|
27 | 27 | \let\NormalColor=\Black |
28 | 28 | \pdfcompresslevel=9 |
29 | 29 | % |
| 30 | + % Pad the number with '0' to 3 digits wide so no page name is a prefix |
| 31 | + % of any other. |
| 32 | + % |
| 33 | + \def\py@targetno#1{\ifnum#1<100 0\fi\ifnum#1<10 0\fi#1} |
| 34 | + \def\py@pageno{\py@targetno\thepage} |
| 35 | + % |
30 | 36 | % This definition allows the entries in the page-view of the ToC to be |
31 | 37 | % active links. Some work, some don't. |
32 | 38 | % |
33 | 39 | \let\OldContentsline=\contentsline |
| 40 | + % Compute the padded page number separately since we end up with a pair of |
| 41 | + % \relax tokens; this gets the right string computed and works. |
34 | 42 | \renewcommand{\contentsline}[3]{% |
| 43 | + \def\my@pageno{\py@targetno{#3}}% |
35 | 44 | \OldContentsline{#1}{% |
36 | | - \pdfannotlink attr{/Border [0 0 0]} goto name{page.#3}% |
| 45 | + \pdfannotlink attr{/Border [0 0 0]} goto name{page\my@pageno}% |
37 | 46 | \LinkColor#2\NormalColor% |
38 | 47 | \pdfendlink% |
39 | 48 | }{#3}% |
|
45 | 54 | \AtEndDocument{ |
46 | 55 | \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{} |
47 | 56 | } |
| 57 | + \newcommand{\py@target}[1]{% |
| 58 | + \if@doing@page@targets% |
| 59 | + {\pdfdest name{#1} fit}% |
| 60 | + \fi% |
| 61 | + } |
48 | 62 | \let\OldLabel=\label |
49 | 63 | \renewcommand{\label}[1]{% |
50 | 64 | \OldLabel{#1}% |
51 | | - {\pdfdest name{label.#1} fit}% |
| 65 | + \py@target{label-#1}% |
52 | 66 | } |
53 | | - % This stuff adds a page.# destination to every PDF page, where # has |
| 67 | + % This stuff adds a page# destination to every PDF page, where # has |
54 | 68 | % the same formatting as the displayed page number. This doesn't really |
55 | 69 | % help with the frontmatter, but does fine with the body. |
56 | 70 | % |
|
62 | 76 | } |
63 | 77 | \def\@hyperfixhead{% |
64 | 78 | \let\H@old@thehead\@thehead |
65 | | - \gdef\@foo{\if@doing@page@targets\pdfdest name{page.\thepage x} fit\fi}% |
| 79 | + \global\def\@foo{\py@target{page\py@pageno}}% |
66 | 80 | \expandafter\ifx\expandafter\@empty\H@old@thehead |
67 | 81 | \def\H@old@thehead{\hfil}\fi |
68 | 82 | \def\@thehead{\@foo\relax\H@old@thehead}% |
|
191 | 205 | % Augment the sectioning commands used to get our own font family in place, |
192 | 206 | % and reset some internal data items: |
193 | 207 | \renewcommand{\section}{\reset@python% |
194 | | - \@startsection {section}{1}{\z@}% |
195 | | - {-3.5ex \@plus -1ex \@minus -.2ex}% |
196 | | - {2.3ex \@plus.2ex}% |
197 | | - {\reset@font\Large\HeaderFamily}} |
| 208 | + \@startsection{section}{1}{\z@}% |
| 209 | + {-3.5ex \@plus -1ex \@minus -.2ex}% |
| 210 | + {2.3ex \@plus.2ex}% |
| 211 | + {\reset@font\Large\HeaderFamily}} |
198 | 212 | \renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}% |
199 | | - {-3.25ex\@plus -1ex \@minus -.2ex}% |
200 | | - {1.5ex \@plus .2ex}% |
201 | | - {\reset@font\large\HeaderFamily}} |
| 213 | + {-3.25ex\@plus -1ex \@minus -.2ex}% |
| 214 | + {1.5ex \@plus .2ex}% |
| 215 | + {\reset@font\large\HeaderFamily}} |
202 | 216 | \renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{\z@}% |
203 | | - {-3.25ex\@plus -1ex \@minus -.2ex}% |
204 | | - {1.5ex \@plus .2ex}% |
205 | | - {\reset@font\normalsize\HeaderFamily}} |
| 217 | + {-3.25ex\@plus -1ex \@minus -.2ex}% |
| 218 | + {1.5ex \@plus .2ex}% |
| 219 | + {\reset@font\normalsize\HeaderFamily}} |
206 | 220 | \renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}% |
207 | | - {3.25ex \@plus1ex \@minus.2ex}% |
208 | | - {-1em}% |
209 | | - {\reset@font\normalsize\HeaderFamily}} |
| 221 | + {3.25ex \@plus1ex \@minus.2ex}% |
| 222 | + {-1em}% |
| 223 | + {\reset@font\normalsize\HeaderFamily}} |
210 | 224 | \renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\parindent}% |
211 | 225 | {3.25ex \@plus1ex \@minus .2ex}% |
212 | 226 | {-1em}% |
213 | | - {\reset@font\normalsize\HeaderFamily}} |
| 227 | + {\reset@font\normalsize\HeaderFamily}} |
214 | 228 |
|
215 | 229 |
|
216 | 230 | % Underscore hack (only act like subscript operator if in math mode) |
|
518 | 532 | % Use this def/redef approach for \url{} since hyperref defined this already, |
519 | 533 | % but only if we actually used hyperref: |
520 | 534 | \@ifundefined{pdfannotlink}{ |
521 | | - \newcommand{\pythonurl}[1]{\mbox{\small\textsf{#1}}} |
| 535 | + \newcommand{\py@url}[1]{\mbox{\small\textsf{#1}}} |
522 | 536 | }{ |
523 | | - \newcommand{\pythonurl}[1]{{% |
| 537 | + \newcommand{\py@url}[1]{{% |
524 | 538 | \pdfannotlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% |
525 | 539 | \LinkColor% color of the link text |
526 | 540 | {\small\textsf{#1}}% |
527 | 541 | \NormalColor% Turn it back off; these are declarative |
528 | 542 | \pdfendlink}% and don't appear bound to the current |
529 | 543 | }% formatting "box". |
530 | 544 | } |
531 | | -\let\url=\pythonurl |
| 545 | +\let\url=\py@url |
532 | 546 | \newcommand{\email}[1]{{\small\textsf{#1}}} |
533 | 547 | \newcommand{\newsgroup}[1]{{\small\textsf{#1}}} |
534 | 548 |
|
|
643 | 657 | }{\newcommand{\seemodule}[3][\@modulebadkey]{% |
644 | 658 | \ifx\@modulebadkey#1\def\@modulekey{#2}\else\def\@modulekey{#1}\fi% |
645 | 659 | \ref{module-\@modulekey}:\quad % |
646 | | - {\pdfannotlink attr{/Border [0 0 0]} goto name{label.module-\@modulekey}% |
| 660 | + {\pdfannotlink attr{/Border [0 0 0]} goto name{label-module-\@modulekey}% |
647 | 661 | \LinkColor Module \module{#2} \NormalColor% |
648 | 662 | \pdfendlink% |
649 | 663 | }% |
|
0 commit comments