blob: 745ac4710d50480b89b25d1960d7f9b0da08ab40 [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 Drakedc8af0a1998-02-13 06:48:05 +0000203\newcommand{\funcline}[2]{\item[\code{\bfcode{#1}(\varvars{#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
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000208
209% same for excdesc
Fred Drakedc8af0a1998-02-13 06:48:05 +0000210\newcommand{\excline}[1]{\item[\bfcode{#1}]\ttindex{#1}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000211\newcommand{\excdesc}[1]{\fulllineitems\excline{#1}}
212\let\endexcdesc\endfulllineitems
213
214% same for datadesc
Fred Drakedc8af0a1998-02-13 06:48:05 +0000215\newcommand{\dataline}[1]{\item[\bfcode{#1}]\ttindex{#1}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000216\newcommand{\datadesc}[1]{\fulllineitems\dataline{#1}}
217\let\enddatadesc\endfulllineitems
218
219
Fred Drakea610f9f1997-12-03 03:42:39 +0000220% opcodedesc should be called as an \begin{opcodedesc} ... \end{opcodedesc}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000221\newcommand{\opcodeline}[2]{\item[\bfcode{#1}\quad\var{#2}]}
Fred Drakea610f9f1997-12-03 03:42:39 +0000222\newcommand{\opcodedesc}[2]{\fulllineitems\opcodeline{#1}{#2}}
223\let\endopcodedesc\endfulllineitems
224
225
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000226\let\nodename=\label
227
Fred Drakedc8af0a1998-02-13 06:48:05 +0000228% For these commands, use \command{} to get the typography right, not
229% {\command}. This works better with the texinfo translation.
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000230\newcommand{\ABC}{{\sc abc}}
231\newcommand{\UNIX}{{\sc Unix}}
Fred Drake311c1961998-01-20 05:07:19 +0000232\newcommand{\POSIX}{POSIX}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000233\newcommand{\ASCII}{{\sc ascii}}
Guido van Rossum16d6e711994-08-08 12:30:22 +0000234\newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000235\newcommand{\C}{C}
236\newcommand{\EOF}{{\sc eof}}
Guido van Rossum9231c8f1997-05-15 21:43:21 +0000237\newcommand{\NULL}{\code{NULL}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000238
239% code is the most difficult one...
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000240\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 +0000241\mbox{\codefont{#1}}}}
Guido van Rossumecae0b71996-06-26 19:03:20 +0000242
Fred Drakedc8af0a1998-02-13 06:48:05 +0000243\newcommand{\bfcode}[1]{\code{\bfseries#1}} %bold-faced code font
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000244\newcommand{\kbd}[1]{\mbox{\tt #1}}
245\newcommand{\key}[1]{\mbox{\tt #1}}
246\newcommand{\samp}[1]{\mbox{`\code{#1}'}}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000247% This weird definition of \var{} allows it to always appear in roman
248% italics, and won't get funky in code fragments when we play around
249% with fonts.
250\newcommand{\var}[1]{\mbox{\normalsize\textrm{\textit{#1\/}}}}
Guido van Rossum45416021995-03-30 16:00:58 +0000251\newcommand{\dfn}[1]{{\em #1\/}}
Guido van Rossumecae0b71996-06-26 19:03:20 +0000252\renewcommand{\emph}[1]{{\em #1\/}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000253\newcommand{\strong}[1]{{\bf #1}}
Fred Drake06f169b1998-02-11 23:08:20 +0000254% let's experiment with a new font:
Fred Drakedc8af0a1998-02-13 06:48:05 +0000255\newcommand{\file}[1]{\mbox{`\small\textsf{#1}'}}
256\newcommand{\url}[1]{\mbox{\small\textsf{#1}}}
257\let\email=\url
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000258
Fred Drake9b550d91996-11-11 20:43:46 +0000259\newcommand{\varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}}
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000260
261\newif\iftexi\texifalse
Guido van Rossumecae0b71996-06-26 19:03:20 +0000262\newif\iflatex\latextrue
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000263
Fred Drakedc8af0a1998-02-13 06:48:05 +0000264% These should be used for all references to identifiers which are
265% used to refer to instances of specific language constructs. See the
266% names for specific semantic assignments.
Fred Drake311c1961998-01-20 05:07:19 +0000267%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000268% For now, don't do anything really fancy with them; just use them as
269% logical markup. This might change in the future.
Fred Drake311c1961998-01-20 05:07:19 +0000270%
271\let\module=\code
Fred Drakedd28d571998-01-22 15:55:21 +0000272\let\keyword=\code
273\let\exception=\code
Fred Drake311c1961998-01-20 05:07:19 +0000274\let\class=\code
Fred Drakedd28d571998-01-22 15:55:21 +0000275\let\function=\code
276\let\cfunction=\code
277\let\method=\code
278
279% constants defined in Python modules, not language constants:
280\let\constant=\code
Fred Drake311c1961998-01-20 05:07:19 +0000281
282\newcommand{\manpage}[2]{{\emph{#1}(#2)}}
Fred Drake06f169b1998-02-11 23:08:20 +0000283\newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000284\newcommand{\program}[1]{\strong{#1}}
Fred Drake311c1961998-01-20 05:07:19 +0000285
286
Guido van Rossume7af5a01994-08-01 12:39:35 +0000287\newenvironment{tableii}[4]{\begin{center}\def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}\begin{tabular}{#1}\hline#3&#4\\
288\hline}{\hline\end{tabular}\end{center}}
289
Guido van Rossum95cd2ef1992-12-08 14:37:55 +0000290\newenvironment{tableiii}[5]{\begin{center}\def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}\begin{tabular}{#1}\hline#3&#4&#5\\
291\hline}{\hline\end{tabular}\end{center}}
292
293\newcommand{\itemnewline}[1]{\@tempdima\linewidth
294\advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}}
295
Fred Drake9e243091998-01-18 05:09:54 +0000296\newcommand{\sectcode}[1]{{\sectcodefont{#1}}}
Guido van Rossume3d5fc51997-07-17 18:27:53 +0000297
298% Cross-referencing (AMK)
299% Sample usage:
300% \begin{seealso}
301% \seemodule{rand}{Uniform random number generator}; % Module xref
Fred Drakedc8af0a1998-02-13 06:48:05 +0000302% \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
Guido van Rossume3d5fc51997-07-17 18:27:53 +0000303% \end{seealso}
304
Fred Drakedc8af0a1998-02-13 06:48:05 +0000305\newenvironment{seealso}[0]{\strong{See Also:}\par}{\par}
Fred Drake0f026281998-01-22 17:43:15 +0000306\newcommand{\seemodule}[2]{\ref{module-#1}: \module{#1}\quad(#2)}
Guido van Rossume3d5fc51997-07-17 18:27:53 +0000307\newcommand{\seetext}[1]{\par{#1}}
Fred Drakeda941ef1998-01-02 02:57:41 +0000308
Fred Drakedc8af0a1998-02-13 06:48:05 +0000309% Fix the theindex environment to add an entry to the Table of
310% Contents; this is much nicer than just having to jump to the end of
311% the book and flip around, especially with multiple indexes.
Fred Drakeda941ef1998-01-02 02:57:41 +0000312%
313\let\OldTheindex=\theindex
Fred Drake06f169b1998-02-11 23:08:20 +0000314\renewcommand{\theindex}{%
Fred Drakeda941ef1998-01-02 02:57:41 +0000315 \OldTheindex%
316 \addcontentsline{toc}{chapter}{\indexname}%
317}
Fred Drake031ad4b1998-01-09 05:34:23 +0000318
319% Use a similar trick to catch the end of the {abstract} environment,
320% but here make sure the abstract is followed by a blank page if the
321% 'openright' option is used.
322%
323\let\OldEndAbstract=\endabstract
Fred Drake06f169b1998-02-11 23:08:20 +0000324\renewcommand{\endabstract}{
Fred Drake737e73e1998-01-13 22:40:08 +0000325 \if@openright
326 \ifodd\value{page}
327 \typeout{Adding blank page after the abstract.}
328 \vfil\pagebreak
Fred Drake031ad4b1998-01-09 05:34:23 +0000329 \fi
Fred Drake737e73e1998-01-13 22:40:08 +0000330 \fi
331 \OldEndAbstract
Fred Drake031ad4b1998-01-09 05:34:23 +0000332}
333
Fred Drakedc8af0a1998-02-13 06:48:05 +0000334% This wraps the \tableofcontents macro with all the magic to get the
335% spacing right and have the right number of pages if the 'openright'
Fred Drake031ad4b1998-01-09 05:34:23 +0000336% option has been used. This eliminates a fair amount of crud in the
337% individual document files.
338%
Fred Drake737e73e1998-01-13 22:40:08 +0000339\let\OldTableofcontents=\tableofcontents
Fred Drake06f169b1998-02-11 23:08:20 +0000340\renewcommand{\tableofcontents}[0]{%
341 \setcounter{page}{1}%
342 \pagebreak%
343 \pagestyle{plain}%
344 {%
345 \parskip = 0mm%
346 \OldTableofcontents%
347 \if@openright%
348 \ifodd\value{page}%
349 \typeout{Adding blank page after the table of contents.}%
350 \pagebreak\hspace{0pt}%
351 \fi%
352 \fi%
353 }%
354 \pagebreak%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000355 \pagenumbering{arabic}%
Fred Drake06f169b1998-02-11 23:08:20 +0000356}
357
Fred Drakedc8af0a1998-02-13 06:48:05 +0000358% Allow the release number to be specified independently of the
359% \date{}. This allows the date to reflect the document's date and
360% release to specify the Python release that is documented.
361%
Fred Drake06f169b1998-02-11 23:08:20 +0000362\newcommand{\@release}{}
363\newcommand{\version}{}
364\newcommand{\releasename}{Release}
365\newcommand{\release}[1]{%
366 \renewcommand{\@release}{\releasename\space\version}%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000367 \renewcommand{\version}{#1}}
Fred Drake06f169b1998-02-11 23:08:20 +0000368
Fred Drakedc8af0a1998-02-13 06:48:05 +0000369% Allow specification of the author's address separately from the
370% author's name. This can be used to format them differently, which
371% is a good thing.
372%
Fred Drake06f169b1998-02-11 23:08:20 +0000373\newcommand{\@authoraddress}{}
374\newcommand{\authoraddress}[1]{\renewcommand{\@authoraddress}{#1}}
375
Fred Drakedc8af0a1998-02-13 06:48:05 +0000376% Change the title page to look a bit better, and fit in with the
377% fncychap ``Bjarne'' style a bit better.
378%
Fred Drake06f169b1998-02-11 23:08:20 +0000379\renewcommand{\maketitle}{\begin{titlepage}%
380 \let\footnotesize\small
381 \let\footnoterule\relax
382 \@ifundefined{ChTitleVar}{}{%
383 \mghrulefill{\RW}}%
384 \begin{flushright}%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000385 {\rm\Huge\HeaderFamily \@title \par}%
386 {\em\LARGE\HeaderFamily \@release \par}
Fred Drake06f169b1998-02-11 23:08:20 +0000387 \vfill
Fred Drakedc8af0a1998-02-13 06:48:05 +0000388 {\LARGE\HeaderFamily \@author \par}
Fred Drake06f169b1998-02-11 23:08:20 +0000389 \vfill\vfill
390 {\large
391 \@date \par
392 \vskip 3em
393 \@authoraddress \par
394 }%
395 \end{flushright}%\par
396 \@thanks
397 \end{titlepage}%
398 \setcounter{footnote}{0}%
399 \let\thanks\relax\let\maketitle\relax
400 \gdef\@thanks{}\gdef\@author{}\gdef\@title{}
401}
402
Fred Drakedc8af0a1998-02-13 06:48:05 +0000403% ``minitoc'' support; works fairly well but not all chapters do well
404% with it. Has some weird side effects that I haven't tracked down;
405% don't use it for real at this time.
Fred Drake06f169b1998-02-11 23:08:20 +0000406%
Fred Drakedc8af0a1998-02-13 06:48:05 +0000407% To enable, uncomment the following line only (don't do it!):
Fred Drake06f169b1998-02-11 23:08:20 +0000408%\RequirePackage{minitoc}
Fred Drakedc8af0a1998-02-13 06:48:05 +0000409%
410% Maybe this should all be removed. But I think something like this
411% would be really nice if it can be integrated with the ``list of
412% modules'' at the top of module-documentation chapters. But it might
413% require a completely new environment, perhaps based on {list}.
Fred Drake06f169b1998-02-11 23:08:20 +0000414
415% Leave the rest as-is:
416\newif\if@minitocprinted
417\newcommand{\suppressminitoc}{\@minitocprintedtrue}
418\@ifundefined{minitoc}{
419 % allow \minitoc to be used even if the package hasn't been loaded.
420 \newcommand{\minitoc}{\@minitocprintedtrue}
421}{
422 \dominitoc
423 \newif\if@firstsection
424 \let\OldChapter=\chapter
425 \let\OldSection=\section
426 \let\OldMinitoc=\minitoc
427 % This will only include the minitoc once per chapter
428 \renewcommand{\minitoc}{%
429 \if@minitocprinted{}\else%
430 \OldMinitoc%
431 \@minitocprintedtrue%
432 \fi%
Fred Drake031ad4b1998-01-09 05:34:23 +0000433 }
Fred Drake06f169b1998-02-11 23:08:20 +0000434 % This includes a minitoc before the first \section{}, if it hasn't
435 % already been printed using an explicit \minitoc call.
436 \newcommand{\NewSection}[1]{%
437 \if@firstsection%
438 \if@minitocprinted{}\else%
439 \vskip 15pt%
440 \minitoc%
441 \@firstsectionfalse%
442 \fi%
443 \fi%
444 \OldSection{#1}%
445 }
446 % Reset the flags for each chaper to let the automatic stuff work.
447 \newcommand{\NewChapter}[1]{%
448 \OldChapter{#1}%
449 \@firstsectiontrue%
450 \@minitocprintedfalse%
451 }
452 \let\chapter=\NewChapter
453 \let\section=\NewSection
454 \typeout{Including mini Tables of Contents in each chapter.}
455}
456
Fred Drakedc8af0a1998-02-13 06:48:05 +0000457% This sets up the fancy chapter headings that make the documents look
458% at least a little better than the usual LaTeX output.
Fred Drake06f169b1998-02-11 23:08:20 +0000459%
460\RequirePackage[Bjarne]{fncychap}
461\@ifundefined{ChTitleVar}{}{
Fred Drakedc8af0a1998-02-13 06:48:05 +0000462 \ChNameVar{\raggedleft\normalsize\HeaderFamily}
463 \ChNumVar{\raggedleft \bfseries\Large\HeaderFamily}
464 \ChTitleVar{\raggedleft \rm\Huge\HeaderFamily}
Fred Drake06f169b1998-02-11 23:08:20 +0000465 % This creates chapter heads without the leading \vspace*{}:
466 \def\@makechapterhead#1{%
467 {\parindent \z@ \raggedright \normalfont
468 \ifnum \c@secnumdepth >\m@ne
469 \DOCH
470 \fi
471 \interlinepenalty\@M
472 \DOTI{#1}
473 }
474 }
475 \typeout{Using fancy chapter headings.}
Fred Drake031ad4b1998-01-09 05:34:23 +0000476}
Fred Drake8362d001998-01-13 17:29:31 +0000477
478% Uncomment the following line to use a PostScript font instead of bitmaps:
Fred Drake63221121998-02-12 03:48:50 +0000479%\RequirePackage{times}\typeout{Using times fonts instead of Computer Modern.}