blob: b38ad90e9b84c792da423dfda9cc7511d3e15f98 [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}
Fred Drake76183c01998-02-16 22:30:10 +00007 [1998/01/11
Fred Drake06f169b1998-02-11 23:08:20 +00008 LaTeX package (Python manual markup)]
9
Fred Drake76183c01998-02-16 22:30:10 +000010% Optional packages:
11%
12% If processing of these documents fails at your TeX installation,
13% these may be commented out (independently) to make things work.
14% These are both supplied with the current version of the teTeX
15% distribution.
16%
17% The "fancyhdr" package makes nicer page footers reasonable to
18% implement, and is used to put the chapter and section information in
19% the footers.
20%
21% The "times" package makes the default font the PostScript Times
22% font, which makes for smaller PostScript and a font that more people
23% like.
24%
25\RequirePackage{fancyhdr}\typeout{Using fancier footers than usual....}
26\RequirePackage{times}\typeout{Using times fonts instead of Computer Modern.}
27
28
Guido van Rossumdaff1751997-06-02 17:35:01 +000029% Increase printable page size (copied from fullpage.sty)
30\topmargin 0pt
31\advance \topmargin by -\headheight
32\advance \topmargin by -\headsep
Fred Drake9e243091998-01-18 05:09:54 +000033
Fred Drake76183c01998-02-16 22:30:10 +000034\textheight 8.7in
Fred Drake9e243091998-01-18 05:09:54 +000035
Guido van Rossumdaff1751997-06-02 17:35:01 +000036\oddsidemargin 0pt
37\evensidemargin \oddsidemargin
38\marginparwidth 0.5in
Fred Drake9e243091998-01-18 05:09:54 +000039
Guido van Rossumdaff1751997-06-02 17:35:01 +000040\textwidth 6.5in
41
Guido van Rossum643d9321992-03-31 18:53:47 +000042% Style parameters and macros used by most documents here
Guido van Rossum5badc751992-03-06 10:55:46 +000043\raggedbottom
44\sloppy
45\parindent = 0mm
46\parskip = 2mm
47
Fred Drake76183c01998-02-16 22:30:10 +000048% uncomment the following line if you have the fancyhdr package available:
Fred Drakedc8af0a1998-02-13 06:48:05 +000049\pagestyle{empty} % start this way; change for
50\pagenumbering{roman} % ToC & chapters
51\setcounter{secnumdepth}{1}
52
Fred Drake76183c01998-02-16 22:30:10 +000053% Redefine the 'normal' header/footer style when using "fancyhdr" package:
54\@ifundefined{fancyhf}{}{
55 \fancypagestyle{normal}{%
56 \fancyhf{}%
57 \fancyfoot[LE,RO]{{\HeaderFamily\thepage}}%
58 \fancyfoot[LO]{{\HeaderFamily\nouppercase{\rightmark}}}%
59 \fancyfoot[RE]{{\HeaderFamily\nouppercase{\leftmark}}}%
60 \renewcommand{\headrulewidth}{0pt}%
61 \renewcommand{\footrulewidth}{0.4pt}%
62 }
63 % Update the plain style so we get the page number & footer line,
64 % but not a chapter or section title. This is to keep the first
65 % page of a chapter and the blank page between chapters `clean.'
66 \fancypagestyle{plain}{%
67 \fancyhf{}%
68 \fancyfoot[LE,RO]{{\HeaderFamily\thepage}}%
69 \renewcommand{\headrulewidth}{0pt}%
70 \renewcommand{\footrulewidth}{0.4pt}%
71 }
72 % Redefine \cleardoublepage so that the blank page between chapters
73 % gets the plain style and not the fancy style.
74 \renewcommand{\cleardoublepage}{\clearpage\if@twoside \ifodd\c@page\else
75 \hbox{}
76 \thispagestyle{plain}
77 \newpage
78 \if@twocolumn\hbox{}\newpage\fi\fi\fi}
79}
80
Fred Drake9e243091998-01-18 05:09:54 +000081% old code font selections:
82\let\codefont=\tt
83\let\sectcodefont=\tt
84
85% (Haven't found a new one that gets <, >, and _ right without being
86% monospaced.)
87
Guido van Rossum4c22cb21991-01-25 13:28:15 +000088% Variable used by begin code command
Guido van Rossum44000ed1991-01-24 16:54:29 +000089\newlength{\codewidth}
Guido van Rossum44000ed1991-01-24 16:54:29 +000090
Fred Drakedc8af0a1998-02-13 06:48:05 +000091\newcommand{\examplevspace}{2mm}
92\newcommand{\exampleindent}{1cm}
Guido van Rossum5badc751992-03-06 10:55:46 +000093% Command to start a code block (follow this by \begin{verbatim})
Fred Drakedc8af0a1998-02-13 06:48:05 +000094\newcommand{\b@code}{%
95 \begingroup%
96 \setlength{\parindent}\exampleindent%
97 % Calculate the text width for the minipage:
98 \setlength{\codewidth}{\linewidth}%
99 \addtolength{\codewidth}{-\parindent}%
100 %
101 \par%
102 \vspace\examplevspace%
103 \indent%
104 \begin{minipage}[t]{\codewidth}%
105 \small%
Guido van Rossum4c22cb21991-01-25 13:28:15 +0000106}
107
Guido van Rossum5badc751992-03-06 10:55:46 +0000108% Command to end a code block (precede this by \end{verbatim})
Fred Drakedc8af0a1998-02-13 06:48:05 +0000109\newcommand{\e@code}{%
110 \end{minipage}%
111 \endgroup%
Guido van Rossum4c22cb21991-01-25 13:28:15 +0000112}
Guido van Rossum5badc751992-03-06 10:55:46 +0000113
Fred Drakedc8af0a1998-02-13 06:48:05 +0000114\let\OldVerbatim=\verbatim
115\let\OldEndVerbatim=\endverbatim
116\renewcommand{\verbatim}{\b@code\OldVerbatim}
117\renewcommand{\endverbatim}{\OldEndVerbatim\e@code}
118
119% Augment the sectioning commands used to get our own font family in
120% place:
121\newcommand{\HeaderFamily}{\sffamily}
122\renewcommand{\section}{\@startsection {section}{1}{\z@}%
123 {-3.5ex \@plus -1ex \@minus -.2ex}%
124 {2.3ex \@plus.2ex}%
125 {\reset@font\Large\HeaderFamily}}
126\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
127 {-3.25ex\@plus -1ex \@minus -.2ex}%
128 {1.5ex \@plus .2ex}%
129 {\reset@font\large\HeaderFamily}}
130\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}%
131 {-3.25ex\@plus -1ex \@minus -.2ex}%
132 {1.5ex \@plus .2ex}%
133 {\reset@font\normalsize\HeaderFamily}}
134\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
135 {3.25ex \@plus1ex \@minus.2ex}%
136 {-1em}%
137 {\reset@font\normalsize\HeaderFamily}}
138\renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}%
139 {3.25ex \@plus1ex \@minus .2ex}%
140 {-1em}%
141 {\reset@font\normalsize\HeaderFamily}}
142
143
Guido van Rossumecae0b71996-06-26 19:03:20 +0000144% Underscore hack (only act like subscript operator if in math mode)
145%
146% The following is due to Mark Wooding (the old version didn't work with
147% Latex 2e.
148
149\DeclareRobustCommand\hackscore{%
150 \ifmmode_\else\textunderscore\fi%
151}
152\begingroup
153\catcode`\_\active
154\def\next{%
155 \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}%
156}
157\expandafter\endgroup\next
158
159%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000160% This is the old hack, which didn't work with 2e.
161% You should not need this since the rest of the documentation is now
162% LaTeX2e-only.
Guido van Rossumecae0b71996-06-26 19:03:20 +0000163%
164%\def\_{\ifnum\fam=\ttfamily \char'137\else{\tt\char'137}\fi}
165%\catcode`\_=12
166%\catcode`\_=\active\def_{\ifnum\fam=\ttfamily \char'137 \else{\tt\char'137}\fi}
Guido van Rossum5badc751992-03-06 10:55:46 +0000167
Fred Drakeb37a3951998-02-06 22:52:52 +0000168
Fred Drakedc8af0a1998-02-13 06:48:05 +0000169
Fred Drakeb37a3951998-02-06 22:52:52 +0000170%% Lots of index-entry generation support.
171
Fred Drakedc8af0a1998-02-13 06:48:05 +0000172% Command to wrap around stuff that refers to function / module /
173% attribute names in the index. Default behavior: like \code{}. To
174% just keep the index entries in the roman font, uncomment the second
175% definition to use instead; it matches O'Reilly style more.
176%
Fred Drakeb37a3951998-02-06 22:52:52 +0000177\newcommand{\idxcode}[1]{\codefont{#1}}
178%\renewcommand{\idxcode}[1]{#1}
Guido van Rossum5badc751992-03-06 10:55:46 +0000179
180% Command to generate two index entries (using subentries)
Guido van Rossum16d6e711994-08-08 12:30:22 +0000181\newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}}
Guido van Rossum5badc751992-03-06 10:55:46 +0000182
183% And three entries (using only one level of subentries)
Guido van Rossum16d6e711994-08-08 12:30:22 +0000184\newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}}
Guido van Rossum5badc751992-03-06 10:55:46 +0000185
186% And four (again, using only one level of subentries)
187\newcommand{\indexiv}[4]{
188\index{#1!#2 #3 #4}
189\index{#2!#3 #4, #1}
190\index{#3!#4, #1 #2}
191\index{#4!#1 #2 #3}
192}
193
Fred Drakedc8af0a1998-02-13 06:48:05 +0000194% Command to generate a reference to a function, statement, keyword,
195% operator.
Fred Drakeb37a3951998-02-06 22:52:52 +0000196\newcommand{\stindex}[1]{\indexii{statement}{#1@{\idxcode{#1}}}}
197\newcommand{\opindex}[1]{\indexii{operator}{#1@{\idxcode{#1}}}}
198\newcommand{\exindex}[1]{\indexii{exception}{#1@{\idxcode{#1}}}}
Guido van Rossum6886c831992-04-03 14:44:27 +0000199\newcommand{\obindex}[1]{\indexii{object}{#1}}
Fred Drakeb37a3951998-02-06 22:52:52 +0000200\newcommand{\bifuncindex}[1]{\index{#1@{\idxcode{#1}} (built-in function)}}
Guido van Rossum5badc751992-03-06 10:55:46 +0000201
202% Add an index entry for a module
Fred Drakeb37a3951998-02-06 22:52:52 +0000203\newcommand{\refmodule}[2]{\index{#1@{\idxcode{#1}} (#2module)}}
Fred Drake4af18141997-12-15 22:08:14 +0000204\newcommand{\refmodindex}[1]{\refmodule{#1}{}}
Fred Drake207e57b1997-12-15 21:37:45 +0000205\newcommand{\refbimodindex}[1]{\refmodule{#1}{built-in }}
206\newcommand{\refstmodindex}[1]{\refmodule{#1}{standard }}
207
Fred Drakeda941ef1998-01-02 02:57:41 +0000208% support for the module index
209\newwrite\modindexfile
210\openout\modindexfile=modules.idx
211
Fred Drake207e57b1997-12-15 21:37:45 +0000212% Add the defining entry for a module
Fred Drakeb37a3951998-02-06 22:52:52 +0000213\newcommand{\defmodindex}[2]{%
214 \index{#1@{\idxcode{#1}} (#2module)|textbf}%
Fred Drakeda941ef1998-01-02 02:57:41 +0000215 \write\modindexfile{#1 \thepage}}
Fred Drakeb1927471998-02-04 14:43:36 +0000216\newcommand{\modindex}[1]{\defmodindex{#1}{}}
Fred Drake207e57b1997-12-15 21:37:45 +0000217\newcommand{\bimodindex}[1]{\defmodindex{#1}{built-in }}
218\newcommand{\stmodindex}[1]{\defmodindex{#1}{standard }}
Guido van Rossum5badc751992-03-06 10:55:46 +0000219
220% Additional string for an index entry
Fred Drakedc8af0a1998-02-13 06:48:05 +0000221\newcommand{\index@subitem}{}
222\newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}}
223\newcommand{\ttindex}[1]{\index{#1@{\idxcode{#1}} \index@subitem}}
Guido van Rossum5badc751992-03-06 10:55:46 +0000224
Guido van Rossum5badc751992-03-06 10:55:46 +0000225
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000226% from user-level, fulllineitems should be called as an environment
227\def\fulllineitems{\list{}{\labelwidth \leftmargin \labelsep 0pt
228\rightmargin 0pt \topsep -\parskip \partopsep \parskip
229\itemsep -\parsep
230\let\makelabel\itemnewline}}
231\let\endfulllineitems\endlist
232
233
Guido van Rossum36f35021997-05-22 20:43:24 +0000234% cfuncdesc should be called as
235% \begin{cfuncdesc}{type}{name}{arglist}
236% ... description ...
237% \end{cfuncdesc}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000238\newcommand{\cfuncline}[3]{\item[\code{#1 \bfcode{#2}(\varvars{#3})}]\ttindex{#2}}
Fred Drakeeb33c781996-10-29 15:55:08 +0000239\newcommand{\cfuncdesc}[3]{\fulllineitems\cfuncline{#1}{#2}{#3}}
240\let\endcfuncdesc\endfulllineitems
241
Fred Drakedc8af0a1998-02-13 06:48:05 +0000242\newcommand{\cvarline}[2]{\item[\code{#1 \bfcode{#2}}]\ttindex{#2}}
Guido van Rossum36f35021997-05-22 20:43:24 +0000243\newcommand{\cvardesc}[2]{\fulllineitems\cvarline{#1}{#2}}
244\let\endcvardesc\endfulllineitems
245
Fred Drakedc8af0a1998-02-13 06:48:05 +0000246\newcommand{\ctypeline}[1]{\item[\bfcode{#1}]\ttindex{#1}}
Guido van Rossum36f35021997-05-22 20:43:24 +0000247\newcommand{\ctypedesc}[1]{\fulllineitems\ctypeline{#1}}
248\let\endctypedesc\endfulllineitems
249
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000250% funcdesc should be called as an \begin{funcdesc} ... \end{funcdesc}
Fred Drakeaebc6f31998-02-13 14:34:04 +0000251\newcommand{\funcline}[2]{\funclineni{#1}{#2}\ttindex{#1}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000252\newcommand{\funcdesc}[2]{\fulllineitems\funcline{#1}{#2}}
253\let\endfuncdesc\endfulllineitems
Fred Drakedc8af0a1998-02-13 06:48:05 +0000254\newcommand{\optional}[1]{{\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
Guido van Rossum16d6e711994-08-08 12:30:22 +0000255
Fred Drakeaebc6f31998-02-13 14:34:04 +0000256% similar to {funcdesc}, but doesn't add to the index
257\newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\varvars{#2})}]}
258\newcommand{\funcdescni}[2]{\fulllineitems\funclineni{#1}{#2}}
259\let\endfuncdescni\endfulllineitems
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000260
261% same for excdesc
Fred Drakedc8af0a1998-02-13 06:48:05 +0000262\newcommand{\excline}[1]{\item[\bfcode{#1}]\ttindex{#1}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000263\newcommand{\excdesc}[1]{\fulllineitems\excline{#1}}
264\let\endexcdesc\endfulllineitems
265
266% same for datadesc
Fred Drakeaebc6f31998-02-13 14:34:04 +0000267\newcommand{\dataline}[1]{\datalineni{#1}\ttindex{#1}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000268\newcommand{\datadesc}[1]{\fulllineitems\dataline{#1}}
269\let\enddatadesc\endfulllineitems
270
Fred Drakeaebc6f31998-02-13 14:34:04 +0000271% similar to {datadesc}, but doesn't add to the index
272\newcommand{\datalineni}[1]{\item[\bfcode{#1}]}
273\newcommand{\datadescni}[1]{\fulllineitems\datalineni{#1}}
274\let\enddatadescni\endfulllineitems
275
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000276
Fred Drakea610f9f1997-12-03 03:42:39 +0000277% opcodedesc should be called as an \begin{opcodedesc} ... \end{opcodedesc}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000278\newcommand{\opcodeline}[2]{\item[\bfcode{#1}\quad\var{#2}]}
Fred Drakea610f9f1997-12-03 03:42:39 +0000279\newcommand{\opcodedesc}[2]{\fulllineitems\opcodeline{#1}{#2}}
280\let\endopcodedesc\endfulllineitems
281
282
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000283\let\nodename=\label
284
Fred Drakedc8af0a1998-02-13 06:48:05 +0000285% For these commands, use \command{} to get the typography right, not
286% {\command}. This works better with the texinfo translation.
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000287\newcommand{\ABC}{{\sc abc}}
288\newcommand{\UNIX}{{\sc Unix}}
Fred Drake311c1961998-01-20 05:07:19 +0000289\newcommand{\POSIX}{POSIX}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000290\newcommand{\ASCII}{{\sc ascii}}
Guido van Rossum16d6e711994-08-08 12:30:22 +0000291\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000292\newcommand{\C}{C}
293\newcommand{\EOF}{{\sc eof}}
Guido van Rossum9231c8f1997-05-15 21:43:21 +0000294\newcommand{\NULL}{\code{NULL}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000295
296% code is the most difficult one...
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000297\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 +0000298\mbox{\codefont{#1}}}}
Guido van Rossumecae0b71996-06-26 19:03:20 +0000299
Fred Drakedc8af0a1998-02-13 06:48:05 +0000300\newcommand{\bfcode}[1]{\code{\bfseries#1}} %bold-faced code font
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000301\newcommand{\kbd}[1]{\mbox{\tt #1}}
302\newcommand{\key}[1]{\mbox{\tt #1}}
303\newcommand{\samp}[1]{\mbox{`\code{#1}'}}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000304% This weird definition of \var{} allows it to always appear in roman
305% italics, and won't get funky in code fragments when we play around
306% with fonts.
307\newcommand{\var}[1]{\mbox{\normalsize\textrm{\textit{#1\/}}}}
Guido van Rossum45416021995-03-30 16:00:58 +0000308\newcommand{\dfn}[1]{{\em #1\/}}
Guido van Rossumecae0b71996-06-26 19:03:20 +0000309\renewcommand{\emph}[1]{{\em #1\/}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000310\newcommand{\strong}[1]{{\bf #1}}
Fred Drake06f169b1998-02-11 23:08:20 +0000311% let's experiment with a new font:
Fred Drakedc8af0a1998-02-13 06:48:05 +0000312\newcommand{\file}[1]{\mbox{`\small\textsf{#1}'}}
313\newcommand{\url}[1]{\mbox{\small\textsf{#1}}}
314\let\email=\url
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000315
Fred Drake9b550d91996-11-11 20:43:46 +0000316\newcommand{\varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000317
318\newif\iftexi\texifalse
Guido van Rossumecae0b71996-06-26 19:03:20 +0000319\newif\iflatex\latextrue
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000320
Fred Drakedc8af0a1998-02-13 06:48:05 +0000321% These should be used for all references to identifiers which are
322% used to refer to instances of specific language constructs. See the
323% names for specific semantic assignments.
Fred Drake311c1961998-01-20 05:07:19 +0000324%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000325% For now, don't do anything really fancy with them; just use them as
326% logical markup. This might change in the future.
Fred Drake311c1961998-01-20 05:07:19 +0000327%
328\let\module=\code
Fred Drakedd28d571998-01-22 15:55:21 +0000329\let\keyword=\code
330\let\exception=\code
Fred Drake311c1961998-01-20 05:07:19 +0000331\let\class=\code
Fred Drakedd28d571998-01-22 15:55:21 +0000332\let\function=\code
333\let\cfunction=\code
334\let\method=\code
335
336% constants defined in Python modules, not language constants:
337\let\constant=\code
Fred Drake311c1961998-01-20 05:07:19 +0000338
339\newcommand{\manpage}[2]{{\emph{#1}(#2)}}
Fred Drake06f169b1998-02-11 23:08:20 +0000340\newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000341\newcommand{\program}[1]{\strong{#1}}
Fred Drake311c1961998-01-20 05:07:19 +0000342
343
Guido van Rossume7af5a01994-08-01 12:39:35 +0000344\newenvironment{tableii}[4]{\begin{center}\def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}\begin{tabular}{#1}\hline#3&#4\\
345\hline}{\hline\end{tabular}\end{center}}
346
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000347\newenvironment{tableiii}[5]{\begin{center}\def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}\begin{tabular}{#1}\hline#3&#4&#5\\
348\hline}{\hline\end{tabular}\end{center}}
349
350\newcommand{\itemnewline}[1]{\@tempdima\linewidth
351\advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}}
352
Fred Drake9e243091998-01-18 05:09:54 +0000353\newcommand{\sectcode}[1]{{\sectcodefont{#1}}}
Guido van Rossume3d5fc51997-07-17 18:27:53 +0000354
355% Cross-referencing (AMK)
356% Sample usage:
357% \begin{seealso}
358% \seemodule{rand}{Uniform random number generator}; % Module xref
Fred Drakedc8af0a1998-02-13 06:48:05 +0000359% \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
Guido van Rossume3d5fc51997-07-17 18:27:53 +0000360% \end{seealso}
361
Fred Drakedc8af0a1998-02-13 06:48:05 +0000362\newenvironment{seealso}[0]{\strong{See Also:}\par}{\par}
Fred Drakeaebc6f31998-02-13 14:34:04 +0000363\newcommand{\seemodule}[2]{\ref{module-#1}:%
364 \quad Module \module{#1}\quad(#2)}
365\newcommand{\seebimodule}[2]{\ref{module-#1}:%
366 \quad Built-in Module \module{#1}\quad(#2)}
367\newcommand{\seestmodule}[2]{\ref{module-#1}:%
368 \quad Standard Module \module{#1}\quad(#2)}
Guido van Rossume3d5fc51997-07-17 18:27:53 +0000369\newcommand{\seetext}[1]{\par{#1}}
Fred Drakeda941ef1998-01-02 02:57:41 +0000370
Fred Drakedc8af0a1998-02-13 06:48:05 +0000371% Fix the theindex environment to add an entry to the Table of
372% Contents; this is much nicer than just having to jump to the end of
373% the book and flip around, especially with multiple indexes.
Fred Drakeda941ef1998-01-02 02:57:41 +0000374%
375\let\OldTheindex=\theindex
Fred Drake06f169b1998-02-11 23:08:20 +0000376\renewcommand{\theindex}{%
Fred Drakef1a41501998-02-16 05:30:27 +0000377 \cleardoublepage%
Fred Drakeda941ef1998-01-02 02:57:41 +0000378 \OldTheindex%
379 \addcontentsline{toc}{chapter}{\indexname}%
380}
Fred Drake031ad4b1998-01-09 05:34:23 +0000381
382% Use a similar trick to catch the end of the {abstract} environment,
383% but here make sure the abstract is followed by a blank page if the
384% 'openright' option is used.
385%
386\let\OldEndAbstract=\endabstract
Fred Drake06f169b1998-02-11 23:08:20 +0000387\renewcommand{\endabstract}{
Fred Drake737e73e1998-01-13 22:40:08 +0000388 \if@openright
389 \ifodd\value{page}
390 \typeout{Adding blank page after the abstract.}
391 \vfil\pagebreak
Fred Drake031ad4b1998-01-09 05:34:23 +0000392 \fi
Fred Drake737e73e1998-01-13 22:40:08 +0000393 \fi
394 \OldEndAbstract
Fred Drake031ad4b1998-01-09 05:34:23 +0000395}
396
Fred Drakedc8af0a1998-02-13 06:48:05 +0000397% This wraps the \tableofcontents macro with all the magic to get the
398% spacing right and have the right number of pages if the 'openright'
Fred Drake031ad4b1998-01-09 05:34:23 +0000399% option has been used. This eliminates a fair amount of crud in the
400% individual document files.
401%
Fred Drake737e73e1998-01-13 22:40:08 +0000402\let\OldTableofcontents=\tableofcontents
Fred Drake06f169b1998-02-11 23:08:20 +0000403\renewcommand{\tableofcontents}[0]{%
404 \setcounter{page}{1}%
405 \pagebreak%
406 \pagestyle{plain}%
407 {%
408 \parskip = 0mm%
409 \OldTableofcontents%
410 \if@openright%
411 \ifodd\value{page}%
412 \typeout{Adding blank page after the table of contents.}%
413 \pagebreak\hspace{0pt}%
414 \fi%
415 \fi%
416 }%
Fred Drake4c689631998-02-13 16:58:49 +0000417 \cleardoublepage%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000418 \pagenumbering{arabic}%
Fred Drake76183c01998-02-16 22:30:10 +0000419 \@ifundefined{fancyhf}{}{\pagestyle{normal}}%
Fred Drake06f169b1998-02-11 23:08:20 +0000420}
421
Fred Drakedc8af0a1998-02-13 06:48:05 +0000422% Allow the release number to be specified independently of the
423% \date{}. This allows the date to reflect the document's date and
424% release to specify the Python release that is documented.
425%
Fred Drake06f169b1998-02-11 23:08:20 +0000426\newcommand{\@release}{}
427\newcommand{\version}{}
428\newcommand{\releasename}{Release}
429\newcommand{\release}[1]{%
430 \renewcommand{\@release}{\releasename\space\version}%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000431 \renewcommand{\version}{#1}}
Fred Drake06f169b1998-02-11 23:08:20 +0000432
Fred Drakedc8af0a1998-02-13 06:48:05 +0000433% Allow specification of the author's address separately from the
434% author's name. This can be used to format them differently, which
435% is a good thing.
436%
Fred Drake06f169b1998-02-11 23:08:20 +0000437\newcommand{\@authoraddress}{}
438\newcommand{\authoraddress}[1]{\renewcommand{\@authoraddress}{#1}}
439
Fred Drakedc8af0a1998-02-13 06:48:05 +0000440% Change the title page to look a bit better, and fit in with the
441% fncychap ``Bjarne'' style a bit better.
442%
Fred Drake06f169b1998-02-11 23:08:20 +0000443\renewcommand{\maketitle}{\begin{titlepage}%
444 \let\footnotesize\small
445 \let\footnoterule\relax
446 \@ifundefined{ChTitleVar}{}{%
447 \mghrulefill{\RW}}%
448 \begin{flushright}%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000449 {\rm\Huge\HeaderFamily \@title \par}%
450 {\em\LARGE\HeaderFamily \@release \par}
Fred Drake06f169b1998-02-11 23:08:20 +0000451 \vfill
Fred Drakedc8af0a1998-02-13 06:48:05 +0000452 {\LARGE\HeaderFamily \@author \par}
Fred Drake06f169b1998-02-11 23:08:20 +0000453 \vfill\vfill
454 {\large
455 \@date \par
456 \vskip 3em
457 \@authoraddress \par
458 }%
459 \end{flushright}%\par
460 \@thanks
461 \end{titlepage}%
462 \setcounter{footnote}{0}%
463 \let\thanks\relax\let\maketitle\relax
464 \gdef\@thanks{}\gdef\@author{}\gdef\@title{}
465}
466
Fred Drakedc8af0a1998-02-13 06:48:05 +0000467% ``minitoc'' support; works fairly well but not all chapters do well
468% with it. Has some weird side effects that I haven't tracked down;
469% don't use it for real at this time.
Fred Drake06f169b1998-02-11 23:08:20 +0000470%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000471% To enable, uncomment the following line only (don't do it!):
Fred Drake06f169b1998-02-11 23:08:20 +0000472%\RequirePackage{minitoc}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000473%
474% Maybe this should all be removed. But I think something like this
475% would be really nice if it can be integrated with the ``list of
476% modules'' at the top of module-documentation chapters. But it might
477% require a completely new environment, perhaps based on {list}.
Fred Drake06f169b1998-02-11 23:08:20 +0000478
479% Leave the rest as-is:
480\newif\if@minitocprinted
481\newcommand{\suppressminitoc}{\@minitocprintedtrue}
482\@ifundefined{minitoc}{
483 % allow \minitoc to be used even if the package hasn't been loaded.
484 \newcommand{\minitoc}{\@minitocprintedtrue}
485}{
486 \dominitoc
487 \newif\if@firstsection
488 \let\OldChapter=\chapter
489 \let\OldSection=\section
490 \let\OldMinitoc=\minitoc
491 % This will only include the minitoc once per chapter
492 \renewcommand{\minitoc}{%
493 \if@minitocprinted{}\else%
494 \OldMinitoc%
495 \@minitocprintedtrue%
496 \fi%
Fred Drake031ad4b1998-01-09 05:34:23 +0000497 }
Fred Drake06f169b1998-02-11 23:08:20 +0000498 % This includes a minitoc before the first \section{}, if it hasn't
499 % already been printed using an explicit \minitoc call.
500 \newcommand{\NewSection}[1]{%
501 \if@firstsection%
502 \if@minitocprinted{}\else%
503 \vskip 15pt%
504 \minitoc%
505 \@firstsectionfalse%
506 \fi%
507 \fi%
508 \OldSection{#1}%
509 }
510 % Reset the flags for each chaper to let the automatic stuff work.
511 \newcommand{\NewChapter}[1]{%
512 \OldChapter{#1}%
513 \@firstsectiontrue%
514 \@minitocprintedfalse%
515 }
516 \let\chapter=\NewChapter
517 \let\section=\NewSection
518 \typeout{Including mini Tables of Contents in each chapter.}
519}
520
Fred Drakedc8af0a1998-02-13 06:48:05 +0000521% This sets up the fancy chapter headings that make the documents look
522% at least a little better than the usual LaTeX output.
Fred Drake06f169b1998-02-11 23:08:20 +0000523%
524\RequirePackage[Bjarne]{fncychap}
525\@ifundefined{ChTitleVar}{}{
Fred Drakedc8af0a1998-02-13 06:48:05 +0000526 \ChNameVar{\raggedleft\normalsize\HeaderFamily}
527 \ChNumVar{\raggedleft \bfseries\Large\HeaderFamily}
528 \ChTitleVar{\raggedleft \rm\Huge\HeaderFamily}
Fred Drake06f169b1998-02-11 23:08:20 +0000529 % This creates chapter heads without the leading \vspace*{}:
530 \def\@makechapterhead#1{%
531 {\parindent \z@ \raggedright \normalfont
532 \ifnum \c@secnumdepth >\m@ne
533 \DOCH
534 \fi
535 \interlinepenalty\@M
536 \DOTI{#1}
537 }
538 }
539 \typeout{Using fancy chapter headings.}
Fred Drake031ad4b1998-01-09 05:34:23 +0000540}