Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1 | % |
| 2 | % myformat.sty for the Python docummentation [works only with with Latex2e] |
| 3 | % |
| 4 | |
| 5 | \NeedsTeXFormat{LaTeX2e}[1995/12/01] |
| 6 | \ProvidesPackage{python} |
| 7 | [1998/01/11 LaTeX package (Python manual markup)] |
| 8 | |
| 9 | % The "fncychap" package is used to get the nice chapter headers. The |
| 10 | % .sty file is distributed with Python, so you should not need to disable |
| 11 | % it. You'd also end up with a mixed page style; uglier than stock LaTeX! |
| 12 | % |
| 13 | \RequirePackage[Bjarne]{fncychap}\typeout{Using nice chapter headings.} |
| 14 | |
| 15 | |
| 16 | % for PDF output, use maximal compression |
| 17 | \@ifundefined{pdfannotlink}{ |
| 18 | \let\LinkColor=\relax |
| 19 | \let\NormalColor=\relax |
| 20 | }{% |
| 21 | \input{pdfcolor} |
| 22 | \let\LinkColor=\NavyBlue |
| 23 | \let\NormalColor=\Black |
| 24 | \pdfcompresslevel=9 |
| 25 | \let\OldContentsline=\contentsline |
| 26 | \renewcommand{\contentsline}[3]{% |
| 27 | \OldContentsline{#1}{% |
| 28 | \pdfannotlink attr{/Border [0 0 0]} goto name{page.#3}% |
| 29 | \LinkColor#2\NormalColor% |
| 30 | \pdfendlink% |
| 31 | }{#3}% |
| 32 | } |
| 33 | \let\OldLabel=\label |
| 34 | \renewcommand{\label}[1]{% |
| 35 | \OldLabel{#1}% |
| 36 | {\pdfdest name{label.#1} fit}% |
| 37 | } |
| 38 | % This stuff adds a page.# destination to every PDF page, where # has |
| 39 | % the same formatting as the displayed page number. This doesn't really |
| 40 | % help with the frontmatter, but does fine with the body. |
| 41 | % |
| 42 | % This is *heavily* based on the hyperref package. |
| 43 | % |
| 44 | \def\@begindvi{% |
| 45 | \unvbox \@begindvibox |
| 46 | \@hyperfixhead |
| 47 | \global\let \@begindvi \@hyperfixhead |
| 48 | } |
| 49 | \def\hyperpageanchor{% |
| 50 | \hyper@anchorstart{page.\thepage}\hyper@anchorend |
| 51 | } |
| 52 | \let\HYPERPAGEANCHOR\hyperpageanchor |
| 53 | \def\@hyperfixhead{% |
| 54 | \let\H@old@thehead\@thehead |
| 55 | \gdef\@foo{\pdfdest name{page.\thepage} fit}% |
| 56 | \expandafter\ifx\expandafter\@empty\H@old@thehead |
| 57 | \def\H@old@thehead{\hfil}\fi |
| 58 | \def\@thehead{\@foo\relax\H@old@thehead}% |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | % Increase printable page size (copied from fullpage.sty) |
| 63 | \topmargin 0pt |
| 64 | \advance \topmargin by -\headheight |
| 65 | \advance \topmargin by -\headsep |
| 66 | |
| 67 | % attempt to work a little better for A4 users |
| 68 | \@ifundefined{paperheight}{ |
| 69 | \textheight 9in |
| 70 | }{ |
| 71 | \textheight \paperheight |
| 72 | \advance\textheight by -2in |
| 73 | } |
| 74 | |
| 75 | \oddsidemargin 0pt |
| 76 | \evensidemargin \oddsidemargin |
| 77 | \marginparwidth 0.5in |
| 78 | |
| 79 | \@ifundefined{paperwidth}{ |
| 80 | \textwidth 6.5in |
| 81 | }{ |
| 82 | \textwidth \paperwidth |
| 83 | \advance\textwidth by -2in |
| 84 | } |
| 85 | |
| 86 | |
| 87 | % Style parameters and macros used by most documents here |
| 88 | \raggedbottom |
| 89 | \sloppy |
| 90 | \parindent = 0mm |
| 91 | \parskip = 2mm |
| 92 | \hbadness = 5000 % don't print trivial gripes |
| 93 | |
| 94 | \pagestyle{empty} % start this way; change for |
| 95 | \pagenumbering{roman} % ToC & chapters |
| 96 | \setcounter{secnumdepth}{1} |
| 97 | |
| 98 | % Use this to set the font family for headers and other decor: |
| 99 | \newcommand{\HeaderFamily}{\sffamily} |
| 100 | |
| 101 | % Redefine the 'normal' header/footer style when using "fancyhdr" package: |
| 102 | \@ifundefined{fancyhf}{}{ |
| 103 | % Use \pagestyle{normal} as the primary pagestyle for text. |
| 104 | \fancypagestyle{normal}{ |
| 105 | \fancyhf{} |
| 106 | \fancyfoot[LE,RO]{{\HeaderFamily\thepage}} |
| 107 | \fancyfoot[LO]{{\HeaderFamily\nouppercase{\rightmark}}} |
| 108 | \fancyfoot[RE]{{\HeaderFamily\nouppercase{\leftmark}}} |
| 109 | \renewcommand{\headrulewidth}{0pt} |
| 110 | \renewcommand{\footrulewidth}{0.4pt} |
| 111 | } |
| 112 | % Update the plain style so we get the page number & footer line, |
| 113 | % but not a chapter or section title. This is to keep the first |
| 114 | % page of a chapter and the blank page between chapters `clean.' |
| 115 | \fancypagestyle{plain}{ |
| 116 | \fancyhf{} |
| 117 | \fancyfoot[LE,RO]{{\HeaderFamily\thepage}} |
| 118 | \renewcommand{\headrulewidth}{0pt} |
| 119 | \renewcommand{\footrulewidth}{0.4pt} |
| 120 | } |
| 121 | % Redefine \cleardoublepage so that the blank page between chapters |
| 122 | % gets the plain style and not the fancy style. This is described |
| 123 | % in the documentation for the fancyhdr package by Piet von Oostrum. |
| 124 | \renewcommand{\cleardoublepage}{ |
| 125 | \clearpage\if@openright \ifodd\c@page\else |
| 126 | \hbox{} |
| 127 | \thispagestyle{plain} |
| 128 | \newpage |
| 129 | \if@twocolumn\hbox{}\newpage\fi\fi\fi} |
| 130 | } |
| 131 | |
| 132 | % old code font selections: |
| 133 | \let\codefont=\tt |
| 134 | \let\sectcodefont=\tt |
| 135 | |
| 136 | % (Haven't found a new one that gets <, >, and _ right without being |
| 137 | % monospaced.) |
| 138 | |
| 139 | |
| 140 | % This sets up the {verbatim} environment to be indented and a minipage, |
| 141 | % and to have all the other mostly nice properties that we want for |
| 142 | % code samples. |
| 143 | |
| 144 | % Variable used by begin code command |
| 145 | \newlength{\codewidth} |
| 146 | |
| 147 | \newcommand{\examplevspace}{2mm} |
| 148 | \newcommand{\exampleindent}{1cm} |
| 149 | |
| 150 | \let\OldVerbatim=\verbatim |
| 151 | \let\OldEndVerbatim=\endverbatim |
| 152 | \renewcommand{\verbatim}{% |
| 153 | \begingroup% |
| 154 | \setlength{\parindent}\exampleindent% |
| 155 | % Calculate the text width for the minipage: |
| 156 | \setlength{\codewidth}{\linewidth}% |
| 157 | \addtolength{\codewidth}{-\parindent}% |
| 158 | % |
| 159 | \par% |
| 160 | \vspace\examplevspace% |
| 161 | \indent% |
| 162 | \begin{minipage}[t]{\codewidth}% |
| 163 | \small% |
| 164 | \OldVerbatim% |
| 165 | } |
| 166 | \renewcommand{\endverbatim}{% |
| 167 | \OldEndVerbatim% |
| 168 | \end{minipage}% |
| 169 | \endgroup% |
| 170 | } |
| 171 | |
| 172 | % Augment the sectioning commands used to get our own font family in place: |
| 173 | \renewcommand{\section}{\@startsection {section}{1}{\z@}% |
| 174 | {-3.5ex \@plus -1ex \@minus -.2ex}% |
| 175 | {2.3ex \@plus.2ex}% |
| 176 | {\reset@font\Large\HeaderFamily}} |
| 177 | \renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}% |
| 178 | {-3.25ex\@plus -1ex \@minus -.2ex}% |
| 179 | {1.5ex \@plus .2ex}% |
| 180 | {\reset@font\large\HeaderFamily}} |
| 181 | \renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}% |
| 182 | {-3.25ex\@plus -1ex \@minus -.2ex}% |
| 183 | {1.5ex \@plus .2ex}% |
| 184 | {\reset@font\normalsize\HeaderFamily}} |
| 185 | \renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}% |
| 186 | {3.25ex \@plus1ex \@minus.2ex}% |
| 187 | {-1em}% |
| 188 | {\reset@font\normalsize\HeaderFamily}} |
| 189 | \renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}% |
| 190 | {3.25ex \@plus1ex \@minus .2ex}% |
| 191 | {-1em}% |
| 192 | {\reset@font\normalsize\HeaderFamily}} |
| 193 | |
| 194 | |
| 195 | % Underscore hack (only act like subscript operator if in math mode) |
| 196 | % |
| 197 | % The following is due to Mark Wooding (the old version didn't work with |
| 198 | % Latex 2e. |
| 199 | |
| 200 | \DeclareRobustCommand\hackscore{% |
| 201 | \ifmmode_\else\textunderscore\fi% |
| 202 | } |
| 203 | \begingroup |
| 204 | \catcode`\_\active |
| 205 | \def\next{% |
| 206 | \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}% |
| 207 | } |
| 208 | \expandafter\endgroup\next |
| 209 | |
| 210 | % |
| 211 | % This is the old hack, which didn't work with 2e. |
| 212 | % You should not need this since the rest of the documentation is now |
| 213 | % LaTeX2e-only. |
| 214 | % |
| 215 | %\def\_{\ifnum\fam=\ttfamily \char'137\else{\tt\char'137}\fi} |
| 216 | %\catcode`\_=12 |
| 217 | %\catcode`\_=\active\def_{\ifnum\fam=\ttfamily \char'137 \else{\tt\char'137}\fi} |
| 218 | |
| 219 | |
| 220 | |
| 221 | %% Lots of index-entry generation support. |
| 222 | |
| 223 | % Command to wrap around stuff that refers to function / module / |
| 224 | % attribute names in the index. Default behavior: like \code{}. To |
| 225 | % just keep the index entries in the roman font, uncomment the second |
| 226 | % definition to use instead; it matches O'Reilly style more. |
| 227 | % |
| 228 | \newcommand{\idxcode}[1]{\codefont{#1}} |
| 229 | %\renewcommand{\idxcode}[1]{#1} |
| 230 | |
| 231 | % Command to generate two index entries (using subentries) |
| 232 | \newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}} |
| 233 | |
| 234 | % And three entries (using only one level of subentries) |
| 235 | \newcommand{\indexiii}[3]{\index{#1!#2 #3}\index{#2!#3, #1}\index{#3!#1 #2}} |
| 236 | |
| 237 | % And four (again, using only one level of subentries) |
| 238 | \newcommand{\indexiv}[4]{ |
| 239 | \index{#1!#2 #3 #4} |
| 240 | \index{#2!#3 #4, #1} |
| 241 | \index{#3!#4, #1 #2} |
| 242 | \index{#4!#1 #2 #3} |
| 243 | } |
| 244 | |
| 245 | % Command to generate a reference to a function, statement, keyword, |
| 246 | % operator. |
| 247 | \newcommand{\stindex}[1]{\indexii{statement}{#1@{\idxcode{#1}}}} |
| 248 | \newcommand{\opindex}[1]{\indexii{operator}{#1@{\idxcode{#1}}}} |
| 249 | \newcommand{\exindex}[1]{\indexii{exception}{#1@{\idxcode{#1}}}} |
| 250 | \newcommand{\obindex}[1]{\indexii{object}{#1}} |
| 251 | \newcommand{\bifuncindex}[1]{\index{#1@{\idxcode{#1()}} (built-in function)}} |
| 252 | |
| 253 | % Add an index entry for a module |
| 254 | \newcommand{\refmodule}[2]{\index{#1@{\idxcode{#1}} (#2module)}} |
| 255 | \newcommand{\refmodindex}[1]{\refmodule{#1}{}} |
| 256 | \newcommand{\refbimodindex}[1]{\refmodule{#1}{built-in }} |
| 257 | \newcommand{\refexmodindex}[1]{\refmodule{#1}{extension }} |
| 258 | \newcommand{\refstmodindex}[1]{\refmodule{#1}{standard }} |
| 259 | |
| 260 | % support for the module index |
| 261 | \newwrite\modindexfile |
| 262 | \openout\modindexfile=mod\jobname.idx |
| 263 | |
| 264 | % Add the defining entry for a module |
| 265 | \newcommand{\defmodindex}[2]{% |
| 266 | \index{#1@{\idxcode{#1}} (#2module)|textbf}% |
| 267 | \setindexsubitem{(in module #1)}% |
| 268 | \write\modindexfile{#1 \thepage}} |
| 269 | |
| 270 | % built-in & Python modules in the main distribution |
| 271 | \newcommand{\bimodindex}[1]{\defmodindex{#1}{built-in }} |
| 272 | \newcommand{\stmodindex}[1]{\defmodindex{#1}{standard }} |
| 273 | |
| 274 | % Python & extension modules outside the main distribution |
| 275 | \newcommand{\modindex}[1]{\defmodindex{#1}{}} |
| 276 | \newcommand{\exmodindex}[1]{\defmodindex{#1}{extension }} |
| 277 | |
| 278 | % Additional string for an index entry |
| 279 | \newcommand{\index@subitem}{} |
| 280 | \newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}} |
| 281 | \newcommand{\ttindex}[1]{\index{#1@{\idxcode{#1}} \index@subitem}} |
| 282 | |
| 283 | |
| 284 | % {fulllineitems} is used in one place in libregex.tex, but is really for |
| 285 | % internal use in this file. |
| 286 | % |
| 287 | \newenvironment{fulllineitems}{ |
| 288 | \begin{list}{}{\labelwidth \leftmargin \labelsep 0pt |
| 289 | \rightmargin 0pt \topsep -\parskip \partopsep \parskip |
| 290 | \itemsep -\parsep |
| 291 | \let\makelabel=\itemnewline} |
| 292 | }{\end{list}} |
| 293 | |
| 294 | |
| 295 | % cfuncdesc should be called as |
| 296 | % \begin{cfuncdesc}{type}{name}{arglist} |
| 297 | % ... description ... |
| 298 | % \end{cfuncdesc} |
| 299 | \newenvironment{cfuncdesc}[3]{% |
| 300 | \begin{fulllineitems}% |
| 301 | \item[\code{#1 \bfcode{#2}(\varvars{#3})}]% |
| 302 | \index{#2@{\idxcode{#2()}}}% |
| 303 | }{\end{fulllineitems}} |
| 304 | |
| 305 | \newenvironment{cvardesc}[2]{% |
| 306 | \begin{fulllineitems}% |
| 307 | \item[\code{#1 \bfcode{#2}}]% |
| 308 | \index{#2@{\idxcode{#2}}}% |
| 309 | }{\end{fulllineitems}} |
| 310 | |
| 311 | \newenvironment{ctypedesc}[1]{% |
| 312 | \begin{fulllineitems}% |
| 313 | \item[\bfcode{#1}]\ttindex{#1} |
| 314 | }{\end{fulllineitems}} |
| 315 | |
| 316 | \newcommand{\funcline}[2]{\funclineni{#1}{#2}\ttindex{#1()}} |
| 317 | \newenvironment{funcdesc}[2]{% |
| 318 | \begin{fulllineitems}% |
| 319 | \funcline{#1}{#2}% |
| 320 | }{\end{fulllineitems}} |
| 321 | |
| 322 | \newcommand{\optional}[1]{% |
| 323 | {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}} |
| 324 | |
| 325 | % similar to {funcdesc}, but doesn't add to the index |
| 326 | \newcommand{\funclineni}[2]{\item[\code{\bfcode{#1}(\varvars{#2})}]} |
| 327 | \newenvironment{funcdescni}[2]{% |
| 328 | \begin{fulllineitems}% |
| 329 | \funclineni{#1}{#2}% |
| 330 | }{\end{fulllineitems}} |
| 331 | |
| 332 | \newenvironment{classdesc}[2]{% |
| 333 | \begin{fulllineitems}% |
| 334 | \item[\code{\bfcode{#1}(\varvars{#2})}]% |
| 335 | \ttindex{#1}% |
| 336 | \def\baseclasses##1{}% |
| 337 | }{\end{fulllineitems}} |
| 338 | |
| 339 | \newenvironment{excdesc}[1]{% |
| 340 | \begin{fulllineitems}% |
| 341 | \item[\bfcode{#1}]\ttindex{#1}% |
| 342 | }{\end{fulllineitems}} |
| 343 | |
| 344 | \newcommand{\dataline}[1]{\datalineni{#1}\ttindex{#1}} |
| 345 | \newenvironment{datadesc}[1]{% |
| 346 | \begin{fulllineitems}% |
| 347 | \dataline{#1}% |
| 348 | }{\end{fulllineitems}} |
| 349 | |
| 350 | % similar to {datadesc}, but doesn't add to the index |
| 351 | \newcommand{\datalineni}[1]{\item[\bfcode{#1}]} |
| 352 | \newenvironment{datadescni}[1]{% |
| 353 | \begin{fulllineitems}% |
| 354 | \datalineni{#1}% |
| 355 | }{\end{fulllineitems}} |
| 356 | |
| 357 | \newenvironment{opcodedesc}[2]{% |
| 358 | \begin{fulllineitems}% |
| 359 | \item[\bfcode{#1}\quad\var{#2}]% |
| 360 | }{\end{fulllineitems}} |
| 361 | |
| 362 | |
| 363 | \let\nodename=\label |
| 364 | |
| 365 | % For these commands, use \command{} to get the typography right, not |
| 366 | % {\command}. This works better with the texinfo translation. |
| 367 | \newcommand{\ABC}{{\sc abc}} |
| 368 | \newcommand{\UNIX}{{\sc Unix}} |
| 369 | \newcommand{\POSIX}{POSIX} |
| 370 | \newcommand{\ASCII}{{\sc ascii}} |
| 371 | \newcommand{\Cpp}{C\protect\raisebox{.18ex}{++}} |
| 372 | \newcommand{\C}{C} |
| 373 | \newcommand{\EOF}{{\sc eof}} |
| 374 | \newcommand{\NULL}{\code{NULL}} |
| 375 | |
| 376 | % code is the most difficult one... |
| 377 | \newcommand{\code}[1]{{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}% |
| 378 | \mbox{\codefont{#1}}}} |
| 379 | |
| 380 | \newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font |
| 381 | \newcommand{\kbd}[1]{\mbox{\tt #1}} |
| 382 | \newcommand{\key}[1]{\mbox{\tt #1}} |
| 383 | \newcommand{\samp}[1]{\mbox{`\code{#1}'}} |
| 384 | % This weird definition of \var{} allows it to always appear in roman |
| 385 | % italics, and won't get funky in code fragments when we play around |
| 386 | % with fonts. |
| 387 | \newcommand{\var}[1]{\mbox{\normalsize\textrm{\textit{#1\/}}}} |
| 388 | \renewcommand{\emph}[1]{{\em #1\/}} |
| 389 | \newcommand{\dfn}[1]{\emph{#1}} |
| 390 | \newcommand{\strong}[1]{{\bf #1}} |
| 391 | % let's experiment with a new font: |
| 392 | \newcommand{\file}[1]{\mbox{`\small\textsf{#1}'}} |
| 393 | |
| 394 | % Use this def/redef approach for \url{} since hyperref defined this already, |
| 395 | % but only if we actually used hyperref: |
| 396 | \@ifundefined{pdfannotlink}{% |
| 397 | \newcommand{\pythonurl}[1]{\mbox{\small\textsf{#1}}}% |
| 398 | }{ |
| 399 | \newcommand{\pythonurl}[1]{{% |
| 400 | \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% |
| 401 | \LinkColor% color of the link text |
| 402 | \mbox{\small\textsf{#1}}% |
| 403 | \NormalColor% Turn it back off; these are declarative |
| 404 | \pdfendlink}% and don't appear bound to the current |
| 405 | }% formatting "box". |
| 406 | } |
| 407 | \let\url=\pythonurl |
| 408 | \newcommand{\email}[1]{\mbox{\small\textsf{#1}}} |
| 409 | |
| 410 | \newcommand{\varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}} |
| 411 | |
| 412 | \newif\iftexi\texifalse |
| 413 | \newif\iflatex\latextrue |
| 414 | |
| 415 | % These should be used for all references to identifiers which are |
| 416 | % used to refer to instances of specific language constructs. See the |
| 417 | % names for specific semantic assignments. |
| 418 | % |
| 419 | % For now, don't do anything really fancy with them; just use them as |
| 420 | % logical markup. This might change in the future. |
| 421 | % |
| 422 | \let\module=\code |
| 423 | \let\keyword=\code |
| 424 | \let\exception=\code |
| 425 | \let\class=\code |
| 426 | \let\function=\code |
| 427 | \let\member=\code |
| 428 | \let\method=\code |
| 429 | |
| 430 | \let\cfunction=\code |
| 431 | \let\ctype=\code |
| 432 | \let\cdata=\code |
| 433 | |
| 434 | % constants defined in Python modules or C headers, not language constants: |
| 435 | \let\constant=\code |
| 436 | |
| 437 | \newcommand{\manpage}[2]{{\emph{#1}(#2)}} |
| 438 | \newcommand{\rfc}[1]{RFC #1\index{RFC!RFC #1}} |
| 439 | \newcommand{\program}[1]{\strong{#1}} |
| 440 | |
| 441 | |
| 442 | % Deprecation stuff. |
| 443 | % Should be extended to allow an index / list of deprecated stuff. But |
| 444 | % there's a lot of stuff that needs to be done to make that automatable. |
| 445 | % |
| 446 | % First parameter is the release number that deprecates the feature, the |
| 447 | % second is the action the should be taken by users of the feature. |
| 448 | % |
| 449 | % Example: |
| 450 | % |
| 451 | % \deprecated {1.5.1} |
| 452 | % {Use \method{frobnicate()} instead.} |
| 453 | % |
| 454 | \newcommand{\deprecated}[2]{% |
| 455 | \strong{Deprecated since release #1.} #2\par} |
| 456 | |
| 457 | |
| 458 | \newenvironment{tableii}[4]{% |
| 459 | \begin{center}% |
| 460 | \def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}% |
| 461 | \begin{tabular}{#1}\hline \strong{#3}&\strong{#4} \\ \hline% |
| 462 | }{% |
| 463 | \hline% |
| 464 | \end{tabular}% |
| 465 | \end{center}% |
| 466 | } |
| 467 | |
| 468 | \newenvironment{tableiii}[5]{% |
| 469 | \begin{center}% |
| 470 | \def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}% |
| 471 | \begin{tabular}{#1}\hline \strong{#3}&\strong{#4}&\strong{#5} \\ \hline% |
| 472 | }{% |
| 473 | \hline% |
| 474 | \end{tabular}% |
| 475 | \end{center}% |
| 476 | } |
| 477 | |
| 478 | \newcommand{\itemnewline}[1]{% |
| 479 | \@tempdima\linewidth% |
| 480 | \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}% |
| 481 | } |
| 482 | |
| 483 | \newcommand{\sectcode}[1]{{\sectcodefont{#1}}} |
| 484 | |
| 485 | % Cross-referencing (AMK) |
| 486 | % Sample usage: |
| 487 | % \begin{seealso} |
| 488 | % \seemodule{rand}{Uniform random number generator}; % Module xref |
| 489 | % \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book |
| 490 | % \end{seealso} |
| 491 | |
| 492 | \newenvironment{seealso}[0]{ |
| 493 | \strong{See Also:}\par |
| 494 | % These should only be defined within the {seealso} environment: |
| 495 | \def\seemodule##1##2{\ref{module-##1}:\quad Module \module{##1}\quad (##2)} |
| 496 | \def\seetext##1{\par{##1}} |
| 497 | }{\par} |
| 498 | |
| 499 | |
| 500 | % Fix the theindex environment to add an entry to the Table of |
| 501 | % Contents; this is much nicer than just having to jump to the end of |
| 502 | % the book and flip around, especially with multiple indexes. |
| 503 | % |
| 504 | \let\OldTheindex=\theindex |
| 505 | \renewcommand{\theindex}{ |
| 506 | \cleardoublepage |
| 507 | \OldTheindex |
| 508 | \addcontentsline{toc}{chapter}{\indexname} |
| 509 | } |
| 510 | |
| 511 | % Use a similar trick to catch the end of the {abstract} environment, |
| 512 | % but here make sure the abstract is followed by a blank page if the |
| 513 | % 'openright' option is used. |
| 514 | % |
| 515 | \let\OldEndAbstract=\endabstract |
| 516 | \renewcommand{\endabstract}{ |
| 517 | \if@openright |
| 518 | \ifodd\value{page} |
| 519 | \typeout{Adding blank page after the abstract.} |
| 520 | \vfil\pagebreak |
| 521 | \fi |
| 522 | \fi |
| 523 | \OldEndAbstract |
| 524 | } |
| 525 | |
| 526 | % This wraps the \tableofcontents macro with all the magic to get the |
| 527 | % spacing right and have the right number of pages if the 'openright' |
| 528 | % option has been used. This eliminates a fair amount of crud in the |
| 529 | % individual document files. |
| 530 | % |
| 531 | \let\OldTableofcontents=\tableofcontents |
| 532 | \renewcommand{\tableofcontents}[0]{% |
| 533 | \setcounter{page}{1}% |
| 534 | \pagebreak% |
| 535 | \pagestyle{plain}% |
| 536 | {% |
| 537 | \parskip = 0mm% |
| 538 | \OldTableofcontents% |
| 539 | \if@openright% |
| 540 | \ifodd\value{page}% |
| 541 | \typeout{Adding blank page after the table of contents.}% |
| 542 | \pagebreak\hspace{0pt}% |
| 543 | \fi% |
| 544 | \fi% |
| 545 | }% |
| 546 | \cleardoublepage% |
| 547 | \pagenumbering{arabic}% |
| 548 | \@ifundefined{fancyhf}{}{\pagestyle{normal}}% |
| 549 | } |
| 550 | |
| 551 | % Allow the release number to be specified independently of the |
| 552 | % \date{}. This allows the date to reflect the document's date and |
| 553 | % release to specify the Python release that is documented. |
| 554 | % |
| 555 | \newcommand{\@release}{} |
| 556 | \newcommand{\version}{} |
| 557 | \newcommand{\releasename}{Release} |
| 558 | \newcommand{\release}[1]{% |
| 559 | \renewcommand{\@release}{\releasename\space\version}% |
| 560 | \renewcommand{\version}{#1}} |
| 561 | |
| 562 | % Allow specification of the author's address separately from the |
| 563 | % author's name. This can be used to format them differently, which |
| 564 | % is a good thing. |
| 565 | % |
| 566 | \newcommand{\@authoraddress}{} |
| 567 | \newcommand{\authoraddress}[1]{\renewcommand{\@authoraddress}{#1}} |
| 568 | |
| 569 | % Change the title page to look a bit better, and fit in with the |
| 570 | % fncychap ``Bjarne'' style a bit better. |
| 571 | % |
| 572 | \renewcommand{\maketitle}{% |
| 573 | \begin{titlepage}% |
| 574 | \let\footnotesize\small |
| 575 | \let\footnoterule\relax |
| 576 | \@ifundefined{ChTitleVar}{}{% |
| 577 | \mghrulefill{\RW}}% |
| 578 | \@ifundefined{pdfinfo}{}{ |
| 579 | \pdfinfo |
| 580 | author {\@author} |
| 581 | title {\@title} |
| 582 | } |
| 583 | \begin{flushright}% |
| 584 | {\rm\Huge\HeaderFamily \@title \par}% |
| 585 | {\em\LARGE\HeaderFamily \@release \par} |
| 586 | \vfill |
| 587 | {\LARGE\HeaderFamily \@author \par} |
| 588 | \vfill\vfill |
| 589 | {\large |
| 590 | \@date \par |
| 591 | \vskip 3em |
| 592 | \@authoraddress \par |
| 593 | }% |
| 594 | \end{flushright}%\par |
| 595 | \@thanks |
| 596 | \end{titlepage}% |
| 597 | \setcounter{footnote}{0}% |
| 598 | \let\thanks\relax\let\maketitle\relax |
| 599 | \gdef\@thanks{}\gdef\@author{}\gdef\@title{} |
| 600 | } |
| 601 | |
| 602 | % This sets up the fancy chapter headings that make the documents look |
| 603 | % at least a little better than the usual LaTeX output. |
| 604 | % |
| 605 | \@ifundefined{ChTitleVar}{}{ |
| 606 | \ChNameVar{\raggedleft\normalsize\HeaderFamily} |
| 607 | \ChNumVar{\raggedleft \bfseries\Large\HeaderFamily} |
| 608 | \ChTitleVar{\raggedleft \rm\Huge\HeaderFamily} |
| 609 | % This creates chapter heads without the leading \vspace*{}: |
| 610 | \def\@makechapterhead#1{% |
| 611 | {\parindent \z@ \raggedright \normalfont |
| 612 | \ifnum \c@secnumdepth >\m@ne |
| 613 | \DOCH |
| 614 | \fi |
| 615 | \interlinepenalty\@M |
| 616 | \DOTI{#1} |
| 617 | } |
| 618 | } |
| 619 | \typeout{Using fancy chapter headings.} |
| 620 | } |
| 621 | |
| 622 | % Tell TeX about pathological hyphenation cases: |
| 623 | \hyphenation{Base-HTTP-Re-quest-Hand-ler} |