Guido van Rossum | ecae0b7 | 1996-06-26 19:03:20 +0000 | [diff] [blame] | 1 | % |
| 2 | % myformat.sty for the Python doc [updated to work with Latex2e] |
| 3 | % |
| 4 | |
Fred Drake | 06f169b | 1998-02-11 23:08:20 +0000 | [diff] [blame^] | 5 | \NeedsTeXFormat{LaTeX2e}[1995/12/01] |
| 6 | \ProvidesPackage{myformat} |
| 7 | [1998/01/11 $Revision$ |
| 8 | LaTeX package (Python manual markup)] |
| 9 | |
Guido van Rossum | daff175 | 1997-06-02 17:35:01 +0000 | [diff] [blame] | 10 | % Increase printable page size (copied from fullpage.sty) |
| 11 | \topmargin 0pt |
| 12 | \advance \topmargin by -\headheight |
| 13 | \advance \topmargin by -\headsep |
Fred Drake | 9e24309 | 1998-01-18 05:09:54 +0000 | [diff] [blame] | 14 | |
Guido van Rossum | daff175 | 1997-06-02 17:35:01 +0000 | [diff] [blame] | 15 | \textheight 8.9in |
Fred Drake | 9e24309 | 1998-01-18 05:09:54 +0000 | [diff] [blame] | 16 | |
Guido van Rossum | daff175 | 1997-06-02 17:35:01 +0000 | [diff] [blame] | 17 | \oddsidemargin 0pt |
| 18 | \evensidemargin \oddsidemargin |
| 19 | \marginparwidth 0.5in |
Fred Drake | 9e24309 | 1998-01-18 05:09:54 +0000 | [diff] [blame] | 20 | |
Guido van Rossum | daff175 | 1997-06-02 17:35:01 +0000 | [diff] [blame] | 21 | \textwidth 6.5in |
| 22 | |
Guido van Rossum | 643d932 | 1992-03-31 18:53:47 +0000 | [diff] [blame] | 23 | % Style parameters and macros used by most documents here |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 24 | \raggedbottom |
| 25 | \sloppy |
| 26 | \parindent = 0mm |
| 27 | \parskip = 2mm |
| 28 | |
Fred Drake | 9e24309 | 1998-01-18 05:09:54 +0000 | [diff] [blame] | 29 | % old code font selections: |
| 30 | \let\codefont=\tt |
| 31 | \let\sectcodefont=\tt |
| 32 | |
| 33 | % (Haven't found a new one that gets <, >, and _ right without being |
| 34 | % monospaced.) |
| 35 | |
Guido van Rossum | 4c22cb2 | 1991-01-25 13:28:15 +0000 | [diff] [blame] | 36 | % Variable used by begin code command |
Guido van Rossum | 44000ed | 1991-01-24 16:54:29 +0000 | [diff] [blame] | 37 | \newlength{\codewidth} |
Guido van Rossum | 44000ed | 1991-01-24 16:54:29 +0000 | [diff] [blame] | 38 | |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 39 | % Command to start a code block (follow this by \begin{verbatim}) |
Guido van Rossum | 4c22cb2 | 1991-01-25 13:28:15 +0000 | [diff] [blame] | 40 | \newcommand{\bcode}{ |
| 41 | % Calculate the text width for the minipage: |
| 42 | \setlength{\codewidth}{\linewidth} |
| 43 | \addtolength{\codewidth}{-\parindent} |
| 44 | % |
Guido van Rossum | 4c22cb2 | 1991-01-25 13:28:15 +0000 | [diff] [blame] | 45 | \par |
Guido van Rossum | 92fba02 | 1991-11-12 15:44:51 +0000 | [diff] [blame] | 46 | \vspace{3mm} |
Guido van Rossum | 4c22cb2 | 1991-01-25 13:28:15 +0000 | [diff] [blame] | 47 | \indent |
| 48 | \begin{minipage}[t]{\codewidth} |
| 49 | } |
| 50 | |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 51 | % Command to end a code block (precede this by \end{verbatim}) |
Guido van Rossum | 4c22cb2 | 1991-01-25 13:28:15 +0000 | [diff] [blame] | 52 | \newcommand{\ecode}{ |
| 53 | \end{minipage} |
| 54 | \vspace{3mm} |
| 55 | \par |
| 56 | \noindent |
| 57 | } |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 58 | |
Guido van Rossum | ecae0b7 | 1996-06-26 19:03:20 +0000 | [diff] [blame] | 59 | % Underscore hack (only act like subscript operator if in math mode) |
| 60 | % |
| 61 | % The following is due to Mark Wooding (the old version didn't work with |
| 62 | % Latex 2e. |
| 63 | |
| 64 | \DeclareRobustCommand\hackscore{% |
| 65 | \ifmmode_\else\textunderscore\fi% |
| 66 | } |
| 67 | \begingroup |
| 68 | \catcode`\_\active |
| 69 | \def\next{% |
| 70 | \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}% |
| 71 | } |
| 72 | \expandafter\endgroup\next |
| 73 | |
| 74 | % |
| 75 | % This is the old hack, which didn't work with 2e. |
| 76 | % If you're still using Latex 2.09, you can give it a try if the above fails. |
| 77 | % |
| 78 | %\def\_{\ifnum\fam=\ttfamily \char'137\else{\tt\char'137}\fi} |
| 79 | %\catcode`\_=12 |
| 80 | %\catcode`\_=\active\def_{\ifnum\fam=\ttfamily \char'137 \else{\tt\char'137}\fi} |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 81 | |
Fred Drake | b37a395 | 1998-02-06 22:52:52 +0000 | [diff] [blame] | 82 | |
| 83 | %% Lots of index-entry generation support. |
| 84 | |
| 85 | % Command to wrap around stuff that refers to function/module/attribute names |
| 86 | % in the index. Default behavior: like \code{}. To just keep the index |
| 87 | % entries in the roman font, uncomment the second definition to use instead; |
| 88 | % it matches O'Reilly style more. |
| 89 | \newcommand{\idxcode}[1]{\codefont{#1}} |
| 90 | %\renewcommand{\idxcode}[1]{#1} |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 91 | |
| 92 | % Command to generate two index entries (using subentries) |
Guido van Rossum | 16d6e71 | 1994-08-08 12:30:22 +0000 | [diff] [blame] | 93 | \newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}} |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 94 | |
| 95 | % And three entries (using only one level of subentries) |
Guido van Rossum | 16d6e71 | 1994-08-08 12:30:22 +0000 | [diff] [blame] | 96 | \newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}} |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 97 | |
| 98 | % And four (again, using only one level of subentries) |
| 99 | \newcommand{\indexiv}[4]{ |
| 100 | \index{#1!#2 #3 #4} |
| 101 | \index{#2!#3 #4, #1} |
| 102 | \index{#3!#4, #1 #2} |
| 103 | \index{#4!#1 #2 #3} |
| 104 | } |
| 105 | |
| 106 | % Command to generate a reference to a function, statement, keyword, operator |
Fred Drake | b37a395 | 1998-02-06 22:52:52 +0000 | [diff] [blame] | 107 | \newcommand{\stindex}[1]{\indexii{statement}{#1@{\idxcode{#1}}}} |
| 108 | \newcommand{\opindex}[1]{\indexii{operator}{#1@{\idxcode{#1}}}} |
| 109 | \newcommand{\exindex}[1]{\indexii{exception}{#1@{\idxcode{#1}}}} |
Guido van Rossum | 6886c83 | 1992-04-03 14:44:27 +0000 | [diff] [blame] | 110 | \newcommand{\obindex}[1]{\indexii{object}{#1}} |
Fred Drake | b37a395 | 1998-02-06 22:52:52 +0000 | [diff] [blame] | 111 | \newcommand{\bifuncindex}[1]{\index{#1@{\idxcode{#1}} (built-in function)}} |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 112 | |
| 113 | % Add an index entry for a module |
Fred Drake | b37a395 | 1998-02-06 22:52:52 +0000 | [diff] [blame] | 114 | \newcommand{\refmodule}[2]{\index{#1@{\idxcode{#1}} (#2module)}} |
Fred Drake | 4af1814 | 1997-12-15 22:08:14 +0000 | [diff] [blame] | 115 | \newcommand{\refmodindex}[1]{\refmodule{#1}{}} |
Fred Drake | 207e57b | 1997-12-15 21:37:45 +0000 | [diff] [blame] | 116 | \newcommand{\refbimodindex}[1]{\refmodule{#1}{built-in }} |
| 117 | \newcommand{\refstmodindex}[1]{\refmodule{#1}{standard }} |
| 118 | |
Fred Drake | da941ef | 1998-01-02 02:57:41 +0000 | [diff] [blame] | 119 | % support for the module index |
| 120 | \newwrite\modindexfile |
| 121 | \openout\modindexfile=modules.idx |
| 122 | |
Fred Drake | 207e57b | 1997-12-15 21:37:45 +0000 | [diff] [blame] | 123 | % Add the defining entry for a module |
Fred Drake | b37a395 | 1998-02-06 22:52:52 +0000 | [diff] [blame] | 124 | \newcommand{\defmodindex}[2]{% |
| 125 | \index{#1@{\idxcode{#1}} (#2module)|textbf}% |
Fred Drake | da941ef | 1998-01-02 02:57:41 +0000 | [diff] [blame] | 126 | \write\modindexfile{#1 \thepage}} |
Fred Drake | b192747 | 1998-02-04 14:43:36 +0000 | [diff] [blame] | 127 | \newcommand{\modindex}[1]{\defmodindex{#1}{}} |
Fred Drake | 207e57b | 1997-12-15 21:37:45 +0000 | [diff] [blame] | 128 | \newcommand{\bimodindex}[1]{\defmodindex{#1}{built-in }} |
| 129 | \newcommand{\stmodindex}[1]{\defmodindex{#1}{standard }} |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 130 | |
| 131 | % Additional string for an index entry |
| 132 | \newcommand{\indexsubitem}{} |
Fred Drake | 06f169b | 1998-02-11 23:08:20 +0000 | [diff] [blame^] | 133 | \newcommand{\setindexsubitem}[1]{\renewcommand{\indexsubitem}{#1}} |
Fred Drake | b37a395 | 1998-02-06 22:52:52 +0000 | [diff] [blame] | 134 | \newcommand{\ttindex}[1]{\index{#1@{\idxcode{#1}} \indexsubitem}} |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 135 | |
Guido van Rossum | 5badc75 | 1992-03-06 10:55:46 +0000 | [diff] [blame] | 136 | |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 137 | % from user-level, fulllineitems should be called as an environment |
| 138 | \def\fulllineitems{\list{}{\labelwidth \leftmargin \labelsep 0pt |
| 139 | \rightmargin 0pt \topsep -\parskip \partopsep \parskip |
| 140 | \itemsep -\parsep |
| 141 | \let\makelabel\itemnewline}} |
| 142 | \let\endfulllineitems\endlist |
| 143 | |
| 144 | |
Guido van Rossum | 36f3502 | 1997-05-22 20:43:24 +0000 | [diff] [blame] | 145 | % cfuncdesc should be called as |
| 146 | % \begin{cfuncdesc}{type}{name}{arglist} |
| 147 | % ... description ... |
| 148 | % \end{cfuncdesc} |
Fred Drake | eb33c78 | 1996-10-29 15:55:08 +0000 | [diff] [blame] | 149 | \newcommand{\cfuncline}[3]{\item[\code{#1 #2(\varvars{#3})}]\ttindex{#2}} |
| 150 | \newcommand{\cfuncdesc}[3]{\fulllineitems\cfuncline{#1}{#2}{#3}} |
| 151 | \let\endcfuncdesc\endfulllineitems |
| 152 | |
Guido van Rossum | 36f3502 | 1997-05-22 20:43:24 +0000 | [diff] [blame] | 153 | \newcommand{\cvarline}[2]{\item[\code{#1 #2}]\ttindex{#2}} |
| 154 | \newcommand{\cvardesc}[2]{\fulllineitems\cvarline{#1}{#2}} |
| 155 | \let\endcvardesc\endfulllineitems |
| 156 | |
| 157 | \newcommand{\ctypeline}[1]{\item[\code{#1}]\ttindex{#1}} |
| 158 | \newcommand{\ctypedesc}[1]{\fulllineitems\ctypeline{#1}} |
| 159 | \let\endctypedesc\endfulllineitems |
| 160 | |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 161 | % funcdesc should be called as an \begin{funcdesc} ... \end{funcdesc} |
| 162 | \newcommand{\funcline}[2]{\item[\code{#1(\varvars{#2})}]\ttindex{#1}} |
| 163 | \newcommand{\funcdesc}[2]{\fulllineitems\funcline{#1}{#2}} |
| 164 | \let\endfuncdesc\endfulllineitems |
Fred Drake | 6c886a8 | 1998-01-12 14:44:33 +0000 | [diff] [blame] | 165 | \newcommand{\optional}[1]{{\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}} } |
Guido van Rossum | 16d6e71 | 1994-08-08 12:30:22 +0000 | [diff] [blame] | 166 | |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 167 | |
| 168 | % same for excdesc |
| 169 | \newcommand{\excline}[1]{\item[\code{#1}]\ttindex{#1}} |
| 170 | \newcommand{\excdesc}[1]{\fulllineitems\excline{#1}} |
| 171 | \let\endexcdesc\endfulllineitems |
| 172 | |
| 173 | % same for datadesc |
| 174 | \newcommand{\dataline}[1]{\item[\code{#1}]\ttindex{#1}} |
| 175 | \newcommand{\datadesc}[1]{\fulllineitems\dataline{#1}} |
| 176 | \let\enddatadesc\endfulllineitems |
| 177 | |
| 178 | |
Fred Drake | a610f9f | 1997-12-03 03:42:39 +0000 | [diff] [blame] | 179 | % opcodedesc should be called as an \begin{opcodedesc} ... \end{opcodedesc} |
| 180 | \newcommand{\opcodeline}[2]{\item[\code{#1\quad\varvars{#2}}]\ttindex{#1}} |
| 181 | \newcommand{\opcodedesc}[2]{\fulllineitems\opcodeline{#1}{#2}} |
| 182 | \let\endopcodedesc\endfulllineitems |
| 183 | |
| 184 | |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 185 | \let\nodename=\label |
| 186 | |
Fred Drake | 3082424 | 1996-12-13 21:53:07 +0000 | [diff] [blame] | 187 | %% For these commands, use \command{} to get the typography right, not |
| 188 | %% {\command}. This works better with the texinfo translation. |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 189 | \newcommand{\ABC}{{\sc abc}} |
| 190 | \newcommand{\UNIX}{{\sc Unix}} |
Fred Drake | 311c196 | 1998-01-20 05:07:19 +0000 | [diff] [blame] | 191 | \newcommand{\POSIX}{POSIX} |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 192 | \newcommand{\ASCII}{{\sc ascii}} |
Guido van Rossum | 16d6e71 | 1994-08-08 12:30:22 +0000 | [diff] [blame] | 193 | \newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}} |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 194 | \newcommand{\C}{C} |
| 195 | \newcommand{\EOF}{{\sc eof}} |
Guido van Rossum | 9231c8f | 1997-05-15 21:43:21 +0000 | [diff] [blame] | 196 | \newcommand{\NULL}{\code{NULL}} |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 197 | |
| 198 | % code is the most difficult one... |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 199 | \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 Drake | 9e24309 | 1998-01-18 05:09:54 +0000 | [diff] [blame] | 200 | \mbox{\codefont{#1}}}} |
Guido van Rossum | ecae0b7 | 1996-06-26 19:03:20 +0000 | [diff] [blame] | 201 | |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 202 | \newcommand{\kbd}[1]{\mbox{\tt #1}} |
| 203 | \newcommand{\key}[1]{\mbox{\tt #1}} |
| 204 | \newcommand{\samp}[1]{\mbox{`\code{#1}'}} |
Fred Drake | 9e24309 | 1998-01-18 05:09:54 +0000 | [diff] [blame] | 205 | % This weird definition of \var{} allows it to always appear in roman italics, |
Fred Drake | 06f169b | 1998-02-11 23:08:20 +0000 | [diff] [blame^] | 206 | % and won't get funky in code fragments when we play around with fonts. |
Fred Drake | 9e24309 | 1998-01-18 05:09:54 +0000 | [diff] [blame] | 207 | \newcommand{\var}[1]{\mbox{\textrm{\textit{#1\/}}}} |
Guido van Rossum | 4541602 | 1995-03-30 16:00:58 +0000 | [diff] [blame] | 208 | \newcommand{\dfn}[1]{{\em #1\/}} |
Guido van Rossum | ecae0b7 | 1996-06-26 19:03:20 +0000 | [diff] [blame] | 209 | \renewcommand{\emph}[1]{{\em #1\/}} |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 210 | \newcommand{\strong}[1]{{\bf #1}} |
Fred Drake | 06f169b | 1998-02-11 23:08:20 +0000 | [diff] [blame^] | 211 | % let's experiment with a new font: |
| 212 | \newcommand{\file}[1]{\mbox{`\textsf{#1}'}} |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 213 | |
Fred Drake | 9b550d9 | 1996-11-11 20:43:46 +0000 | [diff] [blame] | 214 | \newcommand{\varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}} |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 215 | |
| 216 | \newif\iftexi\texifalse |
Guido van Rossum | ecae0b7 | 1996-06-26 19:03:20 +0000 | [diff] [blame] | 217 | \newif\iflatex\latextrue |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 218 | |
Fred Drake | 311c196 | 1998-01-20 05:07:19 +0000 | [diff] [blame] | 219 | % Proposed new macros: These should be used for all references to identifiers |
| 220 | % which are used to refer to instances of specific language constructs. See |
| 221 | % the names for specific semantic assignments. |
| 222 | % |
Fred Drake | dd28d57 | 1998-01-22 15:55:21 +0000 | [diff] [blame] | 223 | % For now, don't do anything really fancy with them; just use them as logical |
| 224 | % markup. This might change in the future. |
Fred Drake | 311c196 | 1998-01-20 05:07:19 +0000 | [diff] [blame] | 225 | % |
| 226 | \let\module=\code |
Fred Drake | dd28d57 | 1998-01-22 15:55:21 +0000 | [diff] [blame] | 227 | \let\keyword=\code |
| 228 | \let\exception=\code |
Fred Drake | 311c196 | 1998-01-20 05:07:19 +0000 | [diff] [blame] | 229 | \let\class=\code |
Fred Drake | dd28d57 | 1998-01-22 15:55:21 +0000 | [diff] [blame] | 230 | \let\function=\code |
| 231 | \let\cfunction=\code |
| 232 | \let\method=\code |
| 233 | |
| 234 | % constants defined in Python modules, not language constants: |
| 235 | \let\constant=\code |
Fred Drake | 311c196 | 1998-01-20 05:07:19 +0000 | [diff] [blame] | 236 | |
| 237 | \newcommand{\manpage}[2]{{\emph{#1}(#2)}} |
Fred Drake | 06f169b | 1998-02-11 23:08:20 +0000 | [diff] [blame^] | 238 | \newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}} |
Fred Drake | 311c196 | 1998-01-20 05:07:19 +0000 | [diff] [blame] | 239 | \let\email=\code |
| 240 | \let\url=\code |
| 241 | |
| 242 | |
Guido van Rossum | e7af5a0 | 1994-08-01 12:39:35 +0000 | [diff] [blame] | 243 | \newenvironment{tableii}[4]{\begin{center}\def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}\begin{tabular}{#1}\hline#3\\ |
| 244 | \hline}{\hline\end{tabular}\end{center}} |
| 245 | |
Guido van Rossum | 95cd2ef | 1992-12-08 14:37:55 +0000 | [diff] [blame] | 246 | \newenvironment{tableiii}[5]{\begin{center}\def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}\begin{tabular}{#1}\hline#3\\ |
| 247 | \hline}{\hline\end{tabular}\end{center}} |
| 248 | |
| 249 | \newcommand{\itemnewline}[1]{\@tempdima\linewidth |
| 250 | \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}} |
| 251 | |
Fred Drake | 9e24309 | 1998-01-18 05:09:54 +0000 | [diff] [blame] | 252 | \newcommand{\sectcode}[1]{{\sectcodefont{#1}}} |
Guido van Rossum | e3d5fc5 | 1997-07-17 18:27:53 +0000 | [diff] [blame] | 253 | |
| 254 | % Cross-referencing (AMK) |
| 255 | % Sample usage: |
| 256 | % \begin{seealso} |
| 257 | % \seemodule{rand}{Uniform random number generator}; % Module xref |
| 258 | % \seetext{{\em Encyclopedia Britannica}}. % Ref to a book |
| 259 | % \end{seealso} |
| 260 | |
Fred Drake | 6c886a8 | 1998-01-12 14:44:33 +0000 | [diff] [blame] | 261 | \newenvironment{seealso}[0]{{\bf See Also:}\par}{\par} |
Fred Drake | 0f02628 | 1998-01-22 17:43:15 +0000 | [diff] [blame] | 262 | \newcommand{\seemodule}[2]{\ref{module-#1}: \module{#1}\quad(#2)} |
Guido van Rossum | e3d5fc5 | 1997-07-17 18:27:53 +0000 | [diff] [blame] | 263 | \newcommand{\seetext}[1]{\par{#1}} |
Fred Drake | da941ef | 1998-01-02 02:57:41 +0000 | [diff] [blame] | 264 | |
| 265 | % Fix the theindex environment to add an entry to the Table of Contents; |
| 266 | % this is much nicer than just having to jump to the end of the book and |
| 267 | % flip around, especially with multiple indexes. |
| 268 | % |
| 269 | \let\OldTheindex=\theindex |
Fred Drake | 06f169b | 1998-02-11 23:08:20 +0000 | [diff] [blame^] | 270 | \renewcommand{\theindex}{% |
Fred Drake | da941ef | 1998-01-02 02:57:41 +0000 | [diff] [blame] | 271 | \OldTheindex% |
| 272 | \addcontentsline{toc}{chapter}{\indexname}% |
| 273 | } |
Fred Drake | 031ad4b | 1998-01-09 05:34:23 +0000 | [diff] [blame] | 274 | |
| 275 | % Use a similar trick to catch the end of the {abstract} environment, |
| 276 | % but here make sure the abstract is followed by a blank page if the |
| 277 | % 'openright' option is used. |
| 278 | % |
| 279 | \let\OldEndAbstract=\endabstract |
Fred Drake | 06f169b | 1998-02-11 23:08:20 +0000 | [diff] [blame^] | 280 | \renewcommand{\endabstract}{ |
Fred Drake | 737e73e | 1998-01-13 22:40:08 +0000 | [diff] [blame] | 281 | \if@openright |
| 282 | \ifodd\value{page} |
| 283 | \typeout{Adding blank page after the abstract.} |
| 284 | \vfil\pagebreak |
Fred Drake | 031ad4b | 1998-01-09 05:34:23 +0000 | [diff] [blame] | 285 | \fi |
Fred Drake | 737e73e | 1998-01-13 22:40:08 +0000 | [diff] [blame] | 286 | \fi |
| 287 | \OldEndAbstract |
Fred Drake | 031ad4b | 1998-01-09 05:34:23 +0000 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | % \mytableofcontents wraps the \tableofcontents macro with all the magic to |
| 291 | % get the spacing right and have the right number of pages if the 'openright' |
| 292 | % option has been used. This eliminates a fair amount of crud in the |
| 293 | % individual document files. |
| 294 | % |
Fred Drake | 737e73e | 1998-01-13 22:40:08 +0000 | [diff] [blame] | 295 | \let\OldTableofcontents=\tableofcontents |
Fred Drake | 06f169b | 1998-02-11 23:08:20 +0000 | [diff] [blame^] | 296 | \renewcommand{\tableofcontents}[0]{% |
| 297 | \setcounter{page}{1}% |
| 298 | \pagebreak% |
| 299 | \pagestyle{plain}% |
| 300 | {% |
| 301 | \parskip = 0mm% |
| 302 | \OldTableofcontents% |
| 303 | \if@openright% |
| 304 | \ifodd\value{page}% |
| 305 | \typeout{Adding blank page after the table of contents.}% |
| 306 | \pagebreak\hspace{0pt}% |
| 307 | \fi% |
| 308 | \fi% |
| 309 | }% |
| 310 | \pagebreak% |
| 311 | } |
| 312 | |
| 313 | % Allow the release number to be specified independently of the \date{}. This |
| 314 | % allows the date to reflect the document's date and release to specify the |
| 315 | % Python release that is documented. |
| 316 | \newcommand{\@release}{} |
| 317 | \newcommand{\version}{} |
| 318 | \newcommand{\releasename}{Release} |
| 319 | \newcommand{\release}[1]{% |
| 320 | \renewcommand{\@release}{\releasename\space\version}% |
| 321 | \renewcommand{\version}{#1}% |
| 322 | } |
| 323 | |
| 324 | % Allow specification of the author's address separately from the author's |
| 325 | % name. This can be used to format them differently, which is a good thing. |
| 326 | \newcommand{\@authoraddress}{} |
| 327 | \newcommand{\authoraddress}[1]{\renewcommand{\@authoraddress}{#1}} |
| 328 | |
| 329 | % Change the title page to look a bit better, and fit in with the fncychap |
| 330 | % ``Bjarne'' style a bit better. |
| 331 | \renewcommand{\maketitle}{\begin{titlepage}% |
| 332 | \let\footnotesize\small |
| 333 | \let\footnoterule\relax |
| 334 | \@ifundefined{ChTitleVar}{}{% |
| 335 | \mghrulefill{\RW}}% |
| 336 | \begin{flushright}% |
| 337 | {\huge \@title \par}% |
| 338 | {\em\LARGE \@release \par} |
| 339 | \vfill |
| 340 | {\LARGE \@author \par} |
| 341 | \vfill\vfill |
| 342 | {\large |
| 343 | \@date \par |
| 344 | \vskip 3em |
| 345 | \@authoraddress \par |
| 346 | }% |
| 347 | \end{flushright}%\par |
| 348 | \@thanks |
| 349 | \end{titlepage}% |
| 350 | \setcounter{footnote}{0}% |
| 351 | \let\thanks\relax\let\maketitle\relax |
| 352 | \gdef\@thanks{}\gdef\@author{}\gdef\@title{} |
| 353 | } |
| 354 | |
| 355 | % ``minitoc'' support; works fairly well but not all chapters do well with it. |
| 356 | % Has some weird side effects that I haven't tracked down; don't use it for |
| 357 | % real at this time. |
| 358 | % |
| 359 | % To enable, uncomment the following line only: |
| 360 | %\RequirePackage{minitoc} |
| 361 | |
| 362 | % Leave the rest as-is: |
| 363 | \newif\if@minitocprinted |
| 364 | \newcommand{\suppressminitoc}{\@minitocprintedtrue} |
| 365 | \@ifundefined{minitoc}{ |
| 366 | % allow \minitoc to be used even if the package hasn't been loaded. |
| 367 | \newcommand{\minitoc}{\@minitocprintedtrue} |
| 368 | }{ |
| 369 | \dominitoc |
| 370 | \newif\if@firstsection |
| 371 | \let\OldChapter=\chapter |
| 372 | \let\OldSection=\section |
| 373 | \let\OldMinitoc=\minitoc |
| 374 | % This will only include the minitoc once per chapter |
| 375 | \renewcommand{\minitoc}{% |
| 376 | \if@minitocprinted{}\else% |
| 377 | \OldMinitoc% |
| 378 | \@minitocprintedtrue% |
| 379 | \fi% |
Fred Drake | 031ad4b | 1998-01-09 05:34:23 +0000 | [diff] [blame] | 380 | } |
Fred Drake | 06f169b | 1998-02-11 23:08:20 +0000 | [diff] [blame^] | 381 | % This includes a minitoc before the first \section{}, if it hasn't |
| 382 | % already been printed using an explicit \minitoc call. |
| 383 | \newcommand{\NewSection}[1]{% |
| 384 | \if@firstsection% |
| 385 | \if@minitocprinted{}\else% |
| 386 | \vskip 15pt% |
| 387 | \minitoc% |
| 388 | \@firstsectionfalse% |
| 389 | \fi% |
| 390 | \fi% |
| 391 | \OldSection{#1}% |
| 392 | } |
| 393 | % Reset the flags for each chaper to let the automatic stuff work. |
| 394 | \newcommand{\NewChapter}[1]{% |
| 395 | \OldChapter{#1}% |
| 396 | \@firstsectiontrue% |
| 397 | \@minitocprintedfalse% |
| 398 | } |
| 399 | \let\chapter=\NewChapter |
| 400 | \let\section=\NewSection |
| 401 | \typeout{Including mini Tables of Contents in each chapter.} |
| 402 | } |
| 403 | |
| 404 | % This sets up the fancy chapter headings that make the documents look at |
| 405 | % least a little better than the usual LaTeX output. |
| 406 | % |
| 407 | \RequirePackage[Bjarne]{fncychap} |
| 408 | \@ifundefined{ChTitleVar}{}{ |
| 409 | \ChTitleVar{\raggedleft \rm\Huge} |
| 410 | % This creates chapter heads without the leading \vspace*{}: |
| 411 | \def\@makechapterhead#1{% |
| 412 | {\parindent \z@ \raggedright \normalfont |
| 413 | \ifnum \c@secnumdepth >\m@ne |
| 414 | \DOCH |
| 415 | \fi |
| 416 | \interlinepenalty\@M |
| 417 | \DOTI{#1} |
| 418 | } |
| 419 | } |
| 420 | \typeout{Using fancy chapter headings.} |
Fred Drake | 031ad4b | 1998-01-09 05:34:23 +0000 | [diff] [blame] | 421 | } |
Fred Drake | 8362d00 | 1998-01-13 17:29:31 +0000 | [diff] [blame] | 422 | |
| 423 | % Uncomment the following line to use a PostScript font instead of bitmaps: |
Fred Drake | b16166e | 1998-02-09 19:14:54 +0000 | [diff] [blame] | 424 | \RequirePackage{times}\typeout{Using times fonts instead of Computer Modern.} |