blob: 8250ce4d807348bc706cca31c1bbdca115747e50 [file] [log] [blame]
Guido van Rossumecae0b71996-06-26 19:03:20 +00001%
2% myformat.sty for the Python doc [updated to work with Latex2e]
3%
4
Fred Drake06f169b1998-02-11 23:08:20 +00005\NeedsTeXFormat{LaTeX2e}[1995/12/01]
6\ProvidesPackage{myformat}
7 [1998/01/11 $Revision$
8 LaTeX package (Python manual markup)]
9
Guido van Rossumdaff1751997-06-02 17:35:01 +000010% Increase printable page size (copied from fullpage.sty)
11\topmargin 0pt
12\advance \topmargin by -\headheight
13\advance \topmargin by -\headsep
Fred Drake9e243091998-01-18 05:09:54 +000014
Guido van Rossumdaff1751997-06-02 17:35:01 +000015\textheight 8.9in
Fred Drake9e243091998-01-18 05:09:54 +000016
Guido van Rossumdaff1751997-06-02 17:35:01 +000017\oddsidemargin 0pt
18\evensidemargin \oddsidemargin
19\marginparwidth 0.5in
Fred Drake9e243091998-01-18 05:09:54 +000020
Guido van Rossumdaff1751997-06-02 17:35:01 +000021\textwidth 6.5in
22
Guido van Rossum643d9321992-03-31 18:53:47 +000023% Style parameters and macros used by most documents here
Guido van Rossum5badc751992-03-06 10:55:46 +000024\raggedbottom
25\sloppy
26\parindent = 0mm
27\parskip = 2mm
28
Fred Drakedc8af0a1998-02-13 06:48:05 +000029\pagestyle{empty} % start this way; change for
30\pagenumbering{roman} % ToC & chapters
31\setcounter{secnumdepth}{1}
32
Fred Drake9e243091998-01-18 05:09:54 +000033% old code font selections:
34\let\codefont=\tt
35\let\sectcodefont=\tt
36
37% (Haven't found a new one that gets <, >, and _ right without being
38% monospaced.)
39
Guido van Rossum4c22cb21991-01-25 13:28:15 +000040% Variable used by begin code command
Guido van Rossum44000ed1991-01-24 16:54:29 +000041\newlength{\codewidth}
Guido van Rossum44000ed1991-01-24 16:54:29 +000042
Fred Drakedc8af0a1998-02-13 06:48:05 +000043\newcommand{\examplevspace}{2mm}
44\newcommand{\exampleindent}{1cm}
Guido van Rossum5badc751992-03-06 10:55:46 +000045% Command to start a code block (follow this by \begin{verbatim})
Fred Drakedc8af0a1998-02-13 06:48:05 +000046\newcommand{\b@code}{%
47 \begingroup%
48 \setlength{\parindent}\exampleindent%
49 % Calculate the text width for the minipage:
50 \setlength{\codewidth}{\linewidth}%
51 \addtolength{\codewidth}{-\parindent}%
52 %
53 \par%
54 \vspace\examplevspace%
55 \indent%
56 \begin{minipage}[t]{\codewidth}%
57 \small%
Guido van Rossum4c22cb21991-01-25 13:28:15 +000058}
59
Guido van Rossum5badc751992-03-06 10:55:46 +000060% Command to end a code block (precede this by \end{verbatim})
Fred Drakedc8af0a1998-02-13 06:48:05 +000061\newcommand{\e@code}{%
62 \end{minipage}%
63 \endgroup%
Guido van Rossum4c22cb21991-01-25 13:28:15 +000064}
Guido van Rossum5badc751992-03-06 10:55:46 +000065
Fred Drakedc8af0a1998-02-13 06:48:05 +000066\let\OldVerbatim=\verbatim
67\let\OldEndVerbatim=\endverbatim
68\renewcommand{\verbatim}{\b@code\OldVerbatim}
69\renewcommand{\endverbatim}{\OldEndVerbatim\e@code}
70
71% Augment the sectioning commands used to get our own font family in
72% place:
73\newcommand{\HeaderFamily}{\sffamily}
74\renewcommand{\section}{\@startsection {section}{1}{\z@}%
75 {-3.5ex \@plus -1ex \@minus -.2ex}%
76 {2.3ex \@plus.2ex}%
77 {\reset@font\Large\HeaderFamily}}
78\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
79 {-3.25ex\@plus -1ex \@minus -.2ex}%
80 {1.5ex \@plus .2ex}%
81 {\reset@font\large\HeaderFamily}}
82\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}%
83 {-3.25ex\@plus -1ex \@minus -.2ex}%
84 {1.5ex \@plus .2ex}%
85 {\reset@font\normalsize\HeaderFamily}}
86\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
87 {3.25ex \@plus1ex \@minus.2ex}%
88 {-1em}%
89 {\reset@font\normalsize\HeaderFamily}}
90\renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}%
91 {3.25ex \@plus1ex \@minus .2ex}%
92 {-1em}%
93 {\reset@font\normalsize\HeaderFamily}}
94
95
Guido van Rossumecae0b71996-06-26 19:03:20 +000096% Underscore hack (only act like subscript operator if in math mode)
97%
98% The following is due to Mark Wooding (the old version didn't work with
99% Latex 2e.
100
101\DeclareRobustCommand\hackscore{%
102 \ifmmode_\else\textunderscore\fi%
103}
104\begingroup
105\catcode`\_\active
106\def\next{%
107 \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}%
108}
109\expandafter\endgroup\next
110
111%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000112% This is the old hack, which didn't work with 2e.
113% You should not need this since the rest of the documentation is now
114% LaTeX2e-only.
Guido van Rossumecae0b71996-06-26 19:03:20 +0000115%
116%\def\_{\ifnum\fam=\ttfamily \char'137\else{\tt\char'137}\fi}
117%\catcode`\_=12
118%\catcode`\_=\active\def_{\ifnum\fam=\ttfamily \char'137 \else{\tt\char'137}\fi}
Guido van Rossum5badc751992-03-06 10:55:46 +0000119
Fred Drakeb37a3951998-02-06 22:52:52 +0000120
Fred Drakedc8af0a1998-02-13 06:48:05 +0000121
Fred Drakeb37a3951998-02-06 22:52:52 +0000122%% Lots of index-entry generation support.
123
Fred Drakedc8af0a1998-02-13 06:48:05 +0000124% Command to wrap around stuff that refers to function / module /
125% attribute names in the index. Default behavior: like \code{}. To
126% just keep the index entries in the roman font, uncomment the second
127% definition to use instead; it matches O'Reilly style more.
128%
Fred Drakeb37a3951998-02-06 22:52:52 +0000129\newcommand{\idxcode}[1]{\codefont{#1}}
130%\renewcommand{\idxcode}[1]{#1}
Guido van Rossum5badc751992-03-06 10:55:46 +0000131
132% Command to generate two index entries (using subentries)
Guido van Rossum16d6e711994-08-08 12:30:22 +0000133\newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}}
Guido van Rossum5badc751992-03-06 10:55:46 +0000134
135% And three entries (using only one level of subentries)
Guido van Rossum16d6e711994-08-08 12:30:22 +0000136\newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}}
Guido van Rossum5badc751992-03-06 10:55:46 +0000137
138% And four (again, using only one level of subentries)
139\newcommand{\indexiv}[4]{
140\index{#1!#2 #3 #4}
141\index{#2!#3 #4, #1}
142\index{#3!#4, #1 #2}
143\index{#4!#1 #2 #3}
144}
145
Fred Drakedc8af0a1998-02-13 06:48:05 +0000146% Command to generate a reference to a function, statement, keyword,
147% operator.
Fred Drakeb37a3951998-02-06 22:52:52 +0000148\newcommand{\stindex}[1]{\indexii{statement}{#1@{\idxcode{#1}}}}
149\newcommand{\opindex}[1]{\indexii{operator}{#1@{\idxcode{#1}}}}
150\newcommand{\exindex}[1]{\indexii{exception}{#1@{\idxcode{#1}}}}
Guido van Rossum6886c831992-04-03 14:44:27 +0000151\newcommand{\obindex}[1]{\indexii{object}{#1}}
Fred Drakeb37a3951998-02-06 22:52:52 +0000152\newcommand{\bifuncindex}[1]{\index{#1@{\idxcode{#1}} (built-in function)}}
Guido van Rossum5badc751992-03-06 10:55:46 +0000153
154% Add an index entry for a module
Fred Drakeb37a3951998-02-06 22:52:52 +0000155\newcommand{\refmodule}[2]{\index{#1@{\idxcode{#1}} (#2module)}}
Fred Drake4af18141997-12-15 22:08:14 +0000156\newcommand{\refmodindex}[1]{\refmodule{#1}{}}
Fred Drake207e57b1997-12-15 21:37:45 +0000157\newcommand{\refbimodindex}[1]{\refmodule{#1}{built-in }}
158\newcommand{\refstmodindex}[1]{\refmodule{#1}{standard }}
159
Fred Drakeda941ef1998-01-02 02:57:41 +0000160% support for the module index
161\newwrite\modindexfile
162\openout\modindexfile=modules.idx
163
Fred Drake207e57b1997-12-15 21:37:45 +0000164% Add the defining entry for a module
Fred Drakeb37a3951998-02-06 22:52:52 +0000165\newcommand{\defmodindex}[2]{%
166 \index{#1@{\idxcode{#1}} (#2module)|textbf}%
Fred Drakeda941ef1998-01-02 02:57:41 +0000167 \write\modindexfile{#1 \thepage}}
Fred Drakeb1927471998-02-04 14:43:36 +0000168\newcommand{\modindex}[1]{\defmodindex{#1}{}}
Fred Drake207e57b1997-12-15 21:37:45 +0000169\newcommand{\bimodindex}[1]{\defmodindex{#1}{built-in }}
170\newcommand{\stmodindex}[1]{\defmodindex{#1}{standard }}
Guido van Rossum5badc751992-03-06 10:55:46 +0000171
172% Additional string for an index entry
Fred Drakedc8af0a1998-02-13 06:48:05 +0000173\newcommand{\index@subitem}{}
174\newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}}
175\newcommand{\ttindex}[1]{\index{#1@{\idxcode{#1}} \index@subitem}}
Guido van Rossum5badc751992-03-06 10:55:46 +0000176
Guido van Rossum5badc751992-03-06 10:55:46 +0000177
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000178% from user-level, fulllineitems should be called as an environment
179\def\fulllineitems{\list{}{\labelwidth \leftmargin \labelsep 0pt
180\rightmargin 0pt \topsep -\parskip \partopsep \parskip
181\itemsep -\parsep
182\let\makelabel\itemnewline}}
183\let\endfulllineitems\endlist
184
185
Guido van Rossum36f35021997-05-22 20:43:24 +0000186% cfuncdesc should be called as
187% \begin{cfuncdesc}{type}{name}{arglist}
188% ... description ...
189% \end{cfuncdesc}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000190\newcommand{\cfuncline}[3]{\item[\code{#1 \bfcode{#2}(\varvars{#3})}]\ttindex{#2}}
Fred Drakeeb33c781996-10-29 15:55:08 +0000191\newcommand{\cfuncdesc}[3]{\fulllineitems\cfuncline{#1}{#2}{#3}}
192\let\endcfuncdesc\endfulllineitems
193
Fred Drakedc8af0a1998-02-13 06:48:05 +0000194\newcommand{\cvarline}[2]{\item[\code{#1 \bfcode{#2}}]\ttindex{#2}}
Guido van Rossum36f35021997-05-22 20:43:24 +0000195\newcommand{\cvardesc}[2]{\fulllineitems\cvarline{#1}{#2}}
196\let\endcvardesc\endfulllineitems
197
Fred Drakedc8af0a1998-02-13 06:48:05 +0000198\newcommand{\ctypeline}[1]{\item[\bfcode{#1}]\ttindex{#1}}
Guido van Rossum36f35021997-05-22 20:43:24 +0000199\newcommand{\ctypedesc}[1]{\fulllineitems\ctypeline{#1}}
200\let\endctypedesc\endfulllineitems
201
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000202% funcdesc should be called as an \begin{funcdesc} ... \end{funcdesc}
Fred Drakeaebc6f31998-02-13 14:34:04 +0000203\newcommand{\funcline}[2]{\funclineni{#1}{#2}\ttindex{#1}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000204\newcommand{\funcdesc}[2]{\fulllineitems\funcline{#1}{#2}}
205\let\endfuncdesc\endfulllineitems
Fred Drakedc8af0a1998-02-13 06:48:05 +0000206\newcommand{\optional}[1]{{\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
Guido van Rossum16d6e711994-08-08 12:30:22 +0000207
Fred Drakeaebc6f31998-02-13 14:34:04 +0000208% similar to {funcdesc}, but doesn't add to the index
209\newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\varvars{#2})}]}
210\newcommand{\funcdescni}[2]{\fulllineitems\funclineni{#1}{#2}}
211\let\endfuncdescni\endfulllineitems
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000212
213% same for excdesc
Fred Drakedc8af0a1998-02-13 06:48:05 +0000214\newcommand{\excline}[1]{\item[\bfcode{#1}]\ttindex{#1}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000215\newcommand{\excdesc}[1]{\fulllineitems\excline{#1}}
216\let\endexcdesc\endfulllineitems
217
218% same for datadesc
Fred Drakeaebc6f31998-02-13 14:34:04 +0000219\newcommand{\dataline}[1]{\datalineni{#1}\ttindex{#1}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000220\newcommand{\datadesc}[1]{\fulllineitems\dataline{#1}}
221\let\enddatadesc\endfulllineitems
222
Fred Drakeaebc6f31998-02-13 14:34:04 +0000223% similar to {datadesc}, but doesn't add to the index
224\newcommand{\datalineni}[1]{\item[\bfcode{#1}]}
225\newcommand{\datadescni}[1]{\fulllineitems\datalineni{#1}}
226\let\enddatadescni\endfulllineitems
227
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000228
Fred Drakea610f9f1997-12-03 03:42:39 +0000229% opcodedesc should be called as an \begin{opcodedesc} ... \end{opcodedesc}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000230\newcommand{\opcodeline}[2]{\item[\bfcode{#1}\quad\var{#2}]}
Fred Drakea610f9f1997-12-03 03:42:39 +0000231\newcommand{\opcodedesc}[2]{\fulllineitems\opcodeline{#1}{#2}}
232\let\endopcodedesc\endfulllineitems
233
234
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000235\let\nodename=\label
236
Fred Drakedc8af0a1998-02-13 06:48:05 +0000237% For these commands, use \command{} to get the typography right, not
238% {\command}. This works better with the texinfo translation.
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000239\newcommand{\ABC}{{\sc abc}}
240\newcommand{\UNIX}{{\sc Unix}}
Fred Drake311c1961998-01-20 05:07:19 +0000241\newcommand{\POSIX}{POSIX}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000242\newcommand{\ASCII}{{\sc ascii}}
Guido van Rossum16d6e711994-08-08 12:30:22 +0000243\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000244\newcommand{\C}{C}
245\newcommand{\EOF}{{\sc eof}}
Guido van Rossum9231c8f1997-05-15 21:43:21 +0000246\newcommand{\NULL}{\code{NULL}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000247
248% code is the most difficult one...
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000249\newcommand{\code}[1]{{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}%
Fred Drake9e243091998-01-18 05:09:54 +0000250\mbox{\codefont{#1}}}}
Guido van Rossumecae0b71996-06-26 19:03:20 +0000251
Fred Drakedc8af0a1998-02-13 06:48:05 +0000252\newcommand{\bfcode}[1]{\code{\bfseries#1}} %bold-faced code font
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000253\newcommand{\kbd}[1]{\mbox{\tt #1}}
254\newcommand{\key}[1]{\mbox{\tt #1}}
255\newcommand{\samp}[1]{\mbox{`\code{#1}'}}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000256% This weird definition of \var{} allows it to always appear in roman
257% italics, and won't get funky in code fragments when we play around
258% with fonts.
259\newcommand{\var}[1]{\mbox{\normalsize\textrm{\textit{#1\/}}}}
Guido van Rossum45416021995-03-30 16:00:58 +0000260\newcommand{\dfn}[1]{{\em #1\/}}
Guido van Rossumecae0b71996-06-26 19:03:20 +0000261\renewcommand{\emph}[1]{{\em #1\/}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000262\newcommand{\strong}[1]{{\bf #1}}
Fred Drake06f169b1998-02-11 23:08:20 +0000263% let's experiment with a new font:
Fred Drakedc8af0a1998-02-13 06:48:05 +0000264\newcommand{\file}[1]{\mbox{`\small\textsf{#1}'}}
265\newcommand{\url}[1]{\mbox{\small\textsf{#1}}}
266\let\email=\url
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000267
Fred Drake9b550d91996-11-11 20:43:46 +0000268\newcommand{\varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000269
270\newif\iftexi\texifalse
Guido van Rossumecae0b71996-06-26 19:03:20 +0000271\newif\iflatex\latextrue
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000272
Fred Drakedc8af0a1998-02-13 06:48:05 +0000273% These should be used for all references to identifiers which are
274% used to refer to instances of specific language constructs. See the
275% names for specific semantic assignments.
Fred Drake311c1961998-01-20 05:07:19 +0000276%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000277% For now, don't do anything really fancy with them; just use them as
278% logical markup. This might change in the future.
Fred Drake311c1961998-01-20 05:07:19 +0000279%
280\let\module=\code
Fred Drakedd28d571998-01-22 15:55:21 +0000281\let\keyword=\code
282\let\exception=\code
Fred Drake311c1961998-01-20 05:07:19 +0000283\let\class=\code
Fred Drakedd28d571998-01-22 15:55:21 +0000284\let\function=\code
285\let\cfunction=\code
286\let\method=\code
287
288% constants defined in Python modules, not language constants:
289\let\constant=\code
Fred Drake311c1961998-01-20 05:07:19 +0000290
291\newcommand{\manpage}[2]{{\emph{#1}(#2)}}
Fred Drake06f169b1998-02-11 23:08:20 +0000292\newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000293\newcommand{\program}[1]{\strong{#1}}
Fred Drake311c1961998-01-20 05:07:19 +0000294
295
Guido van Rossume7af5a01994-08-01 12:39:35 +0000296\newenvironment{tableii}[4]{\begin{center}\def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}\begin{tabular}{#1}\hline#3&#4\\
297\hline}{\hline\end{tabular}\end{center}}
298
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000299\newenvironment{tableiii}[5]{\begin{center}\def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}\begin{tabular}{#1}\hline#3&#4&#5\\
300\hline}{\hline\end{tabular}\end{center}}
301
302\newcommand{\itemnewline}[1]{\@tempdima\linewidth
303\advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}}
304
Fred Drake9e243091998-01-18 05:09:54 +0000305\newcommand{\sectcode}[1]{{\sectcodefont{#1}}}
Guido van Rossume3d5fc51997-07-17 18:27:53 +0000306
307% Cross-referencing (AMK)
308% Sample usage:
309% \begin{seealso}
310% \seemodule{rand}{Uniform random number generator}; % Module xref
Fred Drakedc8af0a1998-02-13 06:48:05 +0000311% \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
Guido van Rossume3d5fc51997-07-17 18:27:53 +0000312% \end{seealso}
313
Fred Drakedc8af0a1998-02-13 06:48:05 +0000314\newenvironment{seealso}[0]{\strong{See Also:}\par}{\par}
Fred Drakeaebc6f31998-02-13 14:34:04 +0000315\newcommand{\seemodule}[2]{\ref{module-#1}:%
316 \quad Module \module{#1}\quad(#2)}
317\newcommand{\seebimodule}[2]{\ref{module-#1}:%
318 \quad Built-in Module \module{#1}\quad(#2)}
319\newcommand{\seestmodule}[2]{\ref{module-#1}:%
320 \quad Standard Module \module{#1}\quad(#2)}
Guido van Rossume3d5fc51997-07-17 18:27:53 +0000321\newcommand{\seetext}[1]{\par{#1}}
Fred Drakeda941ef1998-01-02 02:57:41 +0000322
Fred Drakedc8af0a1998-02-13 06:48:05 +0000323% Fix the theindex environment to add an entry to the Table of
324% Contents; this is much nicer than just having to jump to the end of
325% the book and flip around, especially with multiple indexes.
Fred Drakeda941ef1998-01-02 02:57:41 +0000326%
327\let\OldTheindex=\theindex
Fred Drake06f169b1998-02-11 23:08:20 +0000328\renewcommand{\theindex}{%
Fred Drakeda941ef1998-01-02 02:57:41 +0000329 \OldTheindex%
330 \addcontentsline{toc}{chapter}{\indexname}%
331}
Fred Drake031ad4b1998-01-09 05:34:23 +0000332
333% Use a similar trick to catch the end of the {abstract} environment,
334% but here make sure the abstract is followed by a blank page if the
335% 'openright' option is used.
336%
337\let\OldEndAbstract=\endabstract
Fred Drake06f169b1998-02-11 23:08:20 +0000338\renewcommand{\endabstract}{
Fred Drake737e73e1998-01-13 22:40:08 +0000339 \if@openright
340 \ifodd\value{page}
341 \typeout{Adding blank page after the abstract.}
342 \vfil\pagebreak
Fred Drake031ad4b1998-01-09 05:34:23 +0000343 \fi
Fred Drake737e73e1998-01-13 22:40:08 +0000344 \fi
345 \OldEndAbstract
Fred Drake031ad4b1998-01-09 05:34:23 +0000346}
347
Fred Drakedc8af0a1998-02-13 06:48:05 +0000348% This wraps the \tableofcontents macro with all the magic to get the
349% spacing right and have the right number of pages if the 'openright'
Fred Drake031ad4b1998-01-09 05:34:23 +0000350% option has been used. This eliminates a fair amount of crud in the
351% individual document files.
352%
Fred Drake737e73e1998-01-13 22:40:08 +0000353\let\OldTableofcontents=\tableofcontents
Fred Drake06f169b1998-02-11 23:08:20 +0000354\renewcommand{\tableofcontents}[0]{%
355 \setcounter{page}{1}%
356 \pagebreak%
357 \pagestyle{plain}%
358 {%
359 \parskip = 0mm%
360 \OldTableofcontents%
361 \if@openright%
362 \ifodd\value{page}%
363 \typeout{Adding blank page after the table of contents.}%
364 \pagebreak\hspace{0pt}%
365 \fi%
366 \fi%
367 }%
368 \pagebreak%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000369 \pagenumbering{arabic}%
Fred Drake06f169b1998-02-11 23:08:20 +0000370}
371
Fred Drakedc8af0a1998-02-13 06:48:05 +0000372% Allow the release number to be specified independently of the
373% \date{}. This allows the date to reflect the document's date and
374% release to specify the Python release that is documented.
375%
Fred Drake06f169b1998-02-11 23:08:20 +0000376\newcommand{\@release}{}
377\newcommand{\version}{}
378\newcommand{\releasename}{Release}
379\newcommand{\release}[1]{%
380 \renewcommand{\@release}{\releasename\space\version}%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000381 \renewcommand{\version}{#1}}
Fred Drake06f169b1998-02-11 23:08:20 +0000382
Fred Drakedc8af0a1998-02-13 06:48:05 +0000383% Allow specification of the author's address separately from the
384% author's name. This can be used to format them differently, which
385% is a good thing.
386%
Fred Drake06f169b1998-02-11 23:08:20 +0000387\newcommand{\@authoraddress}{}
388\newcommand{\authoraddress}[1]{\renewcommand{\@authoraddress}{#1}}
389
Fred Drakedc8af0a1998-02-13 06:48:05 +0000390% Change the title page to look a bit better, and fit in with the
391% fncychap ``Bjarne'' style a bit better.
392%
Fred Drake06f169b1998-02-11 23:08:20 +0000393\renewcommand{\maketitle}{\begin{titlepage}%
394 \let\footnotesize\small
395 \let\footnoterule\relax
396 \@ifundefined{ChTitleVar}{}{%
397 \mghrulefill{\RW}}%
398 \begin{flushright}%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000399 {\rm\Huge\HeaderFamily \@title \par}%
400 {\em\LARGE\HeaderFamily \@release \par}
Fred Drake06f169b1998-02-11 23:08:20 +0000401 \vfill
Fred Drakedc8af0a1998-02-13 06:48:05 +0000402 {\LARGE\HeaderFamily \@author \par}
Fred Drake06f169b1998-02-11 23:08:20 +0000403 \vfill\vfill
404 {\large
405 \@date \par
406 \vskip 3em
407 \@authoraddress \par
408 }%
409 \end{flushright}%\par
410 \@thanks
411 \end{titlepage}%
412 \setcounter{footnote}{0}%
413 \let\thanks\relax\let\maketitle\relax
414 \gdef\@thanks{}\gdef\@author{}\gdef\@title{}
415}
416
Fred Drakedc8af0a1998-02-13 06:48:05 +0000417% ``minitoc'' support; works fairly well but not all chapters do well
418% with it. Has some weird side effects that I haven't tracked down;
419% don't use it for real at this time.
Fred Drake06f169b1998-02-11 23:08:20 +0000420%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000421% To enable, uncomment the following line only (don't do it!):
Fred Drake06f169b1998-02-11 23:08:20 +0000422%\RequirePackage{minitoc}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000423%
424% Maybe this should all be removed. But I think something like this
425% would be really nice if it can be integrated with the ``list of
426% modules'' at the top of module-documentation chapters. But it might
427% require a completely new environment, perhaps based on {list}.
Fred Drake06f169b1998-02-11 23:08:20 +0000428
429% Leave the rest as-is:
430\newif\if@minitocprinted
431\newcommand{\suppressminitoc}{\@minitocprintedtrue}
432\@ifundefined{minitoc}{
433 % allow \minitoc to be used even if the package hasn't been loaded.
434 \newcommand{\minitoc}{\@minitocprintedtrue}
435}{
436 \dominitoc
437 \newif\if@firstsection
438 \let\OldChapter=\chapter
439 \let\OldSection=\section
440 \let\OldMinitoc=\minitoc
441 % This will only include the minitoc once per chapter
442 \renewcommand{\minitoc}{%
443 \if@minitocprinted{}\else%
444 \OldMinitoc%
445 \@minitocprintedtrue%
446 \fi%
Fred Drake031ad4b1998-01-09 05:34:23 +0000447 }
Fred Drake06f169b1998-02-11 23:08:20 +0000448 % This includes a minitoc before the first \section{}, if it hasn't
449 % already been printed using an explicit \minitoc call.
450 \newcommand{\NewSection}[1]{%
451 \if@firstsection%
452 \if@minitocprinted{}\else%
453 \vskip 15pt%
454 \minitoc%
455 \@firstsectionfalse%
456 \fi%
457 \fi%
458 \OldSection{#1}%
459 }
460 % Reset the flags for each chaper to let the automatic stuff work.
461 \newcommand{\NewChapter}[1]{%
462 \OldChapter{#1}%
463 \@firstsectiontrue%
464 \@minitocprintedfalse%
465 }
466 \let\chapter=\NewChapter
467 \let\section=\NewSection
468 \typeout{Including mini Tables of Contents in each chapter.}
469}
470
Fred Drakedc8af0a1998-02-13 06:48:05 +0000471% This sets up the fancy chapter headings that make the documents look
472% at least a little better than the usual LaTeX output.
Fred Drake06f169b1998-02-11 23:08:20 +0000473%
474\RequirePackage[Bjarne]{fncychap}
475\@ifundefined{ChTitleVar}{}{
Fred Drakedc8af0a1998-02-13 06:48:05 +0000476 \ChNameVar{\raggedleft\normalsize\HeaderFamily}
477 \ChNumVar{\raggedleft \bfseries\Large\HeaderFamily}
478 \ChTitleVar{\raggedleft \rm\Huge\HeaderFamily}
Fred Drake06f169b1998-02-11 23:08:20 +0000479 % This creates chapter heads without the leading \vspace*{}:
480 \def\@makechapterhead#1{%
481 {\parindent \z@ \raggedright \normalfont
482 \ifnum \c@secnumdepth >\m@ne
483 \DOCH
484 \fi
485 \interlinepenalty\@M
486 \DOTI{#1}
487 }
488 }
489 \typeout{Using fancy chapter headings.}
Fred Drake031ad4b1998-01-09 05:34:23 +0000490}
Fred Drake8362d001998-01-13 17:29:31 +0000491
492% Uncomment the following line to use a PostScript font instead of bitmaps:
Fred Drake63221121998-02-12 03:48:50 +0000493%\RequirePackage{times}\typeout{Using times fonts instead of Computer Modern.}