Annotation of OpenXM_contrib/pari-2.2/doc/pdfmacs.tex, Revision 1.1
1.1 ! noro 1: % $Id: pdfmacs.tex,v 1.3 2000/11/06 18:59:00 karim Exp $
! 2: % Copyright (c) 2000 The PARI Group
! 3: %
! 4: % This file is part of the PARI/GP documentation
! 5: %
! 6: % Permission is granted to copy, distribute and/or modify this document
! 7: % under the terms of the GNU Free Documentation License
! 8:
! 9: %% Modifications to parimacro.tex to be run through pdftex instead of
! 10: %% tex. Code now includes some pdf-specific code for hyperlinks.
! 11: %%
! 12: %% Cliff Bergman (cbergman@iastate.edu) Jan. 2000.
! 13: %%
! 14: %
! 15: %% Set the document info
! 16: \pdfoutput = 1
! 17: \pdfinfo {
! 18: /Title (\TITLE)
! 19: /Creator (pdfTeX)
! 20: /Producer (PARI, pari@math.u-bordeaux.fr)
! 21: /Author (C. Batut, K. Belabas, D. Bernardi, H. Cohen, M. Olivier)
! 22: /Subject (Number Theory) }
! 23: %
! 24: \pdfcatalog {/PageMode /UseOutlines}
! 25: %
! 26: \catcode`\@=11
! 27: %% Now we redefine several of the macros so as to provide hyperlinks.
! 28: %
! 29: % Colors
! 30: %
! 31: %% We use TeX's grouping mechanism to make \currentcolor into a stack.
! 32: %
! 33: \def\pushcolor#1{\bgroup\pdfsetcolor{#1}}
! 34: \def\popcolor{\egroup\pdfsetcolor{\currentcolor}}
! 35: \def\pdfsetcolor#1{\let\currentcolor=#1\pdfliteral{#1 k}}
! 36: % %
! 37: % % Maybe somebody with a better eye would like to pick nicer ones. See
! 38: % % the file plain/misc/pdfcolor.tex in the pdftex distribution.
! 39: % %
! 40: \def\Red{0 1 1 0}
! 41: \def\Blue{1 1 0 0}
! 42: \def\Green{1 0 1 0}
! 43: \def\Black{0 0 0 1}
! 44: \def\textcolor{\Black}
! 45: \def\linkcolor{\Red}
! 46: \def\emacscolor{\Green}
! 47: \def\unixcolor{\Blue}
! 48: \let\currentcolor=\textcolor
! 49: \pdfsetcolor{\textcolor}
! 50: %
! 51: %% Bookmarks. These turned out to be a pain. In order to get nested
! 52: %% bookmarks, Acrobat requires that each entry declare the number of
! 53: %% subentries in advance. We do this by counting the subentries (the
! 54: %% main entries are the chapters, subentries are the sections) during
! 55: %% the first pass and writing them to the aux file as a macro. Then the
! 56: %% bookmark entry is created on the second pass.
! 57:
! 58: % These keep track of the number of sections in each chapter and appendix.
! 59: \newtoks\numsectok \numsectok={\or}
! 60: \newtoks\numsecapptok \numsecapptok={\or}
! 61:
! 62: % Append #1 to the token list given in #2, separated by \or. #1 is
! 63: % expanded first (needed by \numsecs)
! 64: \def\append#1#2{\toks0=\expandafter{#1 \or }%
! 65: \edef\act{\global\noexpand#2={\the#2 \the\toks0}}\act}
! 66:
! 67: \def\writesecnumbers{
! 68: % Append the number of sections to the last appendix to the toks reg.
! 69: \append{\the\secno}\numsecapptok
! 70: % Write the definitions of (\numsecs and \numsecapp) to the aux file.
! 71: \write\aux{
! 72: \def\string\numsecs\string##1{%
! 73: \string\ifcase \string##1 \the\numsectok 0 \string\else 0 \string\fi}
! 74: \def\string\numsecsapp\string##1{%
! 75: \string\ifcase \string##1 \the\numsecapptok 0 \string\else 0 \string\fi}}}
! 76: %
! 77: % Hyperlink destinations will simply be of the form: pdf@nnn, where nnn
! 78: % is obtained from a new counter.
! 79: \newcount\pdfdestcntr \pdfdestcntr=0
! 80: % \putdest creates a pdf destination. Currently, the destination view
! 81: % is 'xyz' which means no change from the existing zoom factor.
! 82: \def\putdest{\global\advance\pdfdestcntr by 1%
! 83: \pdfdest name {pdf@\number\pdfdestcntr} xyz }
! 84:
! 85: %% It turns out that I also need a different counter for these
! 86: %% destinations since they are only computed on the second pass.
! 87: \newcount\pdfchapcntr \pdfchapcntr=0
! 88: \def\putchapdest{\global\advance\pdfchapcntr by1%
! 89: \pdfdest name {pdfchap@\number\pdfchapcntr} fitbh }
! 90:
! 91: \def\chapter#1#2\par{
! 92: \ifnum\chapno=0 \else \append{\the\secno}\numsectok \fi
! 93: \secno=0\global\advance\chapno by 1
! 94: \title{Chapter \number\chapno:}{#1}#2\noindent\ignorespaces
! 95: \ifsecondpass
! 96: \pdfoutline goto name {pdfchap@\number\pdfchapcntr} count -\numsecs\chapno
! 97: {\number\chapno\ #1}
! 98: \fi
! 99: }
! 100: \def\appendix#1{
! 101: \ifnum\appno=0 \append{\the\secno}\numsectok
! 102: \else \append{\the\secno}\numsecapptok \fi
! 103: \chapno=0
! 104: \global\secno=0\global\advance\appno by 1
! 105: \def\applet{\ifcase\appno\or A\or B\or C\or D\or E\or F\or G\fi}
! 106: \title{Appendix \applet:}{#1}\noindent\ignorespaces
! 107: \ifsecondpass
! 108: \pdfoutline goto name {pdfchap@\number\pdfchapcntr}
! 109: count -\numsecsapp\appno {\applet\ #1}
! 110: \fi}
! 111: \def\section#1{
! 112: \subsecno=0\global\advance\secno by 1
! 113: \gdef\currentlabel{\number\secno}
! 114: \sectitle{\maketitle{#1}}
! 115: \ifsecondpass
! 116: \pdfoutline goto name {pdfchap@\number\pdfchapcntr}
! 117: {\number\chapno.\number\secno\ #1}
! 118: \fi
! 119: }
! 120: %
! 121: %% FIXME: should use \[push|pop]color and not use explicitly \textcolor
! 122: %% (cf install() in Chapter 3)
! 123: \def\@restore{\endgraf \global\let\par\endgraf \pdfsetcolor{\textcolor}}
! 124: \def\unix{\global\let\par\@restore\pdfsetcolor{\unixcolor}\annotepar{UNIX}}
! 125: \def\emacs{\global\let\par\@restore\pdfsetcolor{\emacscolor}\annotepar{EMACS}}
! 126:
! 127: %% labels and symbolic cross-refs. For this we use the parameter to
! 128: %% build the symbolic pdf destination.
! 129: \def\label#1{\immediate\write\aux{\string
! 130: \newlabel{#1}{{\the\chapno}{\currentlabel}}}
! 131: \pdfdest name {pdf@lab#1} xyz}
! 132: \def\ref#1{\@ifundef{r@#1}
! 133: {{\bf ??}\@errundef{#1}}
! 134: {\edef\@temp{\csname r@#1\endcsname}%
! 135: \def\lbl{\@ref}\def\chp{\@cref}%
! 136: \pdfjumpref{#1}{\ifx\chp{\the\chapno}\lbl\else\chp.\lbl\fi}}}
! 137: \def\pdfjumpref#1#2{\pdfannotlink attr {/Border [ 0 0 0 ] /H /O}
! 138: goto name {pdf@lab#1}\pushcolor{\linkcolor}#2\popcolor\pdfendlink}
! 139:
! 140: \catcode`\@=12
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>