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