Mercurial > cpython-lru_cache-weakref
comparison Doc/texinputs/python.sty @ 34064:cec31edea414 legacy-trunk
- fix up internal hyperlink generation in PDF formatting so that links at
the beginning of a paragraph do not generate errors; this affected
things like \refmodule when it came first in a paragraph
- clean up the .sty file to separate out the treatment of the start
of a new paragraph
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Wed, 01 Dec 2004 06:30:31 +0000 |
| parents | 6b743cbc4171 |
| children | 0349257e1ed5 |
comparison
equal
deleted
inserted
replaced
| 34062:da967fb7a7fb | 34064:cec31edea414 |
|---|---|
| 17 % These packages can be used to add marginal annotations which indicate | 17 % These packages can be used to add marginal annotations which indicate |
| 18 % index entries and labels; useful for reviewing this messy documentation! | 18 % index entries and labels; useful for reviewing this messy documentation! |
| 19 % | 19 % |
| 20 %\RequirePackage{showkeys} | 20 %\RequirePackage{showkeys} |
| 21 %\RequirePackage{showidx} | 21 %\RequirePackage{showidx} |
| 22 | |
| 23 % If we ever want to indent paragraphs, this needs to be changed. | |
| 24 % This is used inside the macros defined here instead of coding | |
| 25 % \noindent directly. | |
| 26 \let\py@parindent=\noindent | |
| 22 | 27 |
| 23 % for PDF output, use maximal compression & a lot of other stuff | 28 % for PDF output, use maximal compression & a lot of other stuff |
| 24 % (test for PDF recommended by Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov>) | 29 % (test for PDF recommended by Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov>) |
| 25 % | 30 % |
| 26 \newif\ifpy@doing@page@targets | 31 \newif\ifpy@doing@page@targets |
| 54 % | 59 % |
| 55 \@ifundefined{pdfstartlink}{ | 60 \@ifundefined{pdfstartlink}{ |
| 56 \let\pdfstartlink=\pdfannotlink | 61 \let\pdfstartlink=\pdfannotlink |
| 57 }{} | 62 }{} |
| 58 % | 63 % |
| 64 % The \py@parindent here is a hack -- we're forcing pdfTeX into | |
| 65 % horizontal mode since \pdfstartlink requires that. | |
| 66 \def\py@pdfstartlink{% | |
| 67 \ifvmode\py@parindent\fi% | |
| 68 \pdfstartlink% | |
| 69 } | |
| 70 % | |
| 59 % Macro that takes two args: the name to link to and the content of | 71 % Macro that takes two args: the name to link to and the content of |
| 60 % the link. This takes care of the PDF magic, getting the colors | 72 % the link. This takes care of the PDF magic, getting the colors |
| 61 % the same for each link, and avoids having lots of garbage all over | 73 % the same for each link, and avoids having lots of garbage all over |
| 62 % this style file. | 74 % this style file. |
| 63 \newcommand{\py@linkToName}[2]{% | 75 \newcommand{\py@linkToName}[2]{% |
| 64 \pdfstartlink attr{/Border [0 0 0]} goto name{#1}% | 76 \py@pdfstartlink attr{/Border [0 0 0]} goto name{#1}% |
| 65 \py@LinkColor#2\py@NormalColor% | 77 \py@LinkColor#2\py@NormalColor% |
| 66 \pdfendlink% | 78 \pdfendlink% |
| 67 } | 79 } |
| 68 % Compute the padded page number separately since we end up with a pair of | 80 % Compute the padded page number separately since we end up with a pair of |
| 69 % \relax tokens; this gets the right string computed and works. | 81 % \relax tokens; this gets the right string computed and works. |
| 855 | 867 |
| 856 % Use this def/redef approach for \url{} since hyperref defined this already, | 868 % Use this def/redef approach for \url{} since hyperref defined this already, |
| 857 % but only if we actually used hyperref: | 869 % but only if we actually used hyperref: |
| 858 \ifpdf | 870 \ifpdf |
| 859 \newcommand{\url}[1]{{% | 871 \newcommand{\url}[1]{{% |
| 860 \noindent% | 872 \py@pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% |
| 861 \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% | |
| 862 \py@LinkColor% color of the link text | 873 \py@LinkColor% color of the link text |
| 863 \py@smallsize\sf #1% | 874 \py@smallsize\sf #1% |
| 864 \py@NormalColor% Turn it back off; these are declarative | 875 \py@NormalColor% Turn it back off; these are declarative |
| 865 \pdfendlink}% and don't appear bound to the current | 876 \pdfendlink}% and don't appear bound to the current |
| 866 }% formatting "box". | 877 }% formatting "box". |
| 931 % Note that \longprogramopt provides the '--'! | 942 % Note that \longprogramopt provides the '--'! |
| 932 \newcommand{\longprogramopt}[1]{\strong{-{}-#1}} | 943 \newcommand{\longprogramopt}[1]{\strong{-{}-#1}} |
| 933 | 944 |
| 934 % \ulink{link text}{URL} | 945 % \ulink{link text}{URL} |
| 935 \ifpdf | 946 \ifpdf |
| 936 % The \noindent here is a hack -- we're forcing pdfTeX into | 947 \newcommand{\ulink}[2]{{% |
| 937 % horizontal mode since \pdfstartlink requires that. | 948 % For PDF, we *should* only generate a link when the URL is absolute. |
| 938 % For PDF, we *should* only generate a link when the URL is absolute. | 949 \py@pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#2)}% |
| 939 \newcommand{\ulink}[2]{\noindent{% | |
| 940 \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#2)}% | |
| 941 \py@LinkColor% color of the link text | 950 \py@LinkColor% color of the link text |
| 942 #1% | 951 #1% |
| 943 \py@NormalColor% Turn it back off; these are declarative | 952 \py@NormalColor% Turn it back off; these are declarative |
| 944 \pdfendlink}% and don't appear bound to the current | 953 \pdfendlink}% and don't appear bound to the current |
| 945 }% formatting "box". | 954 }% formatting "box". |
