comparison Doc/texinputs/python.sty @ 7585:2ef0aca96f2d legacy-trunk

Revise some of the PDF support to get at least preliminary outline support. Rewrite \seemodule (again) to allow an optional argument to support modules which include an underscore in the names. See example in comments.
author Fred Drake <fdrake@acm.org>
date Fri, 06 Mar 1998 21:25:17 +0000
parents cc7e126f009d
children 09440606aac5
comparison
equal deleted inserted replaced
7584:d2b5d9326f09 7585:2ef0aca96f2d
9 % The "fncychap" package is used to get the nice chapter headers. The 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 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! 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
15 14
16 % for PDF output, use maximal compression 15 % for PDF output, use maximal compression
17 \@ifundefined{pdfannotlink}{ 16 \@ifundefined{pdfannotlink}{
18 \let\LinkColor=\relax 17 \let\LinkColor=\relax
19 \let\NormalColor=\relax 18 \let\NormalColor=\relax
20 }{% 19 }{%
21 \input{pdfcolor} 20 \input{pdfcolor}
22 \let\LinkColor=\NavyBlue 21 \let\LinkColor=\NavyBlue
23 \let\NormalColor=\Black 22 \let\NormalColor=\Black
24 \pdfcompresslevel=9 23 \pdfcompresslevel=9
24 %
25 % This definition allows the entries in the page-view of the ToC to be
26 % active links. Some work, some don't.
27 %
25 \let\OldContentsline=\contentsline 28 \let\OldContentsline=\contentsline
26 \renewcommand{\contentsline}[3]{% 29 \renewcommand{\contentsline}[3]{%
27 \OldContentsline{#1}{% 30 \OldContentsline{#1}{%
28 \pdfannotlink attr{/Border [0 0 0]} goto name{page.#3}% 31 \pdfannotlink attr{/Border [0 0 0]} goto name{page.#3}%
29 \LinkColor#2\NormalColor% 32 \LinkColor#2\NormalColor%
30 \pdfendlink% 33 \pdfendlink%
31 }{#3}% 34 }{#3}%
35 }
36 \renewcommand{\thepage}{\roman{page}}
37 %
38 % This is supposed to build the "outline" view of the document; it seems
39 % quite fragile. The breakages are the same as in the ToC.
40 %
41 \AtEndDocument{
42 \InputIfFileExists{\jobname.bkm}{\pdfcatalog pagemode{/UseOutlines}}{}
32 } 43 }
33 \let\OldLabel=\label 44 \let\OldLabel=\label
34 \renewcommand{\label}[1]{% 45 \renewcommand{\label}[1]{%
35 \OldLabel{#1}% 46 \OldLabel{#1}%
36 {\pdfdest name{label.#1} fit}% 47 {\pdfdest name{label.#1} fit}%
42 % This is *heavily* based on the hyperref package. 53 % This is *heavily* based on the hyperref package.
43 % 54 %
44 \def\@begindvi{% 55 \def\@begindvi{%
45 \unvbox \@begindvibox 56 \unvbox \@begindvibox
46 \@hyperfixhead 57 \@hyperfixhead
47 \global\let \@begindvi \@hyperfixhead 58 }
48 } 59 \def\hyperpageanchor{\pdfdest name{page.\thepage}}
49 \def\hyperpageanchor{%
50 \hyper@anchorstart{page.\thepage}\hyper@anchorend
51 }
52 \let\HYPERPAGEANCHOR\hyperpageanchor 60 \let\HYPERPAGEANCHOR\hyperpageanchor
53 \def\@hyperfixhead{% 61 \def\@hyperfixhead{%
54 \let\H@old@thehead\@thehead 62 \let\H@old@thehead\@thehead
55 \gdef\@foo{\pdfdest name{page.\thepage} fit}% 63 \gdef\@foo{\pdfdest name{page.\thepage} fit}%
56 \expandafter\ifx\expandafter\@empty\H@old@thehead 64 \expandafter\ifx\expandafter\@empty\H@old@thehead
492 % Cross-referencing (AMK) 500 % Cross-referencing (AMK)
493 % Sample usage: 501 % Sample usage:
494 % \begin{seealso} 502 % \begin{seealso}
495 % \seemodule{rand}{Uniform random number generator}; % Module xref 503 % \seemodule{rand}{Uniform random number generator}; % Module xref
496 % \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book 504 % \seetext{\emph{Encyclopedia Britannica}}. % Ref to a book
505 %
506 % % A funky case: module name contains '_'; have to supply an optional key
507 % \seemodule[copyreg]{copy_reg}{pickle interface constructor registration}
508 %
497 % \end{seealso} 509 % \end{seealso}
498 510
511 \newif\if@keyedmodule\@keyedmodulefalse
512 \newcommand{\@modulebadkey}{{--just-some-junk--}}
513
514 \@ifundefined{pdfannotlink}{%
515 \newcommand{\seemodule}[3][\@modulebadkey]{%
516 \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi%
517 \ref{module-\@modulekey}:\quad %
518 Module \module{#2}%
519 \quad (#3)%
520 }
521 }{\newcommand{\seemodule}[3][\@modulebadkey]{%
522 \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi%
523 \ref{module-\@modulekey}:\quad %
524 {\pdfannotlink attr{/Border [0 0 0]} goto name{label.module-\@modulekey}%
525 \LinkColor Module \module{#2} \NormalColor%
526 \pdfendlink%
527 }%
528 \quad (#3)%
529 }
530 }
499 \newenvironment{seealso}[0]{ 531 \newenvironment{seealso}[0]{
500 \strong{See Also:}\par 532 \strong{See Also:}\par
501 % These should only be defined within the {seealso} environment: 533 % These should only be defined within the {seealso} environment:
502 \def\seemodule##1##2{\ref{module-##1}:\quad Module \module{##1}\quad (##2)} 534 %\def\see@module##1##2{\ref{module-##1}:\quad Module \module{##1}\quad (##2)}
535 % \def\@seemodule[##1]##2##3{%
536 % \ref{module-##2}:\quad %
537 % \@ifundefined{pdfannotlink}{%
538 % Module \module{##2}%
539 % }{\if@keyedmodule\@keyedmodulefalse\fi%
540 % {\pdfannotlink attr{/Border [0 0 0]} goto name{module.##1}%
541 % \LinkColor Module \module{##2}\NormalColor\pdfendlink}%
542 % }%
543 % \quad (##3)%
544 % }
545 % \def\seemodule{%
546 % \@ifnextchar [\@seemodule{\@keyedmoduletrue \@seemodule[]}%
547 % }
503 \def\seetext##1{\par{##1}} 548 \def\seetext##1{\par{##1}}
504 }{\par} 549 }{\par}
505 550
506 551
507 % Fix the theindex environment to add an entry to the Table of 552 % Fix the theindex environment to add an entry to the Table of