blob: 1e4ef09a4fe74869d4241d8b2ae6fa611563095d [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
Fred Drake4186cd31998-02-18 17:21:09 +000029% for PDF output, use maximal compression, revise \label{} to support named
30% targets for later linking operations.
31\@ifundefined{pdfannotlink}{}{%
32 \pdfcompresslevel=9
33 \let\OldLabel=\label
34 \renewcommand{\label}[1]{%
35 \OldLabel{#1}%
36 {\pdfdest name {#1} fit}%
37 }
38}
Fred Drake30d17821998-02-17 15:56:55 +000039
Guido van Rossumdaff1751997-06-02 17:35:01 +000040% Increase printable page size (copied from fullpage.sty)
41\topmargin 0pt
42\advance \topmargin by -\headheight
43\advance \topmargin by -\headsep
Fred Drake9e243091998-01-18 05:09:54 +000044
Fred Drake76183c01998-02-16 22:30:10 +000045\textheight 8.7in
Fred Drake9e243091998-01-18 05:09:54 +000046
Guido van Rossumdaff1751997-06-02 17:35:01 +000047\oddsidemargin 0pt
48\evensidemargin \oddsidemargin
49\marginparwidth 0.5in
Fred Drake9e243091998-01-18 05:09:54 +000050
Guido van Rossumdaff1751997-06-02 17:35:01 +000051\textwidth 6.5in
52
Guido van Rossum643d9321992-03-31 18:53:47 +000053% Style parameters and macros used by most documents here
Guido van Rossum5badc751992-03-06 10:55:46 +000054\raggedbottom
55\sloppy
56\parindent = 0mm
57\parskip = 2mm
58
Fred Drake76183c01998-02-16 22:30:10 +000059% uncomment the following line if you have the fancyhdr package available:
Fred Drakedc8af0a1998-02-13 06:48:05 +000060\pagestyle{empty} % start this way; change for
61\pagenumbering{roman} % ToC & chapters
62\setcounter{secnumdepth}{1}
63
Fred Drake76183c01998-02-16 22:30:10 +000064% Redefine the 'normal' header/footer style when using "fancyhdr" package:
65\@ifundefined{fancyhf}{}{
66 \fancypagestyle{normal}{%
67 \fancyhf{}%
68 \fancyfoot[LE,RO]{{\HeaderFamily\thepage}}%
69 \fancyfoot[LO]{{\HeaderFamily\nouppercase{\rightmark}}}%
70 \fancyfoot[RE]{{\HeaderFamily\nouppercase{\leftmark}}}%
71 \renewcommand{\headrulewidth}{0pt}%
72 \renewcommand{\footrulewidth}{0.4pt}%
73 }
74 % Update the plain style so we get the page number & footer line,
75 % but not a chapter or section title. This is to keep the first
76 % page of a chapter and the blank page between chapters `clean.'
77 \fancypagestyle{plain}{%
78 \fancyhf{}%
79 \fancyfoot[LE,RO]{{\HeaderFamily\thepage}}%
80 \renewcommand{\headrulewidth}{0pt}%
81 \renewcommand{\footrulewidth}{0.4pt}%
82 }
83 % Redefine \cleardoublepage so that the blank page between chapters
84 % gets the plain style and not the fancy style.
85 \renewcommand{\cleardoublepage}{\clearpage\if@twoside \ifodd\c@page\else
86 \hbox{}
87 \thispagestyle{plain}
88 \newpage
89 \if@twocolumn\hbox{}\newpage\fi\fi\fi}
90}
91
Fred Drake9e243091998-01-18 05:09:54 +000092% old code font selections:
93\let\codefont=\tt
94\let\sectcodefont=\tt
95
96% (Haven't found a new one that gets <, >, and _ right without being
97% monospaced.)
98
Guido van Rossum4c22cb21991-01-25 13:28:15 +000099% Variable used by begin code command
Guido van Rossum44000ed1991-01-24 16:54:29 +0000100\newlength{\codewidth}
Guido van Rossum44000ed1991-01-24 16:54:29 +0000101
Fred Drakedc8af0a1998-02-13 06:48:05 +0000102\newcommand{\examplevspace}{2mm}
103\newcommand{\exampleindent}{1cm}
Guido van Rossum5badc751992-03-06 10:55:46 +0000104% Command to start a code block (follow this by \begin{verbatim})
Fred Drakedc8af0a1998-02-13 06:48:05 +0000105\newcommand{\b@code}{%
106 \begingroup%
107 \setlength{\parindent}\exampleindent%
108 % Calculate the text width for the minipage:
109 \setlength{\codewidth}{\linewidth}%
110 \addtolength{\codewidth}{-\parindent}%
111 %
112 \par%
113 \vspace\examplevspace%
114 \indent%
115 \begin{minipage}[t]{\codewidth}%
116 \small%
Guido van Rossum4c22cb21991-01-25 13:28:15 +0000117}
118
Guido van Rossum5badc751992-03-06 10:55:46 +0000119% Command to end a code block (precede this by \end{verbatim})
Fred Drakedc8af0a1998-02-13 06:48:05 +0000120\newcommand{\e@code}{%
121 \end{minipage}%
122 \endgroup%
Guido van Rossum4c22cb21991-01-25 13:28:15 +0000123}
Guido van Rossum5badc751992-03-06 10:55:46 +0000124
Fred Drakedc8af0a1998-02-13 06:48:05 +0000125\let\OldVerbatim=\verbatim
126\let\OldEndVerbatim=\endverbatim
127\renewcommand{\verbatim}{\b@code\OldVerbatim}
128\renewcommand{\endverbatim}{\OldEndVerbatim\e@code}
129
130% Augment the sectioning commands used to get our own font family in
131% place:
132\newcommand{\HeaderFamily}{\sffamily}
133\renewcommand{\section}{\@startsection {section}{1}{\z@}%
134 {-3.5ex \@plus -1ex \@minus -.2ex}%
135 {2.3ex \@plus.2ex}%
136 {\reset@font\Large\HeaderFamily}}
137\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
138 {-3.25ex\@plus -1ex \@minus -.2ex}%
139 {1.5ex \@plus .2ex}%
140 {\reset@font\large\HeaderFamily}}
141\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}%
142 {-3.25ex\@plus -1ex \@minus -.2ex}%
143 {1.5ex \@plus .2ex}%
144 {\reset@font\normalsize\HeaderFamily}}
145\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
146 {3.25ex \@plus1ex \@minus.2ex}%
147 {-1em}%
148 {\reset@font\normalsize\HeaderFamily}}
149\renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}%
150 {3.25ex \@plus1ex \@minus .2ex}%
151 {-1em}%
152 {\reset@font\normalsize\HeaderFamily}}
153
154
Guido van Rossumecae0b71996-06-26 19:03:20 +0000155% Underscore hack (only act like subscript operator if in math mode)
156%
157% The following is due to Mark Wooding (the old version didn't work with
158% Latex 2e.
159
160\DeclareRobustCommand\hackscore{%
161 \ifmmode_\else\textunderscore\fi%
162}
163\begingroup
164\catcode`\_\active
165\def\next{%
166 \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}%
167}
168\expandafter\endgroup\next
169
170%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000171% This is the old hack, which didn't work with 2e.
172% You should not need this since the rest of the documentation is now
173% LaTeX2e-only.
Guido van Rossumecae0b71996-06-26 19:03:20 +0000174%
175%\def\_{\ifnum\fam=\ttfamily \char'137\else{\tt\char'137}\fi}
176%\catcode`\_=12
177%\catcode`\_=\active\def_{\ifnum\fam=\ttfamily \char'137 \else{\tt\char'137}\fi}
Guido van Rossum5badc751992-03-06 10:55:46 +0000178
Fred Drakeb37a3951998-02-06 22:52:52 +0000179
Fred Drakedc8af0a1998-02-13 06:48:05 +0000180
Fred Drakeb37a3951998-02-06 22:52:52 +0000181%% Lots of index-entry generation support.
182
Fred Drakedc8af0a1998-02-13 06:48:05 +0000183% Command to wrap around stuff that refers to function / module /
184% attribute names in the index. Default behavior: like \code{}. To
185% just keep the index entries in the roman font, uncomment the second
186% definition to use instead; it matches O'Reilly style more.
187%
Fred Drakeb37a3951998-02-06 22:52:52 +0000188\newcommand{\idxcode}[1]{\codefont{#1}}
189%\renewcommand{\idxcode}[1]{#1}
Guido van Rossum5badc751992-03-06 10:55:46 +0000190
191% Command to generate two index entries (using subentries)
Guido van Rossum16d6e711994-08-08 12:30:22 +0000192\newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}}
Guido van Rossum5badc751992-03-06 10:55:46 +0000193
194% And three entries (using only one level of subentries)
Guido van Rossum16d6e711994-08-08 12:30:22 +0000195\newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}}
Guido van Rossum5badc751992-03-06 10:55:46 +0000196
197% And four (again, using only one level of subentries)
198\newcommand{\indexiv}[4]{
199\index{#1!#2 #3 #4}
200\index{#2!#3 #4, #1}
201\index{#3!#4, #1 #2}
202\index{#4!#1 #2 #3}
203}
204
Fred Drakedc8af0a1998-02-13 06:48:05 +0000205% Command to generate a reference to a function, statement, keyword,
206% operator.
Fred Drakeb37a3951998-02-06 22:52:52 +0000207\newcommand{\stindex}[1]{\indexii{statement}{#1@{\idxcode{#1}}}}
208\newcommand{\opindex}[1]{\indexii{operator}{#1@{\idxcode{#1}}}}
209\newcommand{\exindex}[1]{\indexii{exception}{#1@{\idxcode{#1}}}}
Guido van Rossum6886c831992-04-03 14:44:27 +0000210\newcommand{\obindex}[1]{\indexii{object}{#1}}
Fred Drakeb37a3951998-02-06 22:52:52 +0000211\newcommand{\bifuncindex}[1]{\index{#1@{\idxcode{#1}} (built-in function)}}
Guido van Rossum5badc751992-03-06 10:55:46 +0000212
213% Add an index entry for a module
Fred Drakeb37a3951998-02-06 22:52:52 +0000214\newcommand{\refmodule}[2]{\index{#1@{\idxcode{#1}} (#2module)}}
Fred Drake4af18141997-12-15 22:08:14 +0000215\newcommand{\refmodindex}[1]{\refmodule{#1}{}}
Fred Drake207e57b1997-12-15 21:37:45 +0000216\newcommand{\refbimodindex}[1]{\refmodule{#1}{built-in }}
217\newcommand{\refstmodindex}[1]{\refmodule{#1}{standard }}
218
Fred Drakeda941ef1998-01-02 02:57:41 +0000219% support for the module index
220\newwrite\modindexfile
221\openout\modindexfile=modules.idx
222
Fred Drake207e57b1997-12-15 21:37:45 +0000223% Add the defining entry for a module
Fred Drakeb37a3951998-02-06 22:52:52 +0000224\newcommand{\defmodindex}[2]{%
225 \index{#1@{\idxcode{#1}} (#2module)|textbf}%
Fred Drakeda941ef1998-01-02 02:57:41 +0000226 \write\modindexfile{#1 \thepage}}
Fred Drakeb1927471998-02-04 14:43:36 +0000227\newcommand{\modindex}[1]{\defmodindex{#1}{}}
Fred Drake207e57b1997-12-15 21:37:45 +0000228\newcommand{\bimodindex}[1]{\defmodindex{#1}{built-in }}
229\newcommand{\stmodindex}[1]{\defmodindex{#1}{standard }}
Guido van Rossum5badc751992-03-06 10:55:46 +0000230
231% Additional string for an index entry
Fred Drakedc8af0a1998-02-13 06:48:05 +0000232\newcommand{\index@subitem}{}
233\newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}}
234\newcommand{\ttindex}[1]{\index{#1@{\idxcode{#1}} \index@subitem}}
Guido van Rossum5badc751992-03-06 10:55:46 +0000235
Guido van Rossum5badc751992-03-06 10:55:46 +0000236
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000237% from user-level, fulllineitems should be called as an environment
238\def\fulllineitems{\list{}{\labelwidth \leftmargin \labelsep 0pt
239\rightmargin 0pt \topsep -\parskip \partopsep \parskip
240\itemsep -\parsep
241\let\makelabel\itemnewline}}
242\let\endfulllineitems\endlist
243
244
Guido van Rossum36f35021997-05-22 20:43:24 +0000245% cfuncdesc should be called as
246% \begin{cfuncdesc}{type}{name}{arglist}
247% ... description ...
248% \end{cfuncdesc}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000249\newcommand{\cfuncline}[3]{\item[\code{#1 \bfcode{#2}(\varvars{#3})}]\ttindex{#2}}
Fred Drakeeb33c781996-10-29 15:55:08 +0000250\newcommand{\cfuncdesc}[3]{\fulllineitems\cfuncline{#1}{#2}{#3}}
251\let\endcfuncdesc\endfulllineitems
252
Fred Drakedc8af0a1998-02-13 06:48:05 +0000253\newcommand{\cvarline}[2]{\item[\code{#1 \bfcode{#2}}]\ttindex{#2}}
Guido van Rossum36f35021997-05-22 20:43:24 +0000254\newcommand{\cvardesc}[2]{\fulllineitems\cvarline{#1}{#2}}
255\let\endcvardesc\endfulllineitems
256
Fred Drakedc8af0a1998-02-13 06:48:05 +0000257\newcommand{\ctypeline}[1]{\item[\bfcode{#1}]\ttindex{#1}}
Guido van Rossum36f35021997-05-22 20:43:24 +0000258\newcommand{\ctypedesc}[1]{\fulllineitems\ctypeline{#1}}
259\let\endctypedesc\endfulllineitems
260
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000261% funcdesc should be called as an \begin{funcdesc} ... \end{funcdesc}
Fred Drakeaebc6f31998-02-13 14:34:04 +0000262\newcommand{\funcline}[2]{\funclineni{#1}{#2}\ttindex{#1}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000263\newcommand{\funcdesc}[2]{\fulllineitems\funcline{#1}{#2}}
264\let\endfuncdesc\endfulllineitems
Fred Drakedc8af0a1998-02-13 06:48:05 +0000265\newcommand{\optional}[1]{{\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
Guido van Rossum16d6e711994-08-08 12:30:22 +0000266
Fred Drakeaebc6f31998-02-13 14:34:04 +0000267% similar to {funcdesc}, but doesn't add to the index
268\newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\varvars{#2})}]}
269\newcommand{\funcdescni}[2]{\fulllineitems\funclineni{#1}{#2}}
270\let\endfuncdescni\endfulllineitems
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000271
272% same for excdesc
Fred Drakedc8af0a1998-02-13 06:48:05 +0000273\newcommand{\excline}[1]{\item[\bfcode{#1}]\ttindex{#1}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000274\newcommand{\excdesc}[1]{\fulllineitems\excline{#1}}
275\let\endexcdesc\endfulllineitems
276
277% same for datadesc
Fred Drakeaebc6f31998-02-13 14:34:04 +0000278\newcommand{\dataline}[1]{\datalineni{#1}\ttindex{#1}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000279\newcommand{\datadesc}[1]{\fulllineitems\dataline{#1}}
280\let\enddatadesc\endfulllineitems
281
Fred Drakeaebc6f31998-02-13 14:34:04 +0000282% similar to {datadesc}, but doesn't add to the index
283\newcommand{\datalineni}[1]{\item[\bfcode{#1}]}
284\newcommand{\datadescni}[1]{\fulllineitems\datalineni{#1}}
285\let\enddatadescni\endfulllineitems
286
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000287
Fred Drakea610f9f1997-12-03 03:42:39 +0000288% opcodedesc should be called as an \begin{opcodedesc} ... \end{opcodedesc}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000289\newcommand{\opcodeline}[2]{\item[\bfcode{#1}\quad\var{#2}]}
Fred Drakea610f9f1997-12-03 03:42:39 +0000290\newcommand{\opcodedesc}[2]{\fulllineitems\opcodeline{#1}{#2}}
291\let\endopcodedesc\endfulllineitems
292
293
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000294\let\nodename=\label
295
Fred Drakedc8af0a1998-02-13 06:48:05 +0000296% For these commands, use \command{} to get the typography right, not
297% {\command}. This works better with the texinfo translation.
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000298\newcommand{\ABC}{{\sc abc}}
299\newcommand{\UNIX}{{\sc Unix}}
Fred Drake311c1961998-01-20 05:07:19 +0000300\newcommand{\POSIX}{POSIX}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000301\newcommand{\ASCII}{{\sc ascii}}
Guido van Rossum16d6e711994-08-08 12:30:22 +0000302\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000303\newcommand{\C}{C}
304\newcommand{\EOF}{{\sc eof}}
Guido van Rossum9231c8f1997-05-15 21:43:21 +0000305\newcommand{\NULL}{\code{NULL}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000306
307% code is the most difficult one...
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000308\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 +0000309\mbox{\codefont{#1}}}}
Guido van Rossumecae0b71996-06-26 19:03:20 +0000310
Fred Drakedc8af0a1998-02-13 06:48:05 +0000311\newcommand{\bfcode}[1]{\code{\bfseries#1}} %bold-faced code font
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000312\newcommand{\kbd}[1]{\mbox{\tt #1}}
313\newcommand{\key}[1]{\mbox{\tt #1}}
314\newcommand{\samp}[1]{\mbox{`\code{#1}'}}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000315% This weird definition of \var{} allows it to always appear in roman
316% italics, and won't get funky in code fragments when we play around
317% with fonts.
318\newcommand{\var}[1]{\mbox{\normalsize\textrm{\textit{#1\/}}}}
Guido van Rossum45416021995-03-30 16:00:58 +0000319\newcommand{\dfn}[1]{{\em #1\/}}
Guido van Rossumecae0b71996-06-26 19:03:20 +0000320\renewcommand{\emph}[1]{{\em #1\/}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000321\newcommand{\strong}[1]{{\bf #1}}
Fred Drake06f169b1998-02-11 23:08:20 +0000322% let's experiment with a new font:
Fred Drakedc8af0a1998-02-13 06:48:05 +0000323\newcommand{\file}[1]{\mbox{`\small\textsf{#1}'}}
Fred Drake0c17d661998-02-18 14:24:19 +0000324\@ifundefined{pdfannotlink}{%
Fred Drake53740451998-02-17 15:13:01 +0000325 \newcommand{\url}[1]{\mbox{\small\textsf{#1}}}%
Fred Drake0c17d661998-02-18 14:24:19 +0000326}{
327 \input{pdfcolor}% this really isn't a package
328 \newcommand{\url}[1]{{%
329 \pdfannotlink user{/C [1 1 1] /S /URI /URI (#1)}%
330 \NavyBlue% color of the link text
331 \mbox{\small\textsf{#1}}%
332 \Black% Turn it back off; these are declarative
333 \pdfendlink}}% and don't appear bound to the current
334}% formatting "box".
Fred Drake4186cd31998-02-18 17:21:09 +0000335\newcommand{\email}[1]{\mbox{\small\textsf{#1}}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000336
Fred Drake9b550d91996-11-11 20:43:46 +0000337\newcommand{\varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000338
339\newif\iftexi\texifalse
Guido van Rossumecae0b71996-06-26 19:03:20 +0000340\newif\iflatex\latextrue
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000341
Fred Drakedc8af0a1998-02-13 06:48:05 +0000342% These should be used for all references to identifiers which are
343% used to refer to instances of specific language constructs. See the
344% names for specific semantic assignments.
Fred Drake311c1961998-01-20 05:07:19 +0000345%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000346% For now, don't do anything really fancy with them; just use them as
347% logical markup. This might change in the future.
Fred Drake311c1961998-01-20 05:07:19 +0000348%
349\let\module=\code
Fred Drakedd28d571998-01-22 15:55:21 +0000350\let\keyword=\code
351\let\exception=\code
Fred Drake311c1961998-01-20 05:07:19 +0000352\let\class=\code
Fred Drakedd28d571998-01-22 15:55:21 +0000353\let\function=\code
354\let\cfunction=\code
355\let\method=\code
356
357% constants defined in Python modules, not language constants:
358\let\constant=\code
Fred Drake311c1961998-01-20 05:07:19 +0000359
360\newcommand{\manpage}[2]{{\emph{#1}(#2)}}
Fred Drake06f169b1998-02-11 23:08:20 +0000361\newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000362\newcommand{\program}[1]{\strong{#1}}
Fred Drake311c1961998-01-20 05:07:19 +0000363
364
Guido van Rossume7af5a01994-08-01 12:39:35 +0000365\newenvironment{tableii}[4]{\begin{center}\def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}\begin{tabular}{#1}\hline#3&#4\\
366\hline}{\hline\end{tabular}\end{center}}
367
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000368\newenvironment{tableiii}[5]{\begin{center}\def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}\begin{tabular}{#1}\hline#3&#4&#5\\
369\hline}{\hline\end{tabular}\end{center}}
370
371\newcommand{\itemnewline}[1]{\@tempdima\linewidth
372\advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}}
373
Fred Drake9e243091998-01-18 05:09:54 +0000374\newcommand{\sectcode}[1]{{\sectcodefont{#1}}}
Guido van Rossume3d5fc51997-07-17 18:27:53 +0000375
376% Cross-referencing (AMK)
377% Sample usage:
378% \begin{seealso}
379% \seemodule{rand}{Uniform random number generator}; % Module xref
Fred Drakedc8af0a1998-02-13 06:48:05 +0000380% \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
Guido van Rossume3d5fc51997-07-17 18:27:53 +0000381% \end{seealso}
382
Fred Drakedc8af0a1998-02-13 06:48:05 +0000383\newenvironment{seealso}[0]{\strong{See Also:}\par}{\par}
Fred Drakeaebc6f31998-02-13 14:34:04 +0000384\newcommand{\seemodule}[2]{\ref{module-#1}:%
385 \quad Module \module{#1}\quad(#2)}
386\newcommand{\seebimodule}[2]{\ref{module-#1}:%
387 \quad Built-in Module \module{#1}\quad(#2)}
388\newcommand{\seestmodule}[2]{\ref{module-#1}:%
389 \quad Standard Module \module{#1}\quad(#2)}
Guido van Rossume3d5fc51997-07-17 18:27:53 +0000390\newcommand{\seetext}[1]{\par{#1}}
Fred Drakeda941ef1998-01-02 02:57:41 +0000391
Fred Drakedc8af0a1998-02-13 06:48:05 +0000392% Fix the theindex environment to add an entry to the Table of
393% Contents; this is much nicer than just having to jump to the end of
394% the book and flip around, especially with multiple indexes.
Fred Drakeda941ef1998-01-02 02:57:41 +0000395%
396\let\OldTheindex=\theindex
Fred Drake06f169b1998-02-11 23:08:20 +0000397\renewcommand{\theindex}{%
Fred Drakef1a41501998-02-16 05:30:27 +0000398 \cleardoublepage%
Fred Drakeda941ef1998-01-02 02:57:41 +0000399 \OldTheindex%
400 \addcontentsline{toc}{chapter}{\indexname}%
401}
Fred Drake031ad4b1998-01-09 05:34:23 +0000402
403% Use a similar trick to catch the end of the {abstract} environment,
404% but here make sure the abstract is followed by a blank page if the
405% 'openright' option is used.
406%
407\let\OldEndAbstract=\endabstract
Fred Drake06f169b1998-02-11 23:08:20 +0000408\renewcommand{\endabstract}{
Fred Drake737e73e1998-01-13 22:40:08 +0000409 \if@openright
410 \ifodd\value{page}
411 \typeout{Adding blank page after the abstract.}
412 \vfil\pagebreak
Fred Drake031ad4b1998-01-09 05:34:23 +0000413 \fi
Fred Drake737e73e1998-01-13 22:40:08 +0000414 \fi
415 \OldEndAbstract
Fred Drake031ad4b1998-01-09 05:34:23 +0000416}
417
Fred Drakedc8af0a1998-02-13 06:48:05 +0000418% This wraps the \tableofcontents macro with all the magic to get the
419% spacing right and have the right number of pages if the 'openright'
Fred Drake031ad4b1998-01-09 05:34:23 +0000420% option has been used. This eliminates a fair amount of crud in the
421% individual document files.
422%
Fred Drake737e73e1998-01-13 22:40:08 +0000423\let\OldTableofcontents=\tableofcontents
Fred Drake06f169b1998-02-11 23:08:20 +0000424\renewcommand{\tableofcontents}[0]{%
425 \setcounter{page}{1}%
426 \pagebreak%
427 \pagestyle{plain}%
428 {%
429 \parskip = 0mm%
430 \OldTableofcontents%
431 \if@openright%
432 \ifodd\value{page}%
433 \typeout{Adding blank page after the table of contents.}%
434 \pagebreak\hspace{0pt}%
435 \fi%
436 \fi%
437 }%
Fred Drake4c689631998-02-13 16:58:49 +0000438 \cleardoublepage%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000439 \pagenumbering{arabic}%
Fred Drake76183c01998-02-16 22:30:10 +0000440 \@ifundefined{fancyhf}{}{\pagestyle{normal}}%
Fred Drake06f169b1998-02-11 23:08:20 +0000441}
442
Fred Drakedc8af0a1998-02-13 06:48:05 +0000443% Allow the release number to be specified independently of the
444% \date{}. This allows the date to reflect the document's date and
445% release to specify the Python release that is documented.
446%
Fred Drake06f169b1998-02-11 23:08:20 +0000447\newcommand{\@release}{}
448\newcommand{\version}{}
449\newcommand{\releasename}{Release}
450\newcommand{\release}[1]{%
451 \renewcommand{\@release}{\releasename\space\version}%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000452 \renewcommand{\version}{#1}}
Fred Drake06f169b1998-02-11 23:08:20 +0000453
Fred Drakedc8af0a1998-02-13 06:48:05 +0000454% Allow specification of the author's address separately from the
455% author's name. This can be used to format them differently, which
456% is a good thing.
457%
Fred Drake06f169b1998-02-11 23:08:20 +0000458\newcommand{\@authoraddress}{}
459\newcommand{\authoraddress}[1]{\renewcommand{\@authoraddress}{#1}}
460
Fred Drakedc8af0a1998-02-13 06:48:05 +0000461% Change the title page to look a bit better, and fit in with the
462% fncychap ``Bjarne'' style a bit better.
463%
Fred Drake06f169b1998-02-11 23:08:20 +0000464\renewcommand{\maketitle}{\begin{titlepage}%
465 \let\footnotesize\small
466 \let\footnoterule\relax
467 \@ifundefined{ChTitleVar}{}{%
468 \mghrulefill{\RW}}%
Fred Drake53740451998-02-17 15:13:01 +0000469 \@ifundefined{pdfinfo}{}{
470 \pdfinfo
471 author {\@author}
472 title {\@title}
473 }
Fred Drake06f169b1998-02-11 23:08:20 +0000474 \begin{flushright}%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000475 {\rm\Huge\HeaderFamily \@title \par}%
476 {\em\LARGE\HeaderFamily \@release \par}
Fred Drake06f169b1998-02-11 23:08:20 +0000477 \vfill
Fred Drakedc8af0a1998-02-13 06:48:05 +0000478 {\LARGE\HeaderFamily \@author \par}
Fred Drake06f169b1998-02-11 23:08:20 +0000479 \vfill\vfill
480 {\large
481 \@date \par
482 \vskip 3em
483 \@authoraddress \par
484 }%
485 \end{flushright}%\par
486 \@thanks
487 \end{titlepage}%
488 \setcounter{footnote}{0}%
489 \let\thanks\relax\let\maketitle\relax
490 \gdef\@thanks{}\gdef\@author{}\gdef\@title{}
491}
492
Fred Drakedc8af0a1998-02-13 06:48:05 +0000493% ``minitoc'' support; works fairly well but not all chapters do well
494% with it. Has some weird side effects that I haven't tracked down;
495% don't use it for real at this time.
Fred Drake06f169b1998-02-11 23:08:20 +0000496%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000497% To enable, uncomment the following line only (don't do it!):
Fred Drake06f169b1998-02-11 23:08:20 +0000498%\RequirePackage{minitoc}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000499%
500% Maybe this should all be removed. But I think something like this
501% would be really nice if it can be integrated with the ``list of
502% modules'' at the top of module-documentation chapters. But it might
503% require a completely new environment, perhaps based on {list}.
Fred Drake06f169b1998-02-11 23:08:20 +0000504
505% Leave the rest as-is:
506\newif\if@minitocprinted
507\newcommand{\suppressminitoc}{\@minitocprintedtrue}
508\@ifundefined{minitoc}{
509 % allow \minitoc to be used even if the package hasn't been loaded.
510 \newcommand{\minitoc}{\@minitocprintedtrue}
511}{
512 \dominitoc
513 \newif\if@firstsection
514 \let\OldChapter=\chapter
515 \let\OldSection=\section
516 \let\OldMinitoc=\minitoc
517 % This will only include the minitoc once per chapter
518 \renewcommand{\minitoc}{%
519 \if@minitocprinted{}\else%
520 \OldMinitoc%
521 \@minitocprintedtrue%
522 \fi%
Fred Drake031ad4b1998-01-09 05:34:23 +0000523 }
Fred Drake06f169b1998-02-11 23:08:20 +0000524 % This includes a minitoc before the first \section{}, if it hasn't
525 % already been printed using an explicit \minitoc call.
526 \newcommand{\NewSection}[1]{%
527 \if@firstsection%
528 \if@minitocprinted{}\else%
529 \vskip 15pt%
530 \minitoc%
531 \@firstsectionfalse%
532 \fi%
533 \fi%
534 \OldSection{#1}%
535 }
536 % Reset the flags for each chaper to let the automatic stuff work.
537 \newcommand{\NewChapter}[1]{%
538 \OldChapter{#1}%
539 \@firstsectiontrue%
540 \@minitocprintedfalse%
541 }
542 \let\chapter=\NewChapter
543 \let\section=\NewSection
544 \typeout{Including mini Tables of Contents in each chapter.}
545}
546
Fred Drakedc8af0a1998-02-13 06:48:05 +0000547% This sets up the fancy chapter headings that make the documents look
548% at least a little better than the usual LaTeX output.
Fred Drake06f169b1998-02-11 23:08:20 +0000549%
550\RequirePackage[Bjarne]{fncychap}
551\@ifundefined{ChTitleVar}{}{
Fred Drakedc8af0a1998-02-13 06:48:05 +0000552 \ChNameVar{\raggedleft\normalsize\HeaderFamily}
553 \ChNumVar{\raggedleft \bfseries\Large\HeaderFamily}
554 \ChTitleVar{\raggedleft \rm\Huge\HeaderFamily}
Fred Drake06f169b1998-02-11 23:08:20 +0000555 % This creates chapter heads without the leading \vspace*{}:
556 \def\@makechapterhead#1{%
557 {\parindent \z@ \raggedright \normalfont
558 \ifnum \c@secnumdepth >\m@ne
559 \DOCH
560 \fi
561 \interlinepenalty\@M
562 \DOTI{#1}
563 }
564 }
565 \typeout{Using fancy chapter headings.}
Fred Drake031ad4b1998-01-09 05:34:23 +0000566}