comparison Doc/texinputs/python.sty @ 7597:39b84a3dceaa legacy-trunk

Never, NEVER try to recover a screwed up file by carving a chunk out of an RCS ,v archive! And certainly don't check it back in without testing it. ;-( "@" becomes "@@" everywhere. This one *is* tested!
author Fred Drake <fdrake@acm.org>
date Sat, 07 Mar 1998 05:29:15 +0000
parents 09440606aac5
children 068a6942fe1a
comparison
equal deleted inserted replaced
7596:aab76220505e 7597:39b84a3dceaa
11 % it. You'd also end up with a mixed page style; uglier than stock LaTeX! 11 % it. You'd also end up with a mixed page style; uglier than stock LaTeX!
12 % 12 %
13 \RequirePackage[Bjarne]{fncychap}\typeout{Using fancy chapter headings.} 13 \RequirePackage[Bjarne]{fncychap}\typeout{Using fancy chapter headings.}
14 14
15 % for PDF output, use maximal compression 15 % for PDF output, use maximal compression
16 \@@ifundefined{pdfannotlink}{ 16 \@ifundefined{pdfannotlink}{
17 \let\LinkColor=\relax 17 \let\LinkColor=\relax
18 \let\NormalColor=\relax 18 \let\NormalColor=\relax
19 }{% 19 }{%
20 \input{pdfcolor} 20 \input{pdfcolor}
21 \let\LinkColor=\NavyBlue 21 \let\LinkColor=\NavyBlue
50 % the same formatting as the displayed page number. This doesn't really 50 % the same formatting as the displayed page number. This doesn't really
51 % help with the frontmatter, but does fine with the body. 51 % help with the frontmatter, but does fine with the body.
52 % 52 %
53 % This is *heavily* based on the hyperref package. 53 % This is *heavily* based on the hyperref package.
54 % 54 %
55 \def\@@begindvi{% 55 \def\@begindvi{%
56 \unvbox \@@begindvibox 56 \unvbox \@begindvibox
57 \@@hyperfixhead 57 \@hyperfixhead
58 } 58 }
59 \def\hyperpageanchor{\pdfdest name{page.\thepage}} 59 \def\hyperpageanchor{\pdfdest name{page.\thepage}}
60 \let\HYPERPAGEANCHOR\hyperpageanchor 60 \let\HYPERPAGEANCHOR\hyperpageanchor
61 \def\@@hyperfixhead{% 61 \def\@hyperfixhead{%
62 \let\H@@old@@thehead\@@thehead 62 \let\H@old@thehead\@thehead
63 \gdef\@@foo{\pdfdest name{page.\thepage} fit}% 63 \gdef\@foo{\pdfdest name{page.\thepage} fit}%
64 \expandafter\ifx\expandafter\@@empty\H@@old@@thehead 64 \expandafter\ifx\expandafter\@empty\H@old@thehead
65 \def\H@@old@@thehead{\hfil}\fi 65 \def\H@old@thehead{\hfil}\fi
66 \def\@@thehead{\@@foo\relax\H@@old@@thehead}% 66 \def\@thehead{\@foo\relax\H@old@thehead}%
67 } 67 }
68 } 68 }
69 69
70 % Increase printable page size (copied from fullpage.sty) 70 % Increase printable page size (copied from fullpage.sty)
71 \topmargin 0pt 71 \topmargin 0pt
72 \advance \topmargin by -\headheight 72 \advance \topmargin by -\headheight
73 \advance \topmargin by -\headsep 73 \advance \topmargin by -\headsep
74 74
75 % attempt to work a little better for A4 users 75 % attempt to work a little better for A4 users
76 \@@ifundefined{paperheight}{ 76 \@ifundefined{paperheight}{
77 \textheight 9in 77 \textheight 9in
78 }{ 78 }{
79 \textheight \paperheight 79 \textheight \paperheight
80 \advance\textheight by -2in 80 \advance\textheight by -2in
81 } 81 }
82 82
83 \oddsidemargin 0pt 83 \oddsidemargin 0pt
84 \evensidemargin \oddsidemargin 84 \evensidemargin \oddsidemargin
85 \marginparwidth 0.5in 85 \marginparwidth 0.5in
86 86
87 \@@ifundefined{paperwidth}{ 87 \@ifundefined{paperwidth}{
88 \textwidth 6.5in 88 \textwidth 6.5in
89 }{ 89 }{
90 \textwidth \paperwidth 90 \textwidth \paperwidth
91 \advance\textwidth by -2in 91 \advance\textwidth by -2in
92 } 92 }
105 105
106 % Use this to set the font family for headers and other decor: 106 % Use this to set the font family for headers and other decor:
107 \newcommand{\HeaderFamily}{\sffamily} 107 \newcommand{\HeaderFamily}{\sffamily}
108 108
109 % Redefine the 'normal' header/footer style when using "fancyhdr" package: 109 % Redefine the 'normal' header/footer style when using "fancyhdr" package:
110 \@@ifundefined{fancyhf}{}{ 110 \@ifundefined{fancyhf}{}{
111 % Use \pagestyle{normal} as the primary pagestyle for text. 111 % Use \pagestyle{normal} as the primary pagestyle for text.
112 \fancypagestyle{normal}{ 112 \fancypagestyle{normal}{
113 \fancyhf{} 113 \fancyhf{}
114 \fancyfoot[LE,RO]{{\HeaderFamily\thepage}} 114 \fancyfoot[LE,RO]{{\HeaderFamily\thepage}}
115 \fancyfoot[LO]{{\HeaderFamily\nouppercase{\rightmark}}} 115 \fancyfoot[LO]{{\HeaderFamily\nouppercase{\rightmark}}}
127 \renewcommand{\footrulewidth}{0.4pt} 127 \renewcommand{\footrulewidth}{0.4pt}
128 } 128 }
129 % Redefine \cleardoublepage so that the blank page between chapters 129 % Redefine \cleardoublepage so that the blank page between chapters
130 % gets the plain style and not the fancy style. This is described 130 % gets the plain style and not the fancy style. This is described
131 % in the documentation for the fancyhdr package by Piet von Oostrum. 131 % in the documentation for the fancyhdr package by Piet von Oostrum.
132 \@@ifundefined{chapter}{}{ 132 \@ifundefined{chapter}{}{
133 \renewcommand{\cleardoublepage}{ 133 \renewcommand{\cleardoublepage}{
134 \clearpage\if@@openright \ifodd\c@@page\else 134 \clearpage\if@openright \ifodd\c@page\else
135 \hbox{} 135 \hbox{}
136 \thispagestyle{plain} 136 \thispagestyle{plain}
137 \newpage 137 \newpage
138 \if@@twocolumn\hbox{}\newpage\fi\fi\fi 138 \if@twocolumn\hbox{}\newpage\fi\fi\fi
139 } 139 }
140 } 140 }
141 } 141 }
142 142
143 % old code font selections: 143 % old code font selections:
179 \end{minipage}% 179 \end{minipage}%
180 \endgroup% 180 \endgroup%
181 } 181 }
182 182
183 % Augment the sectioning commands used to get our own font family in place: 183 % Augment the sectioning commands used to get our own font family in place:
184 \renewcommand{\section}{\@@startsection {section}{1}{\z@@}% 184 \renewcommand{\section}{\@startsection {section}{1}{\z@}%
185 {-3.5ex \@@plus -1ex \@@minus -.2ex}% 185 {-3.5ex \@plus -1ex \@minus -.2ex}%
186 {2.3ex \@@plus.2ex}% 186 {2.3ex \@plus.2ex}%
187 {\reset@@font\Large\HeaderFamily}} 187 {\reset@font\Large\HeaderFamily}}
188 \renewcommand{\subsection}{\@@startsection{subsection}{2}{\z@@}% 188 \renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
189 {-3.25ex\@@plus -1ex \@@minus -.2ex}% 189 {-3.25ex\@plus -1ex \@minus -.2ex}%
190 {1.5ex \@@plus .2ex}% 190 {1.5ex \@plus .2ex}%
191 {\reset@@font\large\HeaderFamily}} 191 {\reset@font\large\HeaderFamily}}
192 \renewcommand{\subsubsection}{\@@startsection{subsubsection}{3}{\z@@}% 192 \renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}%
193 {-3.25ex\@@plus -1ex \@@minus -.2ex}% 193 {-3.25ex\@plus -1ex \@minus -.2ex}%
194 {1.5ex \@@plus .2ex}% 194 {1.5ex \@plus .2ex}%
195 {\reset@@font\normalsize\HeaderFamily}} 195 {\reset@font\normalsize\HeaderFamily}}
196 \renewcommand{\paragraph}{\@@startsection{paragraph}{4}{\z@@}% 196 \renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}%
197 {3.25ex \@@plus1ex \@@minus.2ex}% 197 {3.25ex \@plus1ex \@minus.2ex}%
198 {-1em}% 198 {-1em}%
199 {\reset@@font\normalsize\HeaderFamily}} 199 {\reset@font\normalsize\HeaderFamily}}
200 \renewcommand{\subparagraph}{\@@startsection{subparagraph}{5}{\parindent}% 200 \renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}%
201 {3.25ex \@@plus1ex \@@minus .2ex}% 201 {3.25ex \@plus1ex \@minus .2ex}%
202 {-1em}% 202 {-1em}%
203 {\reset@@font\normalsize\HeaderFamily}} 203 {\reset@font\normalsize\HeaderFamily}}
204 204
205 205
206 % Underscore hack (only act like subscript operator if in math mode) 206 % Underscore hack (only act like subscript operator if in math mode)
207 % 207 %
208 % The following is due to Mark Wooding (the old version didn't work with 208 % The following is due to Mark Wooding (the old version didn't work with
253 \index{#4!#1 #2 #3} 253 \index{#4!#1 #2 #3}
254 } 254 }
255 255
256 % Command to generate a reference to a function, statement, keyword, 256 % Command to generate a reference to a function, statement, keyword,
257 % operator. 257 % operator.
258 \newcommand{\stindex}[1]{\indexii{statement}{#1@@{\idxcode{#1}}}} 258 \newcommand{\stindex}[1]{\indexii{statement}{#1@{\idxcode{#1}}}}
259 \newcommand{\opindex}[1]{\indexii{operator}{#1@@{\idxcode{#1}}}} 259 \newcommand{\opindex}[1]{\indexii{operator}{#1@{\idxcode{#1}}}}
260 \newcommand{\exindex}[1]{\indexii{exception}{#1@@{\idxcode{#1}}}} 260 \newcommand{\exindex}[1]{\indexii{exception}{#1@{\idxcode{#1}}}}
261 \newcommand{\obindex}[1]{\indexii{object}{#1}} 261 \newcommand{\obindex}[1]{\indexii{object}{#1}}
262 \newcommand{\bifuncindex}[1]{\index{#1@@{\idxcode{#1()}} (built-in function)}} 262 \newcommand{\bifuncindex}[1]{\index{#1@{\idxcode{#1()}} (built-in function)}}
263 263
264 % Add an index entry for a module 264 % Add an index entry for a module
265 \newcommand{\refmodule}[2]{\index{#1@@{\idxcode{#1}} (#2module)}} 265 \newcommand{\refmodule}[2]{\index{#1@{\idxcode{#1}} (#2module)}}
266 \newcommand{\refmodindex}[1]{\refmodule{#1}{}} 266 \newcommand{\refmodindex}[1]{\refmodule{#1}{}}
267 \newcommand{\refbimodindex}[1]{\refmodule{#1}{built-in }} 267 \newcommand{\refbimodindex}[1]{\refmodule{#1}{built-in }}
268 \newcommand{\refexmodindex}[1]{\refmodule{#1}{extension }} 268 \newcommand{\refexmodindex}[1]{\refmodule{#1}{extension }}
269 \newcommand{\refstmodindex}[1]{\refmodule{#1}{standard }} 269 \newcommand{\refstmodindex}[1]{\refmodule{#1}{standard }}
270 270
271 % support for the module index 271 % support for the module index
272 \if@@usemoduleindex 272 \if@usemoduleindex
273 \newwrite\modindexfile 273 \newwrite\modindexfile
274 \openout\modindexfile=mod\jobname.idx 274 \openout\modindexfile=mod\jobname.idx
275 \fi 275 \fi
276 276
277 % Add the defining entry for a module 277 % Add the defining entry for a module
278 \newcommand{\defmodindex}[2]{% 278 \newcommand{\defmodindex}[2]{%
279 \index{#1@@{\idxcode{#1}} (#2module)|textbf}% 279 \index{#1@{\idxcode{#1}} (#2module)|textbf}%
280 \setindexsubitem{(in module #1)}% 280 \setindexsubitem{(in module #1)}%
281 \if@@usemoduleindex% 281 \if@usemoduleindex%
282 \write\modindexfile{#1 \thepage}% 282 \write\modindexfile{#1 \thepage}%
283 \fi} 283 \fi}
284 284
285 % built-in & Python modules in the main distribution 285 % built-in & Python modules in the main distribution
286 \newcommand{\bimodindex}[1]{\defmodindex{#1}{built-in }} 286 \newcommand{\bimodindex}[1]{\defmodindex{#1}{built-in }}
289 % Python & extension modules outside the main distribution 289 % Python & extension modules outside the main distribution
290 \newcommand{\modindex}[1]{\defmodindex{#1}{}} 290 \newcommand{\modindex}[1]{\defmodindex{#1}{}}
291 \newcommand{\exmodindex}[1]{\defmodindex{#1}{extension }} 291 \newcommand{\exmodindex}[1]{\defmodindex{#1}{extension }}
292 292
293 % Additional string for an index entry 293 % Additional string for an index entry
294 \newcommand{\index@@subitem}{} 294 \newcommand{\index@subitem}{}
295 \newcommand{\setindexsubitem}[1]{\renewcommand{\index@@subitem}{#1}} 295 \newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}}
296 \newcommand{\ttindex}[1]{\index{#1@@{\idxcode{#1}} \index@@subitem}} 296 \newcommand{\ttindex}[1]{\index{#1@{\idxcode{#1}} \index@subitem}}
297 297
298 298
299 % {fulllineitems} is used in one place in libregex.tex, but is really for 299 % {fulllineitems} is used in one place in libregex.tex, but is really for
300 % internal use in this file. 300 % internal use in this file.
301 % 301 %
312 % ... description ... 312 % ... description ...
313 % \end{cfuncdesc} 313 % \end{cfuncdesc}
314 \newenvironment{cfuncdesc}[3]{% 314 \newenvironment{cfuncdesc}[3]{%
315 \begin{fulllineitems}% 315 \begin{fulllineitems}%
316 \item[\code{#1 \bfcode{#2}(\varvars{#3})}]% 316 \item[\code{#1 \bfcode{#2}(\varvars{#3})}]%
317 \index{#2@@{\idxcode{#2()}}}% 317 \index{#2@{\idxcode{#2()}}}%
318 }{\end{fulllineitems}} 318 }{\end{fulllineitems}}
319 319
320 \newenvironment{cvardesc}[2]{% 320 \newenvironment{cvardesc}[2]{%
321 \begin{fulllineitems}% 321 \begin{fulllineitems}%
322 \item[\code{#1 \bfcode{#2}}]% 322 \item[\code{#1 \bfcode{#2}}]%
323 \index{#2@@{\idxcode{#2}}}% 323 \index{#2@{\idxcode{#2}}}%
324 }{\end{fulllineitems}} 324 }{\end{fulllineitems}}
325 325
326 \newenvironment{ctypedesc}[1]{% 326 \newenvironment{ctypedesc}[1]{%
327 \begin{fulllineitems}% 327 \begin{fulllineitems}%
328 \item[\bfcode{#1}]\ttindex{#1} 328 \item[\bfcode{#1}]\ttindex{#1}
387 \newcommand{\C}{C} 387 \newcommand{\C}{C}
388 \newcommand{\EOF}{{\sc eof}} 388 \newcommand{\EOF}{{\sc eof}}
389 \newcommand{\NULL}{\code{NULL}} 389 \newcommand{\NULL}{\code{NULL}}
390 390
391 % code is the most difficult one... 391 % code is the most difficult one...
392 \newcommand{\code}[1]{{\@@vobeyspaces\@@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}% 392 \newcommand{\code}[1]{{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}%
393 \mbox{\codefont{#1}}}} 393 \mbox{\codefont{#1}}}}
394 394
395 \newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font 395 \newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font
396 \newcommand{\kbd}[1]{\mbox{\tt #1}} 396 \newcommand{\kbd}[1]{\mbox{\tt #1}}
397 \newcommand{\key}[1]{\mbox{\tt #1}} 397 \newcommand{\key}[1]{\mbox{\tt #1}}
406 % let's experiment with a new font: 406 % let's experiment with a new font:
407 \newcommand{\file}[1]{\mbox{`\small\textsf{#1}'}} 407 \newcommand{\file}[1]{\mbox{`\small\textsf{#1}'}}
408 408
409 % Use this def/redef approach for \url{} since hyperref defined this already, 409 % Use this def/redef approach for \url{} since hyperref defined this already,
410 % but only if we actually used hyperref: 410 % but only if we actually used hyperref:
411 \@@ifundefined{pdfannotlink}{% 411 \@ifundefined{pdfannotlink}{%
412 \newcommand{\pythonurl}[1]{\mbox{\small\textsf{#1}}}% 412 \newcommand{\pythonurl}[1]{\mbox{\small\textsf{#1}}}%
413 }{ 413 }{
414 \newcommand{\pythonurl}[1]{{% 414 \newcommand{\pythonurl}[1]{{%
415 \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% 415 \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}%
416 \LinkColor% color of the link text 416 \LinkColor% color of the link text
489 \end{tabular}% 489 \end{tabular}%
490 \end{center}% 490 \end{center}%
491 } 491 }
492 492
493 \newcommand{\itemnewline}[1]{% 493 \newcommand{\itemnewline}[1]{%
494 \@@tempdima\linewidth% 494 \@tempdima\linewidth%
495 \advance\@@tempdima \leftmargin\makebox[\@@tempdima][l]{#1}% 495 \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}%
496 } 496 }
497 497
498 \newcommand{\sectcode}[1]{{\sectcodefont{#1}}} 498 \newcommand{\sectcode}[1]{{\sectcodefont{#1}}}
499 499
500 % Cross-referencing (AMK) 500 % Cross-referencing (AMK)
506 % % A funky case: module name contains '_'; have to supply an optional key 506 % % A funky case: module name contains '_'; have to supply an optional key
507 % \seemodule[copyreg]{copy_reg}{pickle interface constructor registration} 507 % \seemodule[copyreg]{copy_reg}{pickle interface constructor registration}
508 % 508 %
509 % \end{seealso} 509 % \end{seealso}
510 510
511 \newif\if@@keyedmodule\@@keyedmodulefalse 511 \newif\if@keyedmodule\@keyedmodulefalse
512 \newcommand{\@@modulebadkey}{{--just-some-junk--}} 512 \newcommand{\@modulebadkey}{{--just-some-junk--}}
513 513
514 \@@ifundefined{pdfannotlink}{% 514 \@ifundefined{pdfannotlink}{%
515 \newcommand{\seemodule}[3][\@@modulebadkey]{% 515 \newcommand{\seemodule}[3][\@modulebadkey]{%
516 \ifx\@@modulebadkey#1\def\@@modulekey{#2}\else\def\@@modulekey{#1}\fi% 516 \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi%
517 \ref{module-\@@modulekey}:\quad % 517 \ref{module-\@modulekey}:\quad %
518 Module \module{#2}% 518 Module \module{#2}%
519 \quad (#3)% 519 \quad (#3)%
520 } 520 }
521 }{\newcommand{\seemodule}[3][\@@modulebadkey]{% 521 }{\newcommand{\seemodule}[3][\@modulebadkey]{%
522 \ifx\@@modulebadkey#1\def\@@modulekey{#2}\else\def\@@modulekey{#1}\fi% 522 \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi%
523 \ref{module-\@@modulekey}:\quad % 523 \ref{module-\@modulekey}:\quad %
524 {\pdfannotlink attr{/Border [0 0 0]} goto name{label.module-\@@modulekey}% 524 {\pdfannotlink attr{/Border [0 0 0]} goto name{label.module-\@modulekey}%
525 \LinkColor Module \module{#2} \NormalColor% 525 \LinkColor Module \module{#2} \NormalColor%
526 \pdfendlink% 526 \pdfendlink%
527 }% 527 }%
528 \quad (#3)% 528 \quad (#3)%
529 } 529 }
547 547
548 % Allow the release number to be specified independently of the 548 % Allow the release number to be specified independently of the
549 % \date{}. This allows the date to reflect the document's date and 549 % \date{}. This allows the date to reflect the document's date and
550 % release to specify the Python release that is documented. 550 % release to specify the Python release that is documented.
551 % 551 %
552 \newcommand{\@@release}{} 552 \newcommand{\@release}{}
553 \newcommand{\version}{} 553 \newcommand{\version}{}
554 \newcommand{\releasename}{Release} 554 \newcommand{\releasename}{Release}
555 \newcommand{\release}[1]{% 555 \newcommand{\release}[1]{%
556 \renewcommand{\@@release}{\releasename\space\version}% 556 \renewcommand{\@release}{\releasename\space\version}%
557 \renewcommand{\version}{#1}} 557 \renewcommand{\version}{#1}}
558 558
559 % Allow specification of the author's address separately from the 559 % Allow specification of the author's address separately from the
560 % author's name. This can be used to format them differently, which 560 % author's name. This can be used to format them differently, which
561 % is a good thing. 561 % is a good thing.
562 % 562 %
563 \newcommand{\@@authoraddress}{} 563 \newcommand{\@authoraddress}{}
564 \newcommand{\authoraddress}[1]{\renewcommand{\@@authoraddress}{#1}} 564 \newcommand{\authoraddress}[1]{\renewcommand{\@authoraddress}{#1}}
565 565
566 % This sets up the fancy chapter headings that make the documents look 566 % This sets up the fancy chapter headings that make the documents look
567 % at least a little better than the usual LaTeX output. 567 % at least a little better than the usual LaTeX output.
568 % 568 %
569 \@@ifundefined{ChTitleVar}{}{ 569 \@ifundefined{ChTitleVar}{}{
570 \ChNameVar{\raggedleft\normalsize\HeaderFamily} 570 \ChNameVar{\raggedleft\normalsize\HeaderFamily}
571 \ChNumVar{\raggedleft \bfseries\Large\HeaderFamily} 571 \ChNumVar{\raggedleft \bfseries\Large\HeaderFamily}
572 \ChTitleVar{\raggedleft \rm\Huge\HeaderFamily} 572 \ChTitleVar{\raggedleft \rm\Huge\HeaderFamily}
573 % This creates chapter heads without the leading \vspace*{}: 573 % This creates chapter heads without the leading \vspace*{}:
574 \def\@@makechapterhead#1{% 574 \def\@makechapterhead#1{%
575 {\parindent \z@@ \raggedright \normalfont 575 {\parindent \z@ \raggedright \normalfont
576 \ifnum \c@@secnumdepth >\m@@ne 576 \ifnum \c@secnumdepth >\m@ne
577 \DOCH 577 \DOCH
578 \fi 578 \fi
579 \interlinepenalty\@@M 579 \interlinepenalty\@M
580 \DOTI{#1} 580 \DOTI{#1}
581 } 581 }
582 } 582 }
583 } 583 }
584 584