Hypertext marks in L^{A}TEX

Sebastian Rahtz

          Email: s.rahtz@elsevier.co.uk

processed March 25, 1999

Contents

1 The main macros 2 1.1 Package options and setup . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 Options for different drivers . . . . . . . . . . . . . . . . . . . . . . . . 7 1.3 Options to add extra features . . . . . . . . . . . . . . . . . . . . . . . . 9 1.4 Options to change appearance of links . . . . . . . . . . . . . . . . . . . 9 1.5 PDF-specific options . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.6 User hypertext macros . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 1.7 Underlying basic hypertext macros . . . . . . . . . . . . . . . . . . . . . 17 1.8 Compatibility with the L^{A}TEX2html package . . . . . . . . . . . . . . . . . 19 1.9 Forms creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 1.10 Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 1.11 Low-level utility macros . . . . . . . . . . . . . . . . . . . . . . . . . . 25 1.12 Automated L^{A}TEX hypertext cross-references . . . . . . . . . . . . . . . . 25

1.12.1 Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 1.12.2 Footnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 1.12.3 Float captions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 1.12.4 Bibliographic references . . . . . . . . . . . . . . . . . . . . . . 32 1.12.5 Page numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 1.12.6 Table of contents . . . . . . . . . . . . . . . . . . . . . . . . . . 35 1.12.7 New counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 1.12.8 AMSL^{A}TEX compatibility . . . . . . . . . . . . . . . . . . . . . . 37 1.12.9 Included figures . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

1.13 hyperindex entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 1.14 Compatibility with seminar slide package . . . . . . . . . . . . . . . . . 38 1.15 Localized nullifying of package . . . . . . . . . . . . . . . . . . . . . . 39 1.16 The Mangling Of Aux and Toc Files . . . . . . . . . . . . . . . . . . . . 39

2 Configuration files 42 2.1 pdftex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 2.2 hypertex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 2.3 dviwindo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 2.4 Direct pdfmark support (dvipdf and pdfmark) . . . . . . . . . . . . . . . 56 2.5 Driver-specific form support . . . . . . . . . . . . . . . . . . . . . . . . 63

2.5.1 pdfmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 2.5.2 dvipdf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 2.5.3 HyperTeX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 2.5.4 TeX4ht . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 2.5.5 pdfTeX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

3 Bookmarks in the PDF file 79 3.1 Dealing with PDFDocEncoding . . . . . . . . . . . . . . . . . . . . . . 80 3.2 Device dependent setup . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

3.2.1 Rokicki’s dvips . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 3.2.2 Textures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 3.2.3 dvipsone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

1 The main macros

1⟨∗package⟩

1.1 Package options and setup

It needs the December 95 release of L^{A}TEX, because it uses \protected@write, and it defines commands in options; and the page setup internal code changed at that point. It’ll probably break with the later releases!

2\RequirePackage{keyval}[1997/11/10]
3\RequirePackage{nameref}
4\def\hyper@warn#1{\PackageWarningNoLine{hyperref}{#1}}
5\def\hyper@info#1{\PackageInfo{hyperref}{#1}}
6\def\pdf@bbox{pdf@llx pdf@lly pdf@urx pdf@ury}
7\newif\ifhy@acrofour
8\newif\ifhy@activeanchor
9\newif\ifhy@backref
10\newif\ifhy@bookmarks
11\newif\ifhy@bookmarksnumbered
12\newif\ifhy@bookmarksopen
13\newif\ifhy@breaklinks
14\newif\ifhy@centerwindow
15\newif\ifhy@colorlinks
16\newif\ifhy@debug
17\newif\ifhy@exactdef
18\newif\ifhy@figures
19\newif\ifhy@fitwindow
20\newif\ifhy@frenchlinks
21\newif\ifhy@hyperindex
22\newif\ifhy@implicit
23\newif\ifhy@linktocpage
24\newif\ifhy@menubar
25\newif\ifhy@naturalnames

26\newif\ifhy@nesting
27\newif\ifhy@newwindow
28\newif\ifhy@pageanchor
29\newif\ifhy@plainpages
30\newif\ifhy@psize
31\newif\ifhy@raiselinks
32\newif\ifhy@toolbar
33\newif\ifhy@verbose
34\newif\ifhy@windowui
35\hy@acrofourfalse
36\hy@backreffalse
37\hy@bookmarksnumberedfalse
38\hy@bookmarksopenfalse
39\hy@bookmarkstrue
40\hy@breaklinksfalse
41\hy@centerwindowfalse
42\hy@debugfalse
43\hy@exactdeffalse
44\hy@figuresfalse
45\hy@fitwindowfalse
46\hy@hyperindextrue
47\hy@implicittrue
48\hy@linktocpagefalse
49\hy@menubartrue
50\hy@naturalnamesfalse
51\hy@nestingfalse
52\hy@newwindowfalse
53\hy@pageanchortrue
54\hy@plainpagestrue
55\hy@raiselinksfalse
56\hy@toolbartrue
57\hy@verbosefalse
58\hy@windowuitrue
59\newif\ifPDFbookmark
60\PDFbookmarkfalse
61\newdimen\@linkdim
62\let\hy@driver\@empty
63\let\MaybeStopEarly\relax

The PD1 encoding stuff done by Heiko Oberdiek.

Encoding PD1 can be specified as option of package ’fontenc’ or loaded here. It does not matter what font family is selected, as TEX does not process it anyway. So use CM.

64\@ifundefined{T@PD1}{\input{pd1enc.def}}{}
65\DeclareFontFamily{PD1}{pdf}{}
66\DeclareFontShape{PD1}{pdf}{m}{n}{ <-> cmr10 }{}
67\DeclareFontSubstitution{PD1}{pdf}{m}{n}
68\def\Hy@PDFDef#1#2{%
69 \begingroup
70  \fontencoding{PD1}\enc@update
71  \escapechar=`\\%

For octal numbers

72  \edef\0{\string\0}%
73  \edef\1{\string\1}%
74  \edef\2{\string\2}%
75  \edef\3{\string\3}%
76  \edef\4{\string\4}%
77  \edef\5{\string\5}%
78  \edef\6{\string\6}%
79  \edef\7{\string\7}%

TEX commands

80  \let\{\textbraceleft
81  \let\}\textbraceright
82  \let\\\textbackslash
83  \let\#\textnumbersign
84  \let\$\textdollar
85  \let\%\textpercent
86  \let\&\textampersand
87  \let\~\textasciitilde
88  \let\_\textunderscore
89  \let\P\textparagraph
90  \edef\space{\string\040}%
91  \let\ \space
92  \let~\space
93  \let\ldots\textellipsis
94  \let\dots\textellipsis
95  \let\glqq\textglqq
96  \let\grqq\textgrqq
97  \let\glq\textglq
98  \let\grq\textgrq
99  \let\flqq\textflqq
100  \let\frqq\textfrqq
101  \let\flq\textflq
102  \let\frq\textfrq

Here is a good place to redefine common commands if they should be supported at all, or just make them no-ops.

103  \def\LaTeX{LaTeX}%
104  \def\eTeX{e-TeX}%
105  \def\TeX{TeX}%
106  \def\MF{Metafont}%
107  \let\label\@gobble
108  \let\index\@gobble
109  \let\glossary\@gobble
110  \let\emph\@firstofone
111  \let\textbf\@firstofone
112  \let\textit\@firstofone
113  \let\textmd\@firstofone
114  \let\textnormal\@firstofone
115  \let\textrm\@firstofone

116  \let\textsc\@firstofone
117  \let\textsf\@firstofone
118  \let\textsl\@firstofone
119  \let\texttt\@firstofone
120  \let\textup\@firstofone
121  \let\xspace\@empty
122  \let\ttfamily\@empty
123  \let\sffamily\@empty
124  \let\itshape\@empty
125  \let\upshape\@empty
126  \let\bfseries\@empty
127  \let\rm\@empty
128  \let\Huge\@empty
129  \let\LARGE\@empty
130  \let\Large\@empty
131  \let\footnotesize\@empty
132  \let\huge\@empty
133  \let\large\@empty
134  \let\normalsize\@empty
135  \let\scriptsize\@empty
136  \let\small\@empty
137  \let\tiny\@empty

a) rigid definition of #1, in which unexpandable commands are detected by an error in

\csname...\endcsname
138  \ifhy@exactdef
139  \edef\Hy@temp{\csname#2\endcsname}%
140  \expandafter\ifx\csname\endcsname\Hy@temp
141  \let\Hy@temp\@empty
142  \global\let#1\Hy@temp
143  \else
144  \edef\Hy@temp{\expandafter\string\Hy@temp}%
145  \edef\Hy@temp{\noexpand\gdef\noexpand#1{%
146  \expandafter\ifnum\expandafter\escapechar\expandafter
147  =\expandafter`\Hy@temp\fi}%

148 }%

149  \fi

b) conservative definition of #1, in which unexpandable commands are written to bookmarks

150  \else
151%       \protected@edef\Hy@temp{\noexpand\gdef\noexpand#1{#2}}%
152  \edef\Hy@temp{\noexpand\gdef\noexpand#1{#2}}%
153  \fi
154 \Hy@temp
155 \endgroup

156}

157\@ifpackageloaded{xr}{%

If reading external aux files check whether they have a non zero fourth field in \newlabel and if so, add the URL as the fifth field.

158\def\XR@addURL#1{\XR@@dURL#1{}{}{}{}\\}
159\def\XR@@dURL#1#2#3#4#5\\{{#1}{#2}%
160 \if!#4!\else
161  {#3}{#4}{\XR@URL}%
162\fi}
163}{}
164\def\hy@true{true}
165\let\literalps@out\@gobble
166\let\pdfbookmark\@gobbletwo
167\let\Acrobatmenu\@gobble
168\def\@writetorep#1#2#3#4{}%
169\def\Hyp@boolkey#1#2{%
170 \hyper@info{option #2 set #1}%
171 \csname hy@#2\ifx\relax#1\relax true\else#1\fi\endcsname}
172\define@key{Hyp}{implicit}[true]{%
173 \lowercase{\Hyp@boolkey{#1}}{implicit}%

174}

175\define@key{Hyp}{draft}[true]{\AtBeginDocument{%
176  \let\hyper@@anchor\@gobble
177  \gdef\hyper@link##1##2##3{##3}%
178  \let\hyper@anchorstart\@gobble
179  \let\hyper@anchorend\@empty
180  \let\hyper@linkstart\@gobbletwo
181  \let\hyper@linkend\@empty
182  \def\hyper@linkurl##1##2{##1}%
183  \def\hyper@linkfile##1##2##3{##1}%
184  \def\Acrobatmenu##1##2{##2}%
185  \let\PDF@SetupDoc\@empty
186  \let\PDF@FinishDoc\@empty
187  \let\@fifthoffive\@secondoftwo
188  \let\@secondoffive\@secondoftwo
189  \hyper@warn{ draft mode on}%

190 }% 191}

192\let\KV@Hyp@nolinks\KV@Hyp@draft
193\define@key{Hyp}{a4paper}[true]{\def\special@paper{210mm,297mm}%
194 \def\hy@pageheight{842}}
195\define@key{Hyp}{a5paper}[true]{\def\special@paper{148mm,210mm}%
196 \def\hy@pageheight{595}}
197\define@key{Hyp}{b5paper}[true]{\def\special@paper{176mm,250mm}%
198 \def\hy@pageheight{709}}
199\define@key{Hyp}{letterpaper}[true]{\def\special@paper{8.5in,11in}%
200 \def\hy@pageheight{792}}
201\define@key{Hyp}{legalpaper}[true]{\def\special@paper{8.5in,14in}%
202 \def\hy@pageheight{1008}}
203\define@key{Hyp}{executivepaper}[true]{\def\special@paper{7.25in,10.5in}%
204 \def\hy@pageheight{720}}
205\define@key{Hyp}{debug}[true]{%
206 \lowercase{\Hyp@boolkey{#1}}{debug}}
207\define@key{Hyp}{4}[true]{%

208 \lowercase{\Hyp@boolkey{#1}}{acrofour}}
209\define@key{Hyp}{linktocpage}[true]{%
210 \lowercase{\Hyp@boolkey{#1}}{linktocpage}}
211\define@key{Hyp}{exactdef}[true]{%
212 \lowercase{\Hyp@boolkey{#1}}{exactdef}}
213\define@key{Hyp}{extension}{\def\XR@ext{#1}}
214\def\XR@ext{dvi}
215\define@key{Hyp}{verbose}[true]{%
216 \lowercase{\Hyp@boolkey{#1}}{verbose}}

If we are going to PDF via HyperTeX \special commands, the dvips (-z option) processor does not know the height of a link, as it works solely on the position of the closing \special. If we use this option, the \special is raised up by the right amount, to fool the dvi processor.

217\define@key{Hyp}{raiselinks}[true]{%
218 \lowercase{\Hyp@boolkey{#1}}{raiselinks}}

Most PDF-creating drivers do not allow links to be broken

219\define@key{Hyp}{breaklinks}[true]{%
220 \lowercase{\Hyp@boolkey{#1}}{breaklinks}}

Determines whether an automatic anchor is put on each page

221\define@key{Hyp}{pageanchor}[true]{%
222 \lowercase{\Hyp@boolkey{#1}}{pageanchor}}

Are the page links done as plain arabic numbers, or do they follow the formatting of the package? The latter loses if you put in typesetting like \textbf or the like.

223\define@key{Hyp}{plainpages}[true]{%
224 \lowercase{\Hyp@boolkey{#1}}{plainpages}}

Are the names for anchors made as per the HyperTeX system, or do they simply use what L^{A}TEX provides?

225\define@key{Hyp}{naturalnames}[true]{%
226 \lowercase{\Hyp@boolkey{#1}}{naturalnames}}

Currently, dvips doesn’t allow anchors nested within targets, so this option tries to stop that happening. Other processors may be able to cope.

227\define@key{Hyp}{nesting}[true]{%
228 \lowercase{\Hyp@boolkey{#1}}{nesting}}

1.2 Options for different drivers

229\define@key{Hyp}{hyperref}[true]{}
230\define@key{Hyp}{tex4ht}[true]{%
231 \def\XR@ext{html}%
232 \def\hy@driver{htex4ht}%

233}

234\define@key{Hyp}{pdftex}[true]{%
235 \def\hy@driver{hpdftex}%
236 \def\XR@ext{pdf}%
237 \PassOptionsToPackage{pdftex}{color}%

238 \hy@breaklinkstrue

239}

240\define@key{Hyp}{dvipdf}[true]{%

241}

242\define@key{Hyp}{nativepdf}[true]{%
243 \def\hy@driver{hdvips}%
244 \def\XR@ext{pdf}%

245}

246\define@key{Hyp}{dvipdfm}[true]{%
247 \def\hy@driver{hdvipdfm}%
248 \def\XR@ext{pdf}%

249}

250\define@key{Hyp}{pdfmark}[true]{%
251 \def\hy@driver{hdvips}%
252 \def\XR@ext{pdf}%

253 }

254\define@key{Hyp}{dvips}[true]{%
255 \def\hy@driver{hdvips}%
256 \def\XR@ext{pdf}%

257 }

258\define@key{Hyp}{hypertex}[true]{%
259 \def\hy@driver{hypertex}%

260 }

261\define@key{Hyp}{vtex}[true]{%
262 \@ifundefined{OpMode}{\@latex@error{Non-VTeX processor}{}\endinput}{}
263 \ifnum\OpMode=1\relax
264 \def\XR@ext{pdf}%
265 \def\hy@driver{hvtex}%
266 \else
267 \ifnum\OpMode=10\relax
268  \def\XR@ext{htm}%
269  \def\hy@driver{hvtexhtm}%
270  \def\MaybeStopEarly{\typeout{Hyperref stopped early}\endinput}
271 \else
272  \latex@error{Mode (\the\OpMode) has no hyperref driver}{}\endinput
273 \fi
274 \fi

275}

276\define@key{Hyp}{dviwindo}[true]{%
277  \def\hy@driver{hdviwind}%
278  \setkeys{Hyp}{colorlinks}%
279  \PassOptionsToPackage{dviwindo}{color}%

280}

281\define@key{Hyp}{dvipsone}[true]{%
282 \def\XR@ext{pdf}%
283 \def\hy@driver{hdvipson}%

284}

285\define@key{Hyp}{textures}[true]{%
286 \def\XR@ext{pdf}%
287 \def\hy@driver{htexture}%

289\define@key{Hyp}{latex2html}[true]{%
290 \AtBeginDocument{\@@latextohtmlX}%

291 }

No more special treatment for ps2pdf. Let it sink or swim.

292\define@key{Hyp}{ps2pdf}[true]{%
293 \def\hy@driver{hdvips}%

294}

1.3 Options to add extra features

Make included figures (assuming they use the standard graphics package) be hypertext links. Off by default. Needs more work.

295\define@key{Hyp}{hyperfigures}[true]{%
296 \lowercase{\Hyp@boolkey{#1}}{figures}}

Set up back-referencing to be hyper links, by page or section number,

297\def\back@none{none}
298\def\back@section{section}
299\def\back@page{page}
300\define@key{Hyp}{backref}[section]{%
301 \ifx\\#1\\\def\@tempa{section}\else\def\@tempa{section}\fi
302 \ifx\@tempa\back@section
303 \PassOptionsToPackage{hyperref}{backref}
304 \hy@backreftrue
305 \else
306 \ifx\back@opt\back@page
307  \PassOptionsToPackage{hyperpageref}{backref}
308  \hy@backreftrue
309 \fi
310 \fi

311}

312\define@key{Hyp}{pagebackref}[true]{%
313 \PassOptionsToPackage{hyperpageref}{backref}
314 \hy@backreftrue

315}

Make index entries be links back to the relevant pages. By default this is turned on, but may be stopped.

316\define@key{Hyp}{hyperindex}[true]{%
317 \lowercase{\Hyp@boolkey{#1}}{hyperindex}}

1.4 Options to change appearance of links

Colouring links at the L^{A}TEX level is useful for debugging, perhaps.

318\define@key{Hyp}{colorlinks}[true]{\lowercase{\Hyp@boolkey{#1}}{colorlinks}}
319\define@key{Hyp}{frenchlinks}[true]{\lowercase{\Hyp@boolkey{#1}}{frenchlinks}}
320\define@key{Hyp}{bookmarks}[true]{%
321  \lowercase{\Hyp@boolkey{#1}}{bookmarks}}
322\define@key{Hyp}{bookmarksopen}[true]{%

323  \lowercase{\Hyp@boolkey{#1}}{bookmarksopen}}

Richard Curnow ¡richard@curnow.demon.co.uk¿ suggested this functionality. It adds section numbers etc to bookmarks.

324\define@key{Hyp}{bookmarksnumbered}[true]{%
325  \lowercase{\Hyp@boolkey{#1}}{bookmarksnumbered}}
326\define@key{Hyp}{linkcolor}{\def\@linkcolor{#1}}
327\define@key{Hyp}{anchorcolor}{\def\@anchorcolor{#1}}
328\define@key{Hyp}{citecolor}{\def\@citecolor{#1}}
329\define@key{Hyp}{urlcolor}{\def\@urlcolor{#1}}
330\define@key{Hyp}{menucolor}{\def\@menucolor{#1}}
331\define@key{Hyp}{filecolor}{\def\@filecolor{#1}}
332\define@key{Hyp}{pagecolor}{\def\@pagecolor{#1}}

Default values:

333\def\@linkcolor{red}
334\def\@anchorcolor{black}
335\def\@citecolor{green}
336\def\@filecolor{cyan}
337\def\@urlcolor{magenta}
338\def\@menucolor{red}
339\def\@pagecolor{red}
340\define@key{Hyp}{baseurl}{\def\@baseurl{#1}}
341\def\hyperbaseurl#1{\def\@baseurl{#1}}
342\def\@pdfpagetransition{}
343\let\@baseurl\@empty

1.5 PDF-specific options

344\define@key{Hyp}{linkbordercolor}{\def\@linkbordercolor{#1}}
345\define@key{Hyp}{urlbordercolor}{\def\@urlbordercolor{#1}}
346\define@key{Hyp}{menubordercolor}{\def\@menubordercolor{#1}}
347\define@key{Hyp}{filebordercolor}{\def\@filebordercolor{#1}}
348\define@key{Hyp}{citebordercolor}{\def\@citebordercolor{#1}}
349\define@key{Hyp}{pagebordercolor}{\def\@pagebordercolor{#1}}
350\define@key{Hyp}{pdfhighlight}{\def\@pdfhighlight{#1}}
351\define@key{Hyp}{pdfborder}{\def\@pdfborder{#1}}
352\define@key{Hyp}{pdfpagemode}{\def\@pdfpagemode{/#1 }}
353\define@key{Hyp}{pdfpagetransition}{\def\@pdfpagetransition{#1}}
354\define@key{Hyp}{pdftitle}{\Hy@PDFDef\@pdftitle{#1}}
355\define@key{Hyp}{pdfauthor}{\Hy@PDFDef\@pdfauthor{#1}}
356\define@key{Hyp}{pdfproducer}{\Hy@PDFDef\@pdfproducer{#1}}
357\define@key{Hyp}{pdfcreator}{\Hy@PDFDef\@pdfcreator{#1}}
358\define@key{Hyp}{pdfsubject}{\Hy@PDFDef\@pdfsubject{#1}}
359\define@key{Hyp}{pdfkeywords}{\Hy@PDFDef\@pdfkeywords{#1}}
360\define@key{Hyp}{pdfview}{\calculate@pdfview#1 \\}
361\def\calculate@pdfview#1 #2\\{%
362 \def\@pdfview{#1}%
363 \ifx\\#2\\%
364 \def\@pdfviewparams{ -32768}%

365 \else
366 \def\@pdfviewparams{ #2}%
367 \fi

368}

369\define@key{Hyp}{pdfstartpage}{\def\@pdfstartpage{#1}}
370\define@key{Hyp}{pdfstartview}{%
371\ifx\\#1\\
372 \def\@pdfstartview{}%
373\else
374 \def\@pdfstartview{ /#1 }%
375\fi

376}

377\define@key{Hyp}{pdfpagescrop}{\edef\@pdfpagescrop{#1}}
378\define@key{Hyp}{pdftoolbar}[true]{%
379  \lowercase{\Hyp@boolkey{#1}}{toolbar}}
380\define@key{Hyp}{pdfmenubar}[true]{%
381  \lowercase{\Hyp@boolkey{#1}}{menubar}}
382\define@key{Hyp}{pdfwindowui}[true]{%
383  \lowercase{\Hyp@boolkey{#1}}{windowui}}
384\define@key{Hyp}{pdffitwindow}[true]{%
385  \lowercase{\Hyp@boolkey{#1}}{fitwindow}}
386\define@key{Hyp}{pdfcenterwindow}[true]{%
387  \lowercase{\Hyp@boolkey{#1}}{centerwindow}}
388\define@key{Hyp}{pdfnewwindow}[true]{%
389  \lowercase{\Hyp@boolkey{#1}}{newwindow}}
390\define@key{Hyp}{pdfpagelayout}{\def\pdf@pagelayout{#1}}
391\def\pdf@pagelayout{}

Default values:

392\def\@linkbordercolor{1 0 0}
393\def\@urlbordercolor{0 1 1}
394\def\@menubordercolor{1 0 0}
395\def\@filebordercolor{0 .5 .5}
396\def\@citebordercolor{0 1 0}
397\def\@pagebordercolor{1 1 0}
398\def\@pdfhighlight{/I}
399\def\@pdfpagemode{}
400\def\@pdftitle{}
401\def\@pdfauthor{}
402\def\@pdfproducer{}
403\def\@pdfcreator{LaTeX with hyperref package}
404\def\@pdfsubject{}
405\def\@pdfkeywords{}
406\def\@pdfpagecrop{}
407\def\@pdfpagescrop{}
408\def\@pdfstartview{ /Fit }
409\def\@pdfstartpage{1}
410\let\PDF@SetupDoc\@empty
411\let\PDF@FinishDoc\@empty
412\def\special@paper{210mm,297mm}

413\def\hy@pageheight{842}
414\def\hypersetup{\setkeys{Hyp}}

Allow the user to use \ExecuteOptions in the cfg file even though this package does not use the normal option mechanism. Use \hyper@normalise as a scratch macro, since it is going to be defined in a couple of lines anyway.

415\let\hyper@normalise\ExecuteOptions
416\let\ExecuteOptions\hypersetup
417\InputIfFileExists{hyperref.cfg}{}{}
418\let\ExecuteOptions\hyper@normalise

To add flexibility, we will not use the ordinary processing of package options, but put them through the keyval package. This section was written by David Carlisle.

419\def\ProcessOptionsWithKV#1{%
420 \let\@tempc\relax
421 \let\@tempa\@empty

Add any global options that are known to KV to the start of the list being built in

\@tempa.
422 \@for\CurrentOption:=\@classoptionslist\do{%
423  \@ifundefined{KV@#1@\CurrentOption}%
424  {}%
425  {\edef\@tempa{\@tempa,\CurrentOption,}}}%

Now stick the package options at the end of the list and wrap in a call to \setkeys. Can simply use \edef, normally KV takes care to avoid expansion, but the package system has already fully expanded the package option list before passing it to the package, so no more harm can occur here.

426  \edef\@tempa{%
427  \noexpand\setkeys{#1}{\@tempa\@ptionlist{\@currname.\@currext}}}%

Do it.

428  \@tempa

429}

430\let\ReadBookmarks\relax
431\ProcessOptionsWithKV{Hyp}
432\def\WriteBookmarks{0}
433\ifhy@bookmarks
434 \hyper@info{Bookmarks ON}
435 \ifx\@pdfpagemode\@empty\def\@pdfpagemode{/UseOutlines }\fi
436 \ifhy@bookmarksopen
437  \hyper@info{Bookmarks open}%
438  \def\@bookmarkopenstatus{}%
439 \else
440  \def\@bookmarkopenstatus{-}%
441 \fi
442\else
443 \hyper@info{Bookmarks OFF}
444 \AtEndOfPackage{\global\let\ReadBookmarks\relax
445  \global\let\WriteBookmarks\relax}%
446 \ifx\@pdfpagemode\@empty\def\@pdfpagemode{/None}\fi
447\fi

448\ifhy@figures
449 \hyper@info{Hyper figures ON}
450\else
451 \hyper@info{Hyper figures OFF}
452\fi
453\ifhy@nesting
454 \hyper@info{Link nesting ON}
455\else
456 \hyper@info{Link nesting OFF}
457\fi
458\ifhy@hyperindex
459 \hyper@info{Hyper index ON}
460\else
461 \hyper@info{Hyper index OFF}
462\fi
463\ifhy@plainpages
464 \hyper@info{Plain pages ON}
465\else
466 \hyper@info{Plain pages OFF}
467\fi
468\ifhy@backref
469 \hyper@info{Backreferencing ON}
470\else
471 \hyper@info{Backreferencing OFF}
472\fi

We might need to revert to this:

\ifhy@colorlinks
    \AtEndOfPackage{\RequirePackage{color}}%
    \def\hy@colorlink#1{\let\hyper@color\current@color\color{#1}}%
    \def\hy@endcolorlink{\let\current@color\hyper@color\set@color}%
\else
    \let\hy@colorlink\@gobble
    \let\hy@endcolorlink\@empty
    \hyper@info{Link coloring OFF}
\fi

473\ifhy@implicit
474  \typeout{Implicit mode ON; LaTeX internals redefined}%
475\else
476  \typeout{Implicit mode OFF; no redefinition of LaTeX internals}%
477  \def\MaybeStopEarly{\typeout{Hyperref stopped early}\endinput}%
478  \AtBeginDocument{%
479  \let\autoref\ref
480  \ifx\@pdfpagemode\@empty\global\def\@pdfpagemode{/None}\fi
481  \global\hy@backreffalse

482 }%

483 \AtEndOfPackage{%
484  \global\let\ReadBookmarks\relax
485  \global\let\WriteBookmarks\relax

487\fi
488\AtEndOfPackage{%
489 \ifx\hy@driver\@empty
490 \@ifundefined{pdfoutput}%
491  {\let\pdfoutput\@undefined
492  \typeout{*hyperref using default driver hypertex*}%
493  \input{hypertex.def}}
494  {\ifcase\pdfoutput
495  \let\pdfoutput\@undefined
496  \typeout{*hyperref using default driver hypertex*}%
497  \input{hypertex.def}
498  \else
499  \typeout{*hyperref using default driver pdftex*}%
500  \input{hpdftex.def}%
501  \def\XR@ext{pdf}%
502  \PassOptionsToPackage{pdftex}{color}%
503  \hy@breaklinkstrue
504  \fi}
505 \else
506 \typeout{*hyperref using driver \hy@driver*}%
507 \input{\hy@driver.def}%
508 \fi
509\let\@unprocessedoptions\relax

510}

511\AtBeginDocument{%
512 \ifhy@colorlinks
513 \RequirePackage{color}%
514 \def\hy@colorlink#1{\begingroup\color{#1}}%
515 \def\hy@endcolorlink{\endgroup}%
516 \hyper@info{Link coloring ON}%
517 \else
518 \ifhy@frenchlinks
519 \def\hy@colorlink#1{\begingroup\fontshape{sc}\selectfont}%
520 \def\hy@endcolorlink{\endgroup}%
521 \hyper@info{French linking ON}%
522 \else
523 \def\hy@colorlink#1{\begingroup} % for grouping consistency
524 \def\hy@endcolorlink{\endgroup}%
525 \hyper@info{Link coloring OFF}%
526 \fi
527 \fi
528 \ReadBookmarks

529}

530\ifhy@backref
531 \RequirePackage{backref}
532\else
533 \let\hy@backout\@gobble
534\fi

535\hy@activeanchorfalse

1.6 User hypertext macros

We need to normalise all user commands taking a URL argument; Within the argument the following special definitions apply: \#, \%, ~ produce #, %, ~ respectively. for consistency \~ produces ~ as well. At the top level only ie not within the argument of another command, you can use # and % unescaped, to produce themselves. even if, say, # is entered as # it will be converted to \# so it does not die if written to an aux file etc. \# will write as # locally while making \specials.

536\begingroup
537 \catcode`\!\active
538 \catcode`\&\active
539 \catcode`\_\active
540 \uccode`\!=`\%
541 \uccode`\&=`\#%
542\uppercase{\endgroup%
543\def\hyper@normalise#1{%
544 \begingroup%
545 \catcode`\%\active\def!{\%}%
546 \catcode`\#\active\def&{\#}%
547 \catcode`\_\active\def_{\string_}%
548 \let~\hyper@tilde%
549 \let\~\hyper@tilde%
550 \hyper@n@rmalise#1}}
551\def\hyper@n@rmalise#1#2{%
552 \edef\@tempa{\endgroup\noexpand#1{#2}}%
553 \@tempa}
554\providecommand\hyper@chars{%
555 \let\#\hyper@hash
556 \let\%\@percentchar}
557\def\hyperlink#1#2{%
558 \hyper@@link{}{#1}{#2}}
559\def\href{\hyper@normalise\href@}
560\def\href@#1{\expandafter\href@split#1\#\#\\}
561\def\href@split#1\##2\##3\\{%
562 \hyper@@link{#1}{#2}%

563}

564\RequirePackage{url}
565\def\Hurl{\begingroup \Url}
566\def\url{\hyper@normalise\url@}
567\def\url@#1{\hyper@linkurl{\Hurl{#1}}{#1}}
568\def\hyperimage{\hyper@normalise\hyper@image}
569\providecommand\hyper@image[2]{#2}
570\def\hypertarget#1#2{%
571 \ifhy@nesting
572  \hyper@@anchor{#1}{#2}%

573 \else
574  \hyper@@anchor{#1}{\relax}#2%
575 \fi}

\hyperref is more complicated, as it includes the concept of a category of link, used to make the name. This is not really used in this package. \hyperdef sets up an anchor in the same way. They each have three parameters of category, linkname, and marked text, and \hyperrref also has a first parameter of URL. If there is an optional first parameter to \hyperdef, it is the name of a L^{A}TEX label which can be used in a short form of \hyperref later, to avoid remembering the name and category.

576\def\hyperref{\@ifnextchar[\label@hyperref\@hyperref}
577\def\@hyperref{\hyper@normalise\@@hyperref}
578\def\@@hyperref#1#2#3{%
579 \edef\ref@one{\ifx\\#2\\\else#2.\fi#3}%
580 \expandafter\tryhyper@link\ref@one\\{#1}%

581}

582\def\tryhyper@link#1\\#2{%
583 \hyper@@link{#2}{#1}%

584}

585\def\hyperdef{\@ifnextchar[{\label@hyperdef}{\@hyperdef}}
586\def\@hyperdef#1#2#3{%, category, name, text
587 \ifhy@nesting
588  \hyper@@anchor{#1.#2}{#3}%
589 \else
590  \hyper@@anchor{#1.#2}{\relax}#3%
591 \fi}

We also have a need to give a L^{A}TEX label to a hyper reference, to ease the pain of referring to it later.

592\def\label@hyperref[#1]{%
593 \expandafter\label@@hyperref\csname r@#1\endcsname{#1}}%
594\def\label@@hyperref#1#2#3{%
595 \ifx#1\relax
596 \protect\G@refundefinedtrue
597  \@latex@warning{Hyper reference `#2' on page \thepage \space
598  undefined}%
599 \hyper@@link{}{??}{#3}%
600 \else
601 \hyper@@link{\expandafter\@fifthoffive#1}%
602 {\expandafter\@fourthoffive#1\@empty\@empty}{#3}%
603 \fi

604}

605\def\label@hyperdef[#1]#2#3#4{% label name, category, name,
606  % anchor text
607 \@bsphack
608 \protected@write\@auxout{}%
609  {\string\newlabel{#1}{{}{}{}\##2.#3}}%
610 \@esphack
611 \ifhy@nesting

612 \hyper@@anchor{#2.#3}{#4}%
613 \else
614 \hyper@@anchor{#2.#3}{\relax}#4%
615 \fi

616}

1.7 Underlying basic hypertext macros

Links have an optional type, a filename (possibly a URL), an internal name, and some marked text. If the second parameter is empty, its an internal link, otherwise we need to open another file or a URL. A link start has a type, and a URL.

617\def\hyper@@link{\let\reserved@a\relax
618 \@ifnextchar[{\hyper@link@}{\hyper@link@[link]}}
619\def\hyper@link@[#1]#2#3#4{%
620 \edef\@tempa{#2}%
621 \ifx\@tempa\@empty
622  \hyper@link{#1}{#3}{#4}%
623 \else
624  \expandafter\hyper@readexternallink#2\\{#1}{#3}{#4}%
625 \fi

626}

The problem here is that the first (URL) parameter may be a local file: reference (in which case some browsers treat it differently) or a genuine URL, in which case we’ll have to activate a real Web browser. Note that a simple name is also a URL, as that is interpreted as a relative file name. We have to worry about # signs in a local file as well.

627\def\hyper@readexternallink#1\\#2#3#4{%

Parameters are:

1. The URL or file name

2. The type

3. The internal name

4. The link string

We need to get the 1st parameter properly expanded, so we delimit the arguments rather than passing it inside a group.

628 \expandafter\@hyper@readexternallink{#2}{#3}{#4}#1::\\{#1}%

629}

Now (potentially), we are passed: 1) The link type 2) The internal name, 3) the link string,

4) the URL type (http, mailto, file etc), 5) the URL details 6) anything after a real : in the URL 7) the whole URL again

630\def\@pdftempwordfile{file}%
631\def\@hyper@readexternallink#1#2#3#4:#5:#6\\#7{%

If there are no colons at all (#6 is blank), its a local file; if the URL type (#4) is blank, its probably a Mac filename, so treat it like a file: URL. The only flaw is if its a relative Mac path, with several colon-separated elements — then we lose. Such names must be prefixed with an explicit dvi:

632\ifx\\#6\\%
633 \expandafter\@hyper@linkfile file:#7\\{#3}{#2}%
634\else
635 \ifx\\#4\\%
636 \expandafter\@hyper@linkfile file:#7\\{#3}{#2}%
637 \else

If the URL type is ‘file’, pass it for local opening

638 \def\@pdftempa{#4}%
639 \ifx\@pdftempa\@pdftempwordfile
640  \expandafter\@hyper@linkfile#7\\{#3}{#2}%
641 \else

otherwise its a URL

642  \hyper@linkurl{#3}{#7\ifx\\#2\\\else\##2\fi}%
643 \fi
644 \fi
645\fi

646}

D P Story ¡story@uakron.edu¿ pointed out that relative paths starting .. fell over. Switched to using \filename@parse to solve this.

647\def \@hyper@linkfile file:#1\\#2#3{%
648  %file url,link string, name
649 \filename@parse{#1}%
650 \ifx\filename@ext\relax
651  \edef\filename@ext{\XR@ext}%
652 \fi
653 \def\use@file{\filename@area\filename@base.\filename@ext}%
654 \ifx\filename@ext\XR@ext
655  \hyper@linkfile{#2}{\use@file}{#3}%
656 \else
657  \ifx\@baseurl\@empty
658  \hyper@linkurl{#2}{file:\use@file\ifx\\#3\\\else\##3\fi}%
659  \else
660  \hyper@linkurl{#2}{\use@file\ifx\\#3\\\else\##3\fi}%
661  \fi
662 \fi%

663}

Anchors have a name, and marked text. We have to be careful with the marked text, as if we break off part of something to put a \special around it, all hell breaks loose. Therefore, we check the category code of the first token, and only proceed if its safe. Tanmoy sorted this out.

A curious case arises if the original parameter was in braces. That means that #2 comes here a multiple letters, and the noexpand just looks at the first one, putting the rest in the output. Yuck.

664\long\def\hyper@@anchor#1#2{\@hyper@@anchor#1\relax#2\relax}
665\long\def\@hyper@@anchor#1\relax#2#3\relax{%
666\ifx\\#1\\#2\hyper@warn{empty link? #1: #2#3}%
667\else
668 \def\anchor@spot{#2#3}%
669 \let\put@me@back\@empty
670 \ifx\relax#2\relax
671 \else
672  \ifhy@nesting
673  \else
674  \ifcat a\noexpand#2\relax
675  \else
676  \ifcat 0\noexpand#2 \relax
677  \else
678%\typeout{Anchor start is not alphanumeric on input line\the\inputlineno}%
679  \let\anchor@spot\@empty
680  \def\put@me@back{#2#3}%
681  \fi
682  \fi
683  \fi
684 \fi
685 \ifhy@activeanchor
686  \anchor@spot
687 \else
688  \hyper@anchor{#1}%
689 \fi
690 \expandafter\put@me@back
691\fi
692\let\anchor@spot\@empty

693}

1.8 Compatibility with the L^{A}TEX2html package

Map our macro names on to Nikos’, so that documents prepared for that system will work without change.

Note, however, that the whole complicated structure for segmenting documents is not supported; it is assumed that the user will load html.sty first, and then hyperref.sty, so that the definitions in html.sty take effect, and are then overridden in a few circumstances by this package.

694\let\htmladdimg\hyperimage
695\def\htmladdnormallink#1#2{\href{#2}{#1}}
696\def\htmladdnormallinkfoot#1#2{\href{#2}{#1}\footnote{#2}}
697\def\htmlref#1#2{% anchor text, label
698 \label@hyperref[#2]{#1}%

699}

This is really too much. The L^{A}TEX2html package defines its own \hyperref command, with a different syntax. Was this always here? Its weird, anyway. We interpret it in the ‘printed’ way, since we are about fidelity to the page.

700\def\@@latextohtmlX{%
701 \let\hhyperref\hyperref
702 \def\hyperref##1##2##3##4{% anchor text for HTML
703  % text to print before label in print
704  % label
705  % post-label text in print
706 ##2\ref{##4}##3}%

707}

1.9 Forms creation

Allow for creation of PDF or HTML forms. The effects here are limited somewhat by the need to support both output formats, so it may not be as clever as something which only wants to make PDF forms.

I could not have started this without the encouragement of T V Raman.

708\newif\ifFld@checked
709\newif\ifFld@hidden
710\newif\ifFld@multiline
711\newif\ifFld@readonly
712\newif\ifFld@disabled
713\newif\ifFld@password
714\newif\ifFld@radio
715\newif\ifFld@combo
716\newif\ifFld@popdown
717\Fld@multilinefalse
718\Fld@checkedfalse
719\Fld@hiddenfalse
720\Fld@readonlyfalse
721\Fld@disabledfalse
722\Fld@radiofalse
723\Fld@combofalse
724\Fld@popdownfalse
725\Fld@passwordfalse
726\newcount\Fld@menulength
727\newdimen\Field@Width
728\newdimen\Fld@charsize
729\Fld@charsize=10\p@
730\def\Fld@maxlen{0}
731\def\Fld@align{0}
732\def\Fld@color{0 0 0}
733\def\Fld@bcolor{1 1 1}
734\def\Fld@bordercolor{1 0 0}
735\def\Fld@bordersep{1\p@}
736\def\Fld@borderwidth{1}
737\def\Fld@borderstyle{S}
738\newtoks\Choice@toks
739\def\Form{\@ifnextchar[{\@Form}{\@Form[]}}

740\def\endForm{\@endForm}
741\newif\ifForm@html
742\Form@htmlfalse
743\def\Form@boolkey#1#2{%
744 \csname Form@#2\ifx\relax#1\relax true\else#1\fi\endcsname}
745\define@key{Form}{action}{%
746 \def\Form@action{#1}%

747}

748\def\enc@@html{html}
749\define@key{Form}{encoding}{%
750 \def\@tempa{#1}%
751 \ifx\@tempa\enc@@html
752 \Form@htmltrue
753 \else
754 \typeout{hyperref: form `encoding' key set to #1 -- unknown type}%
755 \Form@htmlfalse
756 \fi

757}

758\define@key{Form}{method}{%
759 \def\Form@method{#1}%

760}

761\def\Form@method{}
762\def\Field@boolkey#1#2{%
763 \csname Fld@#2\ifx\relax#1\relax true\else#1\fi\endcsname}
764\newtoks\Field@toks
765\Field@toks={ }%
766\def\Field@addtoks#1#2{%
767 \edef\@processme{\Field@toks{\the\Field@toks\space #1="#2"}}%
768 \@processme

769}

770\def\Fld@checkequals#1=#2=#3\\{%
771 \def\@currDisplay{#1}%
772 \ifx\\#2\\%
773 \def\@currValue{#1}%
774 \else
775 \def\@currValue{#2}%
776 \fi

777}

778\define@key{Field}{loc}{%
779 \def\Fld@loc{#1}%

780}

781\define@key{Field}{multiline}[true]{%
782 \lowercase{\Field@boolkey{#1}}{multiline}}
783\define@key{Field}{checked}[true]{%
784 \lowercase{\Field@boolkey{#1}}{checked}}
785\define@key{Field}{hidden}[true]{%
786 \lowercase{\Field@boolkey{#1}}{hidden}}
787\define@key{Field}{readonly}[true]{%
788 \lowercase{\Field@boolkey{#1}}{readonly}}
789\define@key{Field}{disabled}[true]{%

790 \lowercase{\Field@boolkey{#1}}{disabled}}
791\define@key{Field}{password}[true]{%
792 \lowercase{\Field@boolkey{#1}}{password}}
793\define@key{Field}{radio}[true]{%
794 \lowercase{\Field@boolkey{#1}}{radio}}
795\define@key{Field}{combo}[true]{%
796 \lowercase{\Field@boolkey{#1}}{combo}}
797\define@key{Field}{popdown}[true]{%
798 \lowercase{\Field@boolkey{#1}}{popdown}}
799\define@key{Field}{accesskey}{%
800 \Field@addtoks{accesskey}{#1}%

801}

802\define@key{Field}{tabkey}{%
803 \Field@addtoks{tabkey}{#1}%

804}

805\define@key{Field}{name}{%
806 \def\Fld@name{#1}}
807\define@key{Field}{width}{%
808 \def\Fld@width{#1}%
809 \Field@Width#1\setbox0=\hbox{m}%

810}

811\define@key{Field}{maxlen}{%
812 \Fld@maxlen=#1}
813\define@key{Field}{menulength}{%
814 \Fld@menulength=#1}
815\define@key{Field}{height}{%
816 \def\Fld@height{#1}}
817\define@key{Field}{charsize}{%
818 \Fld@charsize#1}
819\define@key{Field}{fillcolor}{%
820 \def\Fld@fillcolor{#1}}
821\define@key{Field}{bordercolor}{%
822 \def\Fld@bordercolor{#1}}
823\define@key{Field}{color}{%
824 \def\Fld@color{#1}}
825\define@key{Field}{borderwidth}{%
826 \def\Fld@borderwidth{#1}}
827\define@key{Field}{borderstyle}{%
828 \def\Fld@borderstyle{#1}}
829\define@key{Field}{bordersep}{%
830 \def\Fld@bordersep{#1}}
831\define@key{Field}{default}{%
832 \def\Fld@default{#1}}
833\define@key{Field}{align}{%
834 \def\Fld@align{#1}}
835\define@key{Field}{value}{%
836 \def\Fld@value{#1}}
837\define@key{Field}{backgroundcolor}{%
838 \def\Fld@bcolor{#1}}
839\def\Fld@format@code{}

840\def\Fld@validate@code{}
841\def\Fld@calculate@code{}
842\def\Fld@keystroke@code{}
843\define@key{Field}{keystroke}{%
844 \def\Fld@keystroke@code{#1}%

845}

846\define@key{Field}{format}{%
847 \def\Fld@format@code{#1}%

848}

849\define@key{Field}{validate}{%
850 \def\Fld@validate@code{#1}%

851}

852\define@key{Field}{calculate}{%
853 \def\Fld@calculate@code{#1}%

854}

855\define@key{Field}{onfocus}{%
856 \Field@addtoks{onfocus}{#1}%

857}

858\define@key{Field}{onblur}{%
859 \Field@addtoks{onblur}{#1}%

860}

861\define@key{Field}{onselect}{%
862 \Field@addtoks{onselect}{#1}%

863}

864\define@key{Field}{onchange}{%
865 \Field@addtoks{onchange}{#1}%

866}

867\define@key{Field}{onclick}{%
868 \def\Fld@onclick{#1}%
869 \Field@addtoks{onclick}{#1}%

870}

871\define@key{Field}{ondblclick}{%
872 \Field@addtoks{ondblclick}{#1}%

873}

874\define@key{Field}{onmousedown}{%
875 \Field@addtoks{onmousedown}{#1}%

876}

877\define@key{Field}{onmouseup}{%
878 \Field@addtoks{onmouseup}{#1}%

879}

880\define@key{Field}{onmouseover}{%
881 \Field@addtoks{onmouseover}{#1}%

882}

883\define@key{Field}{onmousemove}{%
884 \Field@addtoks{onmousemove}{#1}%

885}

886\define@key{Field}{onmouseout}{%
887 \Field@addtoks{onmouseout}{#1}%

888}

889\define@key{Field}{onkeypress}{%

890 \Field@addtoks{onkeypress}{#1}%

891}

892\define@key{Field}{onkeydown}{%
893 \Field@addtoks{onkeydown}{#1}%

894}

895\define@key{Field}{onkeyup}{%
896 \Field@addtoks{onkeyup}{#1}%

897} 898%

899\DeclareRobustCommand\TextField{\@ifnextchar[{\@TextField}{\@TextField[]}}
900\DeclareRobustCommand\ChoiceMenu{\@ifnextchar[{\@ChoiceMenu}{\@ChoiceMenu[]}}
901\DeclareRobustCommand\CheckBox{\@ifnextchar[{\@CheckBox}{\@CheckBox[]}}
902\DeclareRobustCommand\PushButton{\@ifnextchar[{\@PushButton}{\@PushButton[]}}
903\DeclareRobustCommand\Gauge{\@ifnextchar[{\@Gauge}{\@Gauge[]}}
904\DeclareRobustCommand\Submit{\@ifnextchar[{\@Submit}{\@Submit[]}}
905\DeclareRobustCommand\Reset{\@ifnextchar[{\@Reset}{\@Reset[]}}
906\def\LayoutTextField#1#2{% label, field
907 #1 #2}
908\def\LayoutChoiceField#1#2{% label, field
909 #1 #2}
910\def\LayoutCheckField#1#2{% label, field
911 #1 #2}
912\def\LayoutPushButtonField#1{% button
913 #1}
914\def\MakeRadioField#1#2{\vbox to #2{\hbox to #1{\hfill}\vfill}}
915\def\MakeCheckField#1#2{\vbox to #2{\hbox to #1{\hfill}\vfill}}
916\def\MakeTextField#1#2{\vbox to #2{\hbox to #1{\hfill}\vfill}}
917\def\MakeChoiceField#1#2{\vbox to #2{\hbox to #1{\hfill}\vfill}}
918\def\MakeButtonField#1{%
919 \setbox0=\hbox{\hskip\Fld@borderwidth bp#1\hskip\Fld@borderwidth bp}%
920 \@tempdima\ht0
921  \advance\@tempdima by \Fld@borderwidth bp
922  \advance\@tempdima by \Fld@borderwidth bp
923  \ht0\@tempdima
924 \@tempdima\dp0
925  \advance\@tempdima by \Fld@borderwidth bp
926  \advance\@tempdima by \Fld@borderwidth bp
927  \dp0\@tempdima
928 \box0}
929\def\DefaultHeightofSubmit{14pt}
930\def\DefaultWidthofSubmit{2cm}
931\def\DefaultHeightofReset{14pt}
932\def\DefaultWidthofReset{2cm}
933\def\DefaultHeightofCheckBox{\baselineskip}
934\def\DefaultWidthofCheckBox{\baselineskip}
935\def\DefaultHeightofChoiceMenu{\baselineskip}
936\def\DefaultWidthofChoiceMenu{\baselineskip}
937\def\DefaultHeightofText{\baselineskip}
938\def\DefaultWidthofText{3cm}

1.10 Setup

939\ifhy@figures
940 \hyper@info{Hyper figures ON}
941\else
942 \hyper@info{Hyper figures OFF}
943\fi
944\ifhy@nesting
945 \hyper@info{Link nesting ON}
946\else
947 \hyper@info{Link nesting OFF}
948\fi
949\ifhy@hyperindex
950 \hyper@info{Hyper index ON}
951\else
952 \hyper@info{Hyper index OFF}
953\fi
954\ifhy@backref
955 \hyper@info{backreferencing ON}
956\else
957 \hyper@info{backreferencing OFF}
958\fi
959\ifhy@colorlinks
960  \hyper@info{Link coloring ON}
961\else
962  \hyper@info{Link coloring OFF}
963\fi

1.11 Low-level utility macros

We need unrestricted access to the #, ~ and " characters, so make them nice macros.

964\edef\hyper@hash{\string#}
965\edef\hyper@tilde{\string~}
966\edef\hyper@quote{\string"}
967\let\@currentHref\@empty

We give the start of document a special label; this is used in backreferencing-by-section, to allow for cites before any sectioning commands. Set up PDF info.

968\AtBeginDocument{%
969 \PDFbookmarktrue
970 \PDF@SetupDoc
971 \hyper@anchorstart{Doc-Start}\hyper@anchorend
972 \PDFbookmarkfalse

973}

974\MaybeStopEarly

1.12 Automated L^{A}TEX hypertext cross-references

Anything which can be referenced advances some counter; we overload this to put in a hypertext starting point (with no visible anchor), and make a note of that for later use in \label. This will fail badly if \theH<name> does not expand to a sensible reference. This means that classes or package which introduce new elements need to define an equivalent \theH<name> for every \the<name>. We do make a trap to make

\theH<name> be the same as \arabic{<name>}, if \theH<name> is not defined,

but this is not necessarily a good idea. Alternativey, the ‘naturalnames’ option uses whatever L^{A}TEX provides, which may be useable. But then its up to you to make sure these are legal PDF and HTML names

All the shenanigans is to make sure section numbers etc are always arabic, separated by dots. Who knows how people will set up \@currentlabel? If they put spaces in, or brackets (quite legal) then the hypertext processors will get upset.

But this is flaky, and open to abuse. Styles like subeqn will mess it up, for starters. Appendices are an issue, too. We just hope to cover most situations. We can at least cope with the standard sectioning structure, allowing for \part and \chapter.

Start with a fallback for equations

975\newcommand\theHequation {\theHsection.\arabic{equation}}
976\@ifundefined{thepart}{}{\newcommand\theHpart{\arabic{part}}}
977\@ifundefined{thechapter}{%
978  \newcommand\theHsection         {\arabic{section}}
979  \newcommand\theHfigure          {\arabic{figure}}
980  \newcommand\theHtable          {\arabic{table}}
981 }{%
982 \newcommand\theHchapter        {\arabic{chapter}}
983 \newcommand\theHfigure         {\theHchapter.\arabic{figure}}
984 \newcommand\theHtable         {\theHchapter.\arabic{table}}
985 \newcommand\theHsection        {\theHchapter.\arabic{section}}

986 }

987\newcommand\theHsubsection     {\theHsection.\arabic{subsection}}
988\newcommand\theHsubsubsection {\theHsubsection.\arabic{subsubsection}}
989\newcommand\theHparagraph      {\theHsubsubsection.\arabic{paragraph}}
990\newcommand\theHsubparagraph  {\theHparagraph.\arabic{subparagraph}}
991\newcommand\theHtheorem        {\theHsection.\arabic{theorem}}
992\newcommand\theHthm        {\theHsection.\arabic{thm}}

Thanks to Greta Meyer (gbd@pop.cwru.edu) for making me realize that enumeration starts at 0 for every list! But \item occurs inside \trivlist, so check if its a real \item before incrementing counters.

993\let\H@item\item
994\newcounter{Item}
995\def\theHItem{\arabic{Item}}
996\def\item{%
997 \@hyper@itemfalse
998 \if@nmbrlist\@hyper@itemtrue\fi
999 \H@item

1000}

1001\newcommand\theHenumi  {\theHItem}
1002\newcommand\theHenumii  {\theHItem}
1003\newcommand\theHenumiii  {\theHItem}
1004\newcommand\theHenumiv  {\theHItem}

1005\newcommand\theHHfootnote  {\arabic{Hfootnote}}
1006\newcommand\theHmpfootnote  {\arabic{mpfootnote}}
1007\let\theHHmpfootnote\theHHfootnote
1008\newcommand\theHslide  {\arabic{slide}}
1009\let\orig@appendix\appendix
1010\def\appendix{\orig@appendix
1011 \@ifundefined{thechapter}%
1012 {\renewcommand\theHsection{\Alph{section}}}%
1013 {\renewcommand\theHchapter{\Alph{chapter}}}%

1014}

Tanmoy asked for this default handling of undefined \theH<name> situations. It really isn’t clear what would be ideal, whether to turn off hyperizing of unknown elements, to pick up the textual definition of the counter, or to default it to something like \arabic{name}. We take the latter course, slightly worriedly.

1015\let\H@refstepcounter\refstepcounter
1016\edef\name@of@eq{equation}%

We do not want the handler for \refstepcounter to cut in during the processing of \item (we handle that separately), so we provide a bypass conditional.

1017\newif\if@hyper@item
1018\newif\if@skiphyperref
1019\@hyper@itemfalse
1020\@skiphyperreffalse
1021\def\refstepcounter#1{%
1022 \H@refstepcounter{#1}%
1023 \if@skiphyperref
1024 \else
1025 \if@hyper@item
1026  \stepcounter{Item}%
1027  \hyper@refstepcounter{Item}%
1028 \else
1029  \hyper@refstepcounter{#1}%

1030 \fi 1031 \fi 1032}

AMSL^{A}TEX processes all equations twice; we want to make sure that the hyper stuff is not executed twice, so we use the AMS \ifmeasuring@, initialized if AMS math is not used.

1033\@ifpackageloaded{amsmath}{}{\newif\ifmeasuring@\measuring@false}
1034\def\hyper@refstepcounter#1{%
1035 \edef\This@name{#1}%
1036 \ifx\This@name\name@of@eq
1037  \make@stripped@name{\theequation}%
1038  \let\theHequation\newname

1039 \fi

1040 \@ifundefined{theH#1}{%
1041 \expandafter\def\csname theH#1\endcsname{\arabic{#1}}%
1042  }{}%

1043 \hyper@makecurrent{#1}%
1044 \ifmeasuring@\else
1045 \hyper@anchorstart{\@currentHref}\hyper@anchorend

1046 \fi 1047}

1048\def\hyper@makecurrent#1{%
1049 \ifhy@naturalnames
1050 \edef\@currentHlabel{\csname the#1\endcsname}%
1051 \else
1052 \edef\@currentHlabel{\csname theH#1\endcsname}%

1053 \fi

1054 \global\edef\@currentHref{#1.\expandafter
1055  \strip@prefix\meaning\@currentHlabel}%

1056}

1057\@ifpackageloaded{fancyvrb}{%
1058 \def\FV@StepLineNo{%
1059 \FV@SetLineNo
1060 \def\FV@StepLineNo{\H@refstepcounter{FancyVerbLine}}%
1061 \FV@StepLineNo}%

1062}{}

1063\@ifpackageloaded{lastpage}{%
1064\def\lastpage@putlabel{\addtocounter{page}{-1}%
1065 \immediate\write\@auxout{\string
1066 \newlabel{LastPage}{{}{\thepage}{}{}{}}}%
1067 \addtocounter{page}{1}}}{}

1068

1.12.1 Equations

We want to make the whole equation a target anchor. Overload equation, temporarily reverting to original \refstepcounter. If, however, it is in AMS math, we do not do anything, as the tag mechanism is used there (see section 1.12.8).

1069\let\new@refstepcounter\refstepcounter
1070\let\H@equation\equation
1071\let\H@endequation\endequation
1072\@ifpackageloaded{amsmath}{}{%
1073 \def\equation{%
1074 \let\refstepcounter\H@refstepcounter
1075 \H@equation
1076 \make@stripped@name{\theequation}%
1077 \let\theHequation\newname
1078 \hyper@makecurrent{equation}%
1079 \hyper@anchorstart{\@currentHref}%
1080 \let\refstepcounter\new@refstepcounter
1081 }\def\endequation{\hyper@anchorend\H@endequation}%

1082}

My goodness, why can’t L^{A}TEX be consistent? Why is \eqnarray set up differently from other objects?

1083\newif\if@eqnstar
1084\@eqnstarfalse
1085\let\H@eqnarray\eqnarray
1086\let\H@endeqnarray\endeqnarray
1087\def\eqnarray{%
1088 \let\reserved@a\relax
1089 \H@eqnarray
1090 \if@eqnstar\else
1091 \make@stripped@name{\theequation}%
1092 \let\theHequation\newname
1093 \hyper@makecurrent{equation}%
1094 \hyper@anchorstart{\@currentHref}{}\hyper@anchorend

1095 \fi 1096}

1097\def\endeqnarray{%
1098 \H@endeqnarray

1099}

This is quite heavy-handed, but it works for now. If its an eqnarray* we need to disable the hyperref actions. There may well be a cleaner way to trap this. Bill Moss found this.

1100\@namedef{eqnarray*}{\def\@eqncr{\nonumber\@seqncr}\@eqnstartrue\eqnarray}
1101\@namedef{endeqnarray*}{\nonumber\endeqnarray\@eqnstarfalse}

Then again, we have the subeqnarray package. Tanmoy provided some code for this:

1102\@ifundefined{subeqnarray}{}%
1103{\let\H@subeqnarray\subeqnarray
1104 \let\H@endsubeqnarray\endsubeqnarray
1105 \def\subeqnarray{%
1106 \let\reserved@a\relax
1107 \H@subeqnarray
1108 \make@stripped@name{\theequation}%
1109 \let\theHequation\newname
1110 \hyper@makecurrent{equation}%
1111 \hyper@anchorstart{\@currentHref}{}\hyper@anchorend

1112 }%

1113 \def\endsubeqnarray{%
1114 \H@endsubeqnarray

1115 }%

1116\newcommand\theHsubequation {\theHequation\alph{subequation}}%

1117}

The aim of this macro is to produce a sanitized version of its argument, to make it a safe label.

1118\def\make@stripped@name#1{{%
1119 \escapechar\m@ne
1120 \global\let\newname\@empty
1121 \protected@edef\@tempa{#1}%
1122 \edef\@tempb{%
1123 \noexpand\@tfor\noexpand\@tempa:=\expandafter\strip@prefix\meaning\@tempa}%
1124 \@tempb\do{%
1125 \if{\@tempa\else

1126  \if}\@tempa\else
1127  \xdef\newname{\newname\@tempa}%

1128 \fi

1129 \fi}}}

1.12.2 Footnotes

The footnote mark is a hypertext link, and the text is a target. We separately number the footnotes sequentially through the text, separately from whatever labels the text assigns. Too hard to keep track of markers otherwise. If the raw forms \footnotemark and \footnotetext are used, force them to use un-hyper original.

1130\newcounter{Hfootnote}
1131\let\H@@footnotetext\@footnotetext
1132\let\H@@footnotemark\@footnotemark
1133\def\@xfootnotenext[#1]{%
1134 \begingroup
1135  \csname c@\@mpfn\endcsname #1\relax
1136  \unrestored@protected@xdef\@thefnmark{\thempfn}%
1137 \endgroup
1138 \H@@footnotetext}
1139\def\@xfootnotemark[#1]{%
1140 \begingroup
1141  \c@footnote #1\relax
1142  \unrestored@protected@xdef\@thefnmark{\thefootnote}%
1143 \endgroup
1144 \H@@footnotemark}
1145\let\H@@mpfootnotetext\@mpfootnotetext
1146\long\def\@mpfootnotetext#1{%
1147 \H@@mpfootnotetext{%
1148 \ifhy@nesting
1149 \hyper@@anchor{\@currentHref}{#1}%
1150 \else
1151 \hyper@@anchor{\@currentHref}{\relax}#1%

1152 \fi 1153 }% 1154}

1155\long\def\@footnotetext#1{%
1156 \H@@footnotetext{%
1157 \ifhy@nesting
1158 \hyper@@anchor{\@currentHref}{#1}%
1159 \else
1160 \hyper@@anchor{\@currentHref}{\relax}#1%

1161 \fi 1162 }% 1163}

Redefine \@footnotemark, borrowing its code (at the cost of getting out of sync with latex.ltx), to take advantage of its white space and hyphenation fudges. If we just overload it, we can get variant documents (the word before the footnote is treated differently).

Thanks to David Carlisle and Brian Ripley for confusing and helping me on this.

1164\def\@footnotemark{%
1165 \leavevmode
1166 \ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
1167 \H@refstepcounter{Hfootnote}%
1168 \hyper@makecurrent{Hfootnote}%
1169 \hyper@linkstart{link}{\@currentHref}%
1170 \@makefnmark
1171 \hyper@linkend
1172 \ifhmode\spacefactor\@x@sf\fi
1173 \relax

1174}

1175\def\realfootnote{\@ifnextchar[\@xfootnote{\stepcounter{\@mpfn}%
1176  \protected@xdef\@thefnmark{\thempfn}%
1177  \H@@footnotemark\H@@footnotetext}}

But the special footnotes in \maketitle are much too hard to deal with properly. Let them revert to plain behaviour.

1178\let\orig@maketitle\maketitle
1179\def\maketitle{%
1180 \let\H@@origfootnotemark\@footnotemark
1181 \let\H@@origfootnotetext\@footnotetext
1182 \let\@footnotemark\H@@footnotemark
1183 \let\@footnotetext\H@@footnotetext
1184 \orig@maketitle
1185 \ifx\@footnotemark\H@@footnotemark
1186 \let\@footnotemark\H@@origfootnotemark

1187 \fi

1188 \ifx\@footnotetext\H@@footnotetext
1189 \let\@footnotetext\H@@origfootnotetext

1190 \fi 1191}

1.12.3 Float captions

Make the float caption the hypertext anchor; curiously enough, we can’t just copy the definition of \@caption. Its all to do with expansion. It screws up. Sigh.

1192\def\caption{\H@refstepcounter\@captype \@dblarg{\@caption\@captype}}
1193\long\def\@caption#1[#2]#3{%
1194 \hyper@makecurrent{\@captype}%
1195 \par\addcontentsline{\csname
1196 ext@#1\endcsname}{#1}{\protect\numberline{\csname
1197 the#1\endcsname}{\ignorespaces #2}}\begingroup
1198  \@parboxrestore
1199  \normalsize
1200  \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces

If we cannot have nesting, the anchor is empty.

1201\ifhy@nesting
1202 \hyper@@anchor{\@currentHref}{#3}%

1203\else
1204 \hyper@@anchor{\@currentHref}{\relax}#3%

1205\fi

1206}\par
1207 \endgroup}

1.12.4 Bibliographic references

This is not very robust, since many styles redefine these things. The package used to redefine \@citex and the like; then we tried adding the hyperref call explicitly into the .aux file. Now we redefine \bibcite; this still breaks some citation packages so we have to work around them. But this remains extremely dangerous. Any or all of achemso, chapterbib, and drftcite may break.

However, lets make an attempt to get natbib right, because thats a powerful, important package. Patrick Daly (daly@linmpi.mpg.de) has provided hooks for us, so all we need to do is activate them.

1208\def\hyper@natlinkstart#1{%
1209 \hy@backout{#1}%
1210 \hyper@linkstart{cite}{cite.#1}%
1211 \def\hyper@nat@current{#1}%

1212}

1213\def\hyper@natlinkend{%
1214 \hyper@linkend

1215}

1216\def\hyper@natlinkbreak#1#2{\hyper@linkend#1\hyper@linkstart{cite}{cite.#2}}
1217\def\hyper@natanchorstart#1{%
1218  \hyper@anchorstart{cite.#1}%

1219}

1220\def\hyper@natanchorend{\hyper@anchorend}

Do not play games if we have natbib support.

1221\@ifundefined{NAT@parse}{%
1222\def\bibcite#1#2{%
1223 \@newl@bel{b}{#1}{\hyper@@link[cite]{}{cite.#1}{#2}}}%

\@BIBLABEL is working around a ‘feature’ of RevTEX.

1224\providecommand{\@BIBLABEL}{\@biblabel}%
1225\def\@lbibitem[#1]#2{%
1226 \@skiphyperreftrue
1227 \H@item[\hyper@anchorstart{cite.#2}%
1228 \@BIBLABEL{#1}\hyper@anchorend\hfill]%
1229 \@skiphyperreffalse
1230 \if@filesw{\let\protect\noexpand
1231 \immediate\write\@auxout{%
1232  \string\bibcite{#2}{#1}}}%

1233 \fi

1234 \ignorespaces

1235}%

Since \bibitem is doing its own labelling, call the raw version of \item, to avoid extra spurious labels

1236\def\@bibitem#1{%
1237 \@skiphyperreftrue\H@item\@skiphyperreffalse
1238 \hyper@anchorstart{cite.#1}\relax\hyper@anchorend
1239 \if@filesw {\let\protect\noexpand
1240 \immediate\write\@auxout{%
1241 \string\bibcite{#1}{\the\value{\@listctr}}}}%

1242 \fi

1243 \ignorespaces

1244}% 1245}{}

Revtex (bless its little heart) takes over \bibcite and looks at the result to measure something. Make this a hypertext link and it goes ape. Therefore, make an anodyne result first, call its business, then go back to the real thing.

1246\@ifclassloaded{revtex}{%
1247 \hyper@info{*** compatibility with revtex **** }%
1248 \def\revtex@checking#1#2{%
1249 \expandafter\let\expandafter\T@temp\csname b@#1\endcsname
1250 \expandafter\def\csname b@#1\endcsname{#2}%
1251 \@SetMaxRnhefLabel{#1}%
1252 \expandafter\let\csname b@#1\endcsname\T@temp

1253 }%

Tanmoy provided this replacement for CITEX. Lord knows what it does.

1254\@ifundefined{@CITE}{\def\@CITE{\@cite}}{}
1255\def\@CITEX[#1]#2{%
1256 \let\@citea\@empty
1257 \leavevmode\unskip$^{\scriptstyle
1258 \@CITE{\@for\@citeb:=#2\do
1259  {\@citea\def\@citea{,\penalty\@m\ }%
1260  \edef\@citeb{\expandafter\@firstofone\@citeb}%
1261  \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
1262  \@ifundefined{b@\@citeb}{\mbox{\reset@font\bfseries ?}%
1263  \G@refundefinedtrue
1264  \@latex@warning
1265  {Citation `\@citeb' on page \thepage \space undefined}}%
1266  {{\csname b@\@citeb\endcsname}}}}{#1}}$}

No, life is too short. I am not going to understand the Revtex \@collapse macro, I shall just restore the original behaviour of \@citex; sigh. This is SO vile.

1267\def\@citex[#1]#2{%
1268 \let\@citea\@empty
1269 \@cite{\@for\@citeb:=#2\do
1270  {\@citea\def\@citea{,\penalty\@m\ }%
1271  \edef\@citeb{\expandafter\@firstofone\@citeb}%
1272  \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
1273  \@ifundefined{b@\@citeb}{\mbox{\reset@font\bfseries ?}%
1274  \G@refundefinedtrue

1275  \@latex@warning
1276  {Citation `\@citeb' on page \thepage \space undefined}}%
1277  {\hbox{\csname b@\@citeb\endcsname}}}}{#1}}

1278}{}

Override Peter Williams’ Harvard package; we have to a) make each of the citation types into a link; b) make each citation write a backref entry, and c) kick off a backreference section for each bibliography entry.

1279\@ifpackageloaded{harvard}{%
1280 \hyper@info{*** compatibility with harvard **** }%
1281 \hy@raiselinksfalse
1282 \def\harvardcite#1#2#3#4{%
1283 \global\@namedef{HAR@fn@#1}{\hyper@@link[cite]{}{cite.#1}{#2}}%
1284 \global\@namedef{HAR@an@#1}{\hyper@@link[cite]{}{cite.#1}{#3}}%
1285 \global\@namedef{HAR@yr@#1}{\hyper@@link[cite]{}{cite.#1}{#4}}%
1286 \global\@namedef{HAR@df@#1}{\csname HAR@fn@#1\endcsname}%

1287 }%

1288 \def\HAR@citetoaux#1{%
1289 \if@filesw\immediate\write\@auxout{\string\citation{#1}}\fi%
1290 \ifhy@backref
1291  \ifx\@empty\@currentlabel\else
1292  \@bsphack
1293  \protected@write\@auxout{}%
1294  {\string\@writefile{brf}%
1295  {\string\backcite{#1}{{\@currentlabel}{\thepage}{\@currentHref}}}}%
1296  \@esphack

1297 \fi 1298 \fi 1299 }

1300 \def\harvarditem{\@ifnextchar[{\@harvarditem}{\@harvarditem[\null]}}
1301 \def\@harvarditem[#1]#2#3#4#5\par{%
1302 \item[]%
1303 \hyper@anchorstart{cite.#4}\relax\hyper@anchorend%
1304 \if@filesw{ \def\protect##1{\string ##1\space}%
1305 \ifthenelse{\equal{#1}{\null}}
1306 {\def\next{{#4}{#2}{#2}{#3}}}
1307 {\def\next{{#4}{#2}{#1}{#3}}}
1308 \immediate\write\@auxout{\string\harvardcite\codeof\next}%
1309 }\fi%
1310 \protect\hspace*{-\labelwidth}\protect\hspace*{-\labelsep}\ignorespaces%

1311 #5

1312 \ifhy@backref
1313 \newblock
1314 \backref{\csname br@#4\endcsname}%

1315 \fi

1316 \par

1317}% 1318}{}

1.12.5 Page numbers

Give every page an automatic number anchor. This involves, sigh, overloading L^{A}TEX’s output bits and pieces, which must be dangerous. This used to be \@shipoutsetup, now \@begindvi. We cannot even overload this, as it sets itself to null. SIGH.

1319\def\@begindvi{%
1320 \unvbox \@begindvibox
1321 \ifhy@pageanchor
1322 \@hyperfixhead
1323 \global\let \@begindvi \@hyperfixhead
1324 \else
1325 \global\let \@begindvi \@empty

1326 \fi 1327}

1328\def\pagenumbering#1{%
1329 \global\c@page \@ne \gdef\thepage{\csname @#1\endcsname
1330 \c@page}}

This is needed for some unremembered reason…

1331\let\HYPERPAGEANCHOR\hyperpageanchor

This where we supply a destination for each page. Test to see if there is some sort of

 header. The test used to be \expandafter\ifx\expandafter\@empty\H@old@thehead.
1332\providecommand\hyper@pagetransition{}
1333\def\@hyperfixhead{%
1334 \ifhy@plainpages
1335  \gdef\@foo{\hyper@@anchor{page.\arabic{page}}}%
1336 \else
1337  \gdef\@foo{\hyper@@anchor{page.\thepage}}%

1338 \fi

1339 \let\H@old@thehead\@thehead
1340 \if^\@thehead^\def\H@old@thehead{\hfil}\fi
1341 \def\@thehead{\@foo\relax\hyper@pagetransition\H@old@thehead}%
1342 \ifx\PDF@FinishDoc\@empty
1343 \else
1344 \PDF@FinishDoc
1345 \gdef\PDF@FinishDoc{}%

1346 \fi 1347}

1.12.6 Table of contents

TV Raman noticed that people who add arbitrary material into the TOC generate a bad or null link. We used to avoid that by checking if the current destination was empty; instead, generate an arbitrary anchor at this point, and link to it. A separate macro is used for the automatic uses of \addcontentsline in section headings. THIS DOES NOT WORK YET!!!!!

1348\def\toclevel@part{-1}
1349\def\toclevel@chapter{0}
1350\def\toclevel@section{1}

1351\def\toclevel@subsection{2}
1352\def\toclevel@subsubsection{3}
1353\def\toclevel@paragraph{4}
1354\def\toclevel@subparagraph{5}
1355\def\@nameoftoc{toc}
1356\newcount\OddToc
1357\def\addhyperlinkline#1#2{%
1358 \global\advance\OddToc by 1
1359 % If we're in vmode we want to revert to vmode
1360 \edef\@tempa{\ifvmode\vskip0pt\fi}%
1361 \hyper@@anchor{toc\the\OddToc}{\relax}\@tempa%
1362 \@writetorep{}{#2}{toc\the\OddToc}{\csname toclevel@#1\endcsname}%

1363}

1364\def\manual@addcontentsline#1#2#3{%
1365 \addhyperlinkline{#2}{#3}
1366 \addtocontents{#1}{\protect\contentsline{#2}{#3}{\thepage}{toc\the\OddToc}}%

1367}

1368\def\addcontentsline#1#2#3{%
1369 \ifx\@currentHref\@empty
1370 \hyper@warn{contentsline with no destination
1371  at line \the\inputlineno}\fi
1372 \addtocontents{#1}{\protect\contentsline{#2}{#3}{\thepage}{\@currentHref}}%

1373}

1374\def\contentsline#1#2#3#4{%
1375 \ifx\\#4\\%
1376 \csname l@#1\endcsname{#2}{#3}%
1377\else
1378 \ifhy@linktocpage
1379  \csname l@#1\endcsname{%
1380  {#2}}{\hyper@linkstart{link}{#4}{#3}\hyper@linkend}%
1381 \else
1382  \csname l@#1\endcsname{%
1383  \hyper@linkstart{link}{#4}{#2}\hyper@linkend}{#3}%

1384 \fi 1385\fi 1386}

1.12.7 New counters

The whole theorem business makes up new counters on the fly; we are going to intercept this. Sigh. Do it at the level where new counters are defined.

1387\let\H@definecounter\@definecounter
1388\def\@definecounter#1{%
1389 \H@definecounter{#1}%
1390 \expandafter\def\csname theH#1\endcsname        {\arabic{#1}}%

1391}

But what if they have used the optional argument to e.g. \newtheorem to determine when the numbering is reset? OK, we’ll trap that too.

1392\let\H@newctr\@newctr

1393\def\@newctr#1[#2]{%
1394 \H@newctr#1[#2]%
1395 \expandafter\def\csname theH#1\endcsname
1396  {\csname the#2\endcsname.\arabic{#1}}%

1397}

1.12.8 AMSL^{A}TEX compatibility

Oh, no, they don’t use anything as simple as \refstepcounter in the AMS! We need to intercept some low-level operations of theirs. Damned if we are going to try and work out what the hell they get up to. Just stick a label of ‘AMS’ on the front, and use the label they worked out. If that produces something invalid, I give up. They’ll change all the code again anyway, I expect.

1398\let\Hmake@df@tag@@\make@df@tag@@
1399\def\make@df@tag@@#1{%
1400 \Hmake@df@tag@@{#1}%
1401 \global\edef\@currentHref{AMS.\theequation}%

1402}

1403\let\H@seteqlabel\@seteqlabel
1404\def\@seteqlabel#1{%
1405 \H@seteqlabel{#1}%
1406 \global\edef\@currentHref{AMS.\theequation}%

1407}

This code I simply cannot remember what I was trying to achieve. The final result seems to do nothing anyway.

\let\H@tagform@\tagform@
\def\tagform@#1{%
  \maketag@@@{\hyper@@anchor{\@currentHref}%
  {(\ignorespaces#1\unskip)}}%
}
\def\eqref#1{\textup{\H@tagform@{\ref{#1}}}}

1.12.9 Included figures

Simply intercept the low level graphics package macro.

1408\ifhy@figures
1409 \let\hy@Gin@setfile\Gin@setfile
1410 \def\Gin@setfile#1#2#3{%
1411 \hyperimage{#3}{\hy@Gin@setfile{#1}{#2}{#3}}%

1412 } 1413\fi

1.13 hyperindex entries

Hyper-indexing works crudely, by forcing code onto the end of the index entry with the | feature; this puts a hyperlink around the printed page numbers. It will not proceed if the author has already used the | specifier for something like emboldening entries. That would make Makeindex fail (cannot have two | specifiers). The solution is for the author to use generic coding, and put in the requisite \hyperpage in his/her own macros along with the boldness.

This section is poor stuff; it’s open to all sorts of abuse. Sensible large projects will design their own indexing macros any bypass this.

1414\ifhy@hyperindex
1415 \def\@wrindex#1{\@@wrindex#1||\\}
1416 \def\@@wrindex#1|#2|#3\\{%
1417 \ifx\\#2\\%
1418 \protected@write\@indexfile{}%
1419  {\string\indexentry{#1|hyperpage}{\thepage}}%
1420 \else
1421 \protected@write\@indexfile{}%
1422  {\string\indexentry{#1|#2}{\thepage}}%

1423 \fi

1424 \endgroup
1425 \@esphack

1426} 1427\fi

This again is quite flaky, but allow for the common situation of a page range separated by en-rule. We split this into two different hyperlinked pages.

1428\def\hyperpage#1{\@hyperpage#1----\\}
1429\def\@hyperpage#1--#2--#3\\{%
1430 \ifx\\#2\\%
1431  \@commahyperpage{#1}%
1432 \else
1433 \hyperlink{page.#1}{#1}--\hyperlink{page.#2}{#2}%

1434 \fi 1435}

1436\def\@commahyperpage#1{\@@commahyperpage#1, ,\\}
1437\def\@@commahyperpage#1, #2,#3\\{%
1438 \ifx\\#2\\%
1439 \hyperlink{page.#1}{#1}%
1440 \else
1441 \hyperlink{page.#1}{#1}, \hyperlink{page.#2}{#2}%

1442 \fi 1443}

1.14 Compatibility with seminar slide package

1444\let\oldslide@heading\slide@heading
1445\def\slide@heading[#1]#2{%
1446 \@writetorep{\theslide}{#1}{slide.\theslide}{0}%
1447 \oldslide@heading[#1]{#2}%

1448}

1449\@ifundefined{listofslides}{}{%
1450 \def\l@slide#1#2#3{%
1451  \slide@undottedcline{\slidenumberline{#3}{\hyperlink{slide.#2}{#2}}}{}}%

1.15 Localized nullifying of package

Sometimes we just don’t want the wretched package interfering with us. Define an environment we can put in manually, or include in a style file, which stops the hypertext functions doing anything. This is used, for instance, in the Elsevier classes, to stop hyperref playing havoc in the front matter.

1453\def\NoHyper{%
1454  \def\hyper@link@[##1]##2##3##4{##4}%
1455  \def\hyper@@anchor##1{}%
1456  \global\let\hyper@livelink\hyper@link
1457  \gdef\hyper@link##1##2##3{##3}%
1458  \def\hyper@anchorstart##1{}%
1459  \let\hyper@anchorend\@empty
1460  \def\hyper@linkstart##1##2{}%
1461  \let\hyper@linkend\@empty
1462  \def\hyper@linkurl##1##2{##1}%
1463  \def\hyper@linkfile##1##2##3{##1}%
1464  \let\hy@backout\@gobble

1465}

1466\def\stop@hyper{%
1467  \def\hyper@link@[##1]##2##3##4{##4}%
1468  \let\hy@backout\@gobble
1469  \def\hyper@@anchor##1{}%
1470  \def\hyper@link##1##2##3{##3}%
1471  \def\hyper@anchorstart##1{}%
1472  \let\hyper@anchorend\@empty
1473  \def\hyper@linkstart##1##2{}%
1474  \let\hyper@linkend\@empty
1475  \def\hyper@linkurl##1##2{##1}%
1476  \def\hyper@linkfile##1##2##3{##1}%

1477}

1478\def\endNoHyper{%
1479  \global\let\hyper@link\hyper@livelink

1480}

1.16 The Mangling Of Aux and Toc Files

Some extra tests so that the hyperref package may be removed or added to a document without having to remove .aux and .toc files (this section is by David Carlisle) All the

 code is delayed to \begin{document}
1481\AtBeginDocument{%

First the code to deal with removing the hyperref package from a document.

Write some stuff into the aux file so if the next run is done without hyperref, then \contentsline and \newlabel are defined to cope with the extra arguments.

1482 \immediate\write\@auxout{%
1483  \string\ifx\string\hyper@anchor\string\@undefined^^J%

1484  \global\let\string\oldcontentsline\string\contentsline^^J%
1485  \gdef\string\contentsline\string#1\string#2\string#3\string#4{%
1486  \string\oldcontentsline{\string#1}{\string#2}{\string#3}}^^J%
1487  \global\let\string\oldnewlabel\string\newlabel^^J%
1488  \gdef\string\newlabel\string#1\string#2{%
1489  \string\newlabelxx{\string#1}\string#2}^^J%
1490  \gdef\string\newlabelxx%
1491  \string#1\string#2\string#3\string#4\string#5\string#6{%
1492  \string\oldnewlabel{\string#1}{{\string#2}{\string#3}}}^^J%

But the new aux file will be read again at the end, with the normal definitions expected, so better put things back as they were.

1493  \string\AtEndDocument{%
1494  \let\string\contentsline\string\oldcontentsline^^J%
1495  \let\string\newlabel\string\oldnewlabel}^^J%

If the document is being run with hyperref put this definition into the aux file, so we can spot it on the next run.

1496  \string\else^^J%
1497  \global\let\string\hyper@last\relax^^J%
1498  \string\fi^^J%

1499 }%

Now the code to deal with adding the hyperref package to a document with aux and toc written the standard way.

If hyperref was used last time, do nothing. If it was not used, or an old version of hyperref was used, don’t use that TOC at all but generate a warning. Not ideal, but better than failing with pre-5.0 hyperref TOCs.

1500 \ifx\hyper@last\@undefined
1501  \def\@starttoc#1{%
1502  \begingroup
1503  \makeatletter
1504  \IfFileExists{\jobname.#1}%
1505  {\hyper@warn{old #1 file detected, not used; run LaTeX again}}{}%
1506  \if@filesw
1507  \expandafter\newwrite\csname tf@#1\endcsname
1508b           \immediate\openout \csname tf@#1\endcsname \jobname.#1\relax

1509 \fi

1510  \@nobreakfalse
1511  \endgroup}%
1512  \def\newlabel#1#2{\@newl@bel r{#1}{#2{}{}{}{}}}
1513 \fi}

This breaks TeX4ht, so leave it to last. Emend \@setref to put out a hypertext link as well as its normal text (which is used as an anchor).

1514\@ifpackageloaded{tex4ht}{\endinput}{}
1515\let\real@setref\@setref
1516\let\real@ref\ref
1517\DeclareRobustCommand\ref{\@ifnextchar*{\@refstar}{\real@ref}}
1518\DeclareRobustCommand\pageref{\@ifnextchar*{\@pagerefstar}{\real@pageref}}
1519\def\@setref#1#2#3{% csname, extract group, refname

1520 \ifx#1\relax
1521 \protect\G@refundefinedtrue
1522 \nfss@text{\reset@font\bfseries ??}%
1523 \@latex@warning{Reference `#3' on page \thepage \space
1524  undefined}%
1525 \else
1526 \hyper@@link
1527  {\expandafter\@fifthoffive#1}%
1528  {\expandafter\@fourthoffive#1\@empty\@empty}%
1529  {\expandafter#2#1\@empty\@empty\null}%
1530 \fi}

Set \pageref to be a link. \realpageref is available for people who know about these things, which uses a copy of \@setref.

1531\def\real@pageref#1{\expandafter\@pagesetref\csname r@#1\endcsname
1532  \@secondoftwo{#1}}
1533\def\@pagesetref#1#2#3{% csname, extract macro, ref
1534 \ifx#1\relax
1535 \protect\G@refundefinedtrue
1536 \nfss@text{\reset@font\bfseries ??}%
1537 \@latex@warning{Reference `#3' on page \thepage \space
1538  undefined}%
1539 \else
1540 \protect\hyper@@link{\expandafter\@fifthoffive#1}%
1541  {page.\expandafter\@secondoffive#1}%
1542  {\expandafter\@secondoffive#1}%
1543 \fi}
1544\def\realpageref#1{\expandafter\real@setref
1545 \csname r@#1\endcsname\@secondoffive{#1}}

Now some extended referencing. \ref* is not linked, and \autoref prefixes with a tag based on the type.

1546\def\@refstar*#1{\expandafter\real@setref
1547  \csname r@#1\endcsname\@firstoffive{#1}}
1548\def\@pagerefstar*#1{\expandafter\real@setref
1549  \csname r@#1\endcsname\@secondoffive{#1}}
1550\DeclareRobustCommand\autoref[1]{%
1551  \expandafter\auto@setref\csname r@#1\endcsname\@firstoffive{#1}}
1552\def\auto@setref#1#2#3{% csname, extract group, refname
1553 \ifx#1\relax
1554 \protect\G@refundefinedtrue
1555 \nfss@text{\reset@font\bfseries ??}%
1556 \@latex@warning{Reference `#3' on page \thepage \space
1557  undefined}%
1558 \else
1559 \edef\@thisref{\expandafter\@fourthoffive#1\@empty\@empty}%
1560 \expandafter\test@reftype\@thisref\\%
1561 \hyper@@link
1562  {\expandafter\@fifthoffive#1}%
1563  {\expandafter\@fourthoffive#1\@empty\@empty}%

1564  {\@currentHtag\expandafter#2#1\@empty\@empty\null}%
1565 \fi}
1566\def\test@reftype#1.#2\\{%
1567 \@ifundefined{#1name}%
1568  {\def\@currentHtag{}%
1569  \@latex@warning{no tag name for #1 at \the\inputlineno}}%
1570  {\def\@currentHtag{\csname#1name\endcsname~}}%

1571}

1572\def\@currentHtag{}
1573\providecommand\figurename{Figure}
1574\providecommand\tablename{Table}
1575\providecommand\partname{Part}
1576\providecommand\appendixname{Appendix}
1577\providecommand\equationname{Equation}
1578\providecommand\Itemname{item}
1579\providecommand\chaptername{chapter}
1580\providecommand\sectionname{section}
1581\providecommand\subsectionname{subsection}
1582\providecommand\subsubsectionname{subsubsection}
1583\providecommand\paragraphname{paragraph}
1584\providecommand\FancyVerbLinename{line}
1585\providecommand\Hfootnotename{footnote}
1586\providecommand\AMSname{Equation}
1587\providecommand\theoremname{Theorem}

1588⟨/package⟩ 1589⟨∗pdftex⟩

2 Configuration files

2.1 pdftex

This driver is for Han The Thanh’s TEX variant which produces PDF directly. This has new primitives to do PDF things, which usually translate almost directly to PDF code, so there is a lot of flexibility which we do not at present harness.

First set up the default linking

1590\providecommand\@pdfview{XYZ}

First define the anchors:

1591\def\new@pdflink#1{%
1592⟨pdftexold⟩ \pdfdest name {#1!}\@pdfview\ifvmode\nobreak\fi

1593⟨∗!pdftexold⟩

1594 \ifhy@verbose\typeout{pdftex: define anchor #1}\fi
1595 \pdfdest name {#1}\@pdfview\ifvmode\nobreak\fi

1596⟨/!pdftexold⟩ 1597}

1598\let\pdf@endanchor\@empty

1599%

Now the links; the interesting part here is the set of attributes which define how the link looks. We probably want to add a border and color it, but there are other choices. This directly translates to PDF code, so consult the manual for how to change this. We will add an interface at some point.

1600\AtBeginDocument{%
1601 \ifhy@colorlinks
1602 \def\pdfBorderAttrs{/Border [0 0 0]}%

1603 \fi 1604}

1605\def\@pdfborder{0 0 1}%
1606\def\pdfBorderAttrs{/Border [\@pdfborder]}
1607\def\find@pdflink#1#2{%
1608 \leavevmode\pdfannotlink
1609 attr{\pdfBorderAttrs /H \@pdfhighlight /C [\CurrentBorderColor]}

1610⟨pdftexold⟩ goto name {#2!}% 1611⟨!pdftexold⟩ goto name {#2}%

1612 \hy@colorlink{\csname @#1color\endcsname}%

1613}

1614\def\close@pdflink{\hy@endcolorlink\pdfendlink}
1615\def\hyper@anchor#1{\new@pdflink{#1}\anchor@spot\pdf@endanchor}
1616\def\hyper@anchorstart#1{\new@pdflink{#1}\hy@activeanchortrue}
1617\def\hyper@anchorend{\pdf@endanchor\hy@activeanchorfalse}
1618\def\hyper@linkstart#1#2{%
1619 \edef\CurrentBorderColor{\csname @#1bordercolor\endcsname}%
1620 \find@pdflink{#1}{#2}}
1621\def\hyper@linkend{\close@pdflink}
1622\def\hyper@link#1#2#3{%
1623  \edef\CurrentBorderColor{\csname @#1bordercolor\endcsname}%
1624  \find@pdflink{#1}{#2}#3\close@pdflink

1625}

1626\def\CurrentBorderColor{\@linkbordercolor}
1627\def\hyper@linkurl#1#2{%
1628 \bgroup
1629 \hyper@chars
1630 \leavevmode\pdfannotlink
1631 attr{\pdfBorderAttrs /H \@pdfhighlight /C [\@urlbordercolor]}

1632⟨∗!pdftexold⟩

1633 user{/Subtype /Link
1634  /A <<
1635  /Type /Action
1636  /S /URI
1637  /URI (#2)
1638  >>}\hy@colorlink{\@urlcolor}#1%

1639⟨/!pdftexold⟩ 1640⟨∗pdftexold⟩

1641 user{/S /URI /URI (#2)}\hy@colorlink{\@urlcolor}#1%

1642⟨/pdftexold⟩

1643 \close@pdflink
1644 \egroup

1645}

1646\def\hyper@linkfile#1#2#3{% anchor text, filename, linkname
1647 \bgroup

1648 \leavevmode\pdfannotlink
1649 attr{\pdfBorderAttrs\space /H \@pdfhighlight\space /C [\@filebordercolor]}
1650 user {/Subtype /Link
1651  /A <<   /F (#2) /S /GoToR
1652  \ifhy@newwindow /NewWindow true \fi
1653  \ifx\\#3\\/D [0 \@pdfstartview] \else /D (#3)\fi
1654  \space>>}\hy@colorlink{\@filecolor}#1\close@pdflink
1655 \egroup

1656}

1657\ifx\pdftexversion\@undefined
1658 \def\@pdfproducer{pdfTeX}
1659\else
1660 \def\@pdfproducer{pdfTeX\the\pdftexversion.\pdftexrevision}

1661\fi 1662⟨∗!pdftexold⟩

1663\def\PDF@SetupDoc{%
1664 \ifx\@pdfpagescrop\@empty\else
1665  \edef\process@me{\pdfpagesattr={/CropBox [\@pdfpagescrop]}}%
1666  \process@me

1667 \fi

1668 \pdfcatalog {              % Catalog dictionary of PDF output.
1669  /PageMode \@pdfpagemode
1670  /URI << /Base (\@baseurl) >>
1671\ifhy@acrofour
1672 /PageLabels << /Nums [ 0 << /S /D /St \c@page\space >> ] >>

1673\fi 1674 }

1675\ifx\@pdfstartview\@empty
1676\else
1677 openaction goto page \@pdfstartpage {\@pdfstartview}%

1678\fi

1679\pdfcatalog{
1680/ViewerPreferences <<
1681 \ifhy@toolbar\else /HideToolbar true \fi
1682 \ifhy@menubar\else /HideMenubar true \fi
1683 \ifhy@windowui\else /HideWindowUI true \fi
1684 \ifhy@fitwindow /FitWindow true \fi
1685 \ifhy@centerwindow /CenterWindow true \fi

1686 >>

1687 \ifx\pdf@pagelayout\@empty\else/PageLayout /\pdf@pagelayout\space\fi

1688}% 1689}

1690\def\PDF@FinishDoc{
1691 \pdfinfo {
1692 /Author (\@pdfauthor)
1693 /Title (\@pdftitle)
1694 /Subject (\@pdfsubject)
1695 /Creator (\@pdfcreator)
1696 /Producer (\@pdfproducer)
1697 /Keywords (\@pdfkeywords)

1698 }% 1699} 1700⟨/!pdftexold⟩ 1701⟨∗pdftexold⟩

1702\def\PDF@FinishDoc{}
1703\def\PDF@SetupDoc{%
1704\edef\x@pdfcatalog{%
1705 pagemode {\@pdfpagemode}
1706 \ifx\@baseurl\@empty\else uri {\@baseurl} \fi}%
1707\edef\x@pdfinfo{%
1708 author {\@pdfauthor}
1709 title {\@pdftitle}
1710 subject {\@pdfsubject}
1711 keywords {\@pdfkeywords}
1712 \ifx\@pdfpagescrop\@empty\else
1713 \pdfpagesattr={/CropBox [\@pdfpagescrop]}

1714 \fi 1715}%

1716 \expandafter\pdfcatalog \x@pdfcatalog
1717 \expandafter\pdfinfo \x@pdfinfo

1718} 1719⟨/pdftexold⟩

1720\def\hyper@pagetransition{%
1721 \ifx\@pdfpagetransition\@empty
1722 \else
1723 \edef\@processme{%
1724\global\pdfpageattr{/Trans << /S /\@pdfpagetransition\space >>}}%
1725 \@processme

1726 \fi 1727}

Let us explicitly turn on PDF generation; they can reverse this decision in the document, but since we are emitting PDF links anyway, we must be in PDF mode.

1728\pdfoutput=1
1729\pdfcompresslevel=9
1730\AtBeginDocument{%
1731 \pdfpagewidth\paperwidth
1732 \pdfpageheight\paperheight

1733} 1734⟨∗!pdftexold⟩

1735\def\Acrobatmenu#1#2{%
1736 \leavevmode\pdfannotlink
1737 attr{\pdfBorderAttrs /H \@pdfhighlight /C [\@menubordercolor]}
1738 user{
1739  /Subtype /Link
1740  /A <<
1741  /S /Named /N /#1

1742 >>

1743  /H \@pdfhighlight
1744  }\hy@colorlink{\@menucolor}#2\close@pdflink

1746⟨/!pdftexold⟩ 1747⟨∗pdftexold⟩

1748\def\Acrobatmenu#1#2{%
1749 \leavevmode\pdfannotlink
1750 attr{\pdfBorderAttrs /H \@pdfhighlight /C [\@menubordercolor]}
1751 user{/S /Named /N /#1}\hy@colorlink{\@menucolor}#2\close@pdflink

1752} 1753⟨/pdftexold⟩ 1754⟨/pdftex⟩ 1755⟨∗hypertex⟩

2.2 hypertex

The HyperTEX specification (this is borrowed from an article by Arthur Smith) says that conformant viewers/translators must recognize the following set of \special commands:

href: html:<a href = "href_string">
name: html:<a name = "name_string">
end: html:</a>
image: html:<img src = "href_string">
base name: html:<base href = "href_string">

The href, name and end commands are used to do the basic hypertext operations of establishing links between sections of documents. The image command is intended (as with current html viewers) to place an image of arbitrary graphical format on the page in the current location. The base name command is be used to communicate to the dvi viewer the full (URL) location of the current document so that files specified by relative URL’s may be retrieved correctly.

The href and name commands must be paired with an end command later in the TEX file — the TEX commands between the two ends of a pair form an anchor in the document. In the case of an href command, the anchor is to be highlighted in the dvi viewer, and when clicked on will cause the scene to shift to the destination specified by href string. The anchor associated with a name command represents a possible location to which other hypertext links may refer, either as local references (of the form href="#name string" with the name string identical to the one in the name command) or as part of a URL (of the form URL#name string). Here href string is a valid URL or local identifier, while name string could be any string at all: the only caveat is that ‘"’ characters should be escaped with a backslash (\), and if it looks like a URL name it may cause problems.

1756\def\PDF@FinishDoc{}
1757\def\PDF@SetupDoc{%
1758 \ifx\@baseurl\@empty\else
1759 \special{html:<base href="\@baseurl">}%

1760 \fi

1762\def\hyper@anchor#1{%
1763 {\let\protect=\string\special{html:<A name=\hyper@quote #1\hyper@quote>}}%
1764 \hy@activeanchortrue
1765 \hy@colorlink{\@anchorcolor}\anchor@spot\hy@endcolorlink
1766 \special{html:</A>}%
1767 \hy@activeanchorfalse

1768}

1769\def\hyper@anchorstart#1{%
1770 {\hyper@chars\special{html:<A name=\hyper@quote#1\hyper@quote>}}%
1771 \hy@activeanchortrue

1772}

1773\def\hyper@anchorend{%
1774 \special{html:</A>}%
1775 \hy@activeanchorfalse

1776}

1777\def\@urltype{url}
1778\def\hyper@linkstart#1#2{%
1779 \hy@colorlink{\csname @#1color\endcsname}%
1780 \def\@tempa{#1}\ifx\@tempa\@urltype
1781  \special{html:<A href=\hyper@quote#2\hyper@quote>}%
1782 \else
1783 {\hyper@chars\special{html:<A href=\hyper@quote\##2\hyper@quote>}}%

1784 \fi 1785}

1786\def\hyper@linkend{%
1787 \special{html:</A>}%
1788 \hy@endcolorlink

1789}

1790\def\hyper@linkfile#1#2#3{%
1791 \hyper@linkurl{#1}{file:#2\ifx\\#3\\\else\##3\fi}%

1792}

1793\def\hyper@linkurl#1#2{%

If we want to raise up the final link \special, we need to get its height; ask me why L^{A}TEX constructs make this totally foul up, and make us revert to basic TEX. I do not know.

1794 \ifhy@raiselinks
1795 \setbox\@tempboxa=\hbox{#1}%
1796 \@linkdim\dp\@tempboxa
1797 \leavevmode\lower\@linkdim\hbox{%
1798  {\hyper@chars\special{html:<A href=\hyper@quote#2\hyper@quote>}}%

1799 }%

1800 \hy@colorlink{\@urlcolor}#1%
1801 \@linkdim\ht\@tempboxa

Because of the interaction with the dvihps processor, we have to subtract a little from the height. This is not clean, or checked. Check with Mark Doyle about what gives here. It may not be needed with the new dvips (Jan 1997).

1802 \advance\@linkdim by -6.5\p@
1803 \raise\@linkdim\hbox{\special{html:</A>}}%

1804 \hy@endcolorlink
1805 \else
1806 {\hyper@chars
1807 \special{html:<A href=\hyper@quote#2\hyper@quote>}%
1808 \hy@colorlink{\@urlcolor}#1\special{html:</A>}%
1809 \hy@endcolorlink}%

1810 \fi 1811}

1812\def\hyper@link#1#2#3{%
1813 \hyper@linkurl{#3}{\##2}%

1814}

1815\def\hyper@image#1#2{%
1816 {\hyper@chars
1817 \special{html:<img src=\hyper@quote#1\hyper@quote>}}}

1818⟨/hypertex⟩ 1819⟨∗dviwindo⟩

2.3 dviwindo

[This was developed by David Carlisle]. Within a file dviwindo hyperlinking is used, for external URL’s a call to \wwwbrowser is made. (You can define this command before or after loading the hyperref package if the default c:/netscape/netscape is not suitable) Dviwindo could in fact handle external links to dvi files on the same machine without calling a web browser, but that would mean parsing the URL to recognise such, and this is currently not done.

This was more or less blindly copied from the hypertex cfg. For dviwindo, L^{A}TEX must specify the size of the active area for links. For some hooks this information is available but for some, the start and end of the link are specified separately in which case a fixed size area of 10000000sp wide by \baselineskip high is used.

1820

1821\providecommand\wwwbrowser{c:\string\netscape\string\netscape}
1822\def\hyper@anchor#1{%
1823 {\let\protect=\string\special{mark:  #1}}%
1824 \hy@activeanchortrue
1825 \hy@colorlink{\@anchorcolor}\anchor@spot\hy@endcolorlink
1826 \hy@activeanchorfalse

1827}

1828\def\hyper@anchorstart#1{%
1829 \special{mark: #1}%
1830 \hy@activeanchortrue

1831}

1832\def\hyper@anchorend{%
1833 \hy@activeanchorfalse

1834}

1835\def\hyper@linkstart#1#2{%
1836 \hy@colorlink{\csname @#1color\endcsname}%
1837 \special{button:  10000000 \number\baselineskip \space
1838  #2}%

1840\def\hyper@linkend{%
1841 \hy@endcolorlink

1842}

1843\def\hyper@link#1#2#3{%
1844 \ifhy@raiselinks
1845 \setbox\@tempboxa=\hbox{#3}%
1846 \@linkdim\dp\@tempboxa
1847 \leavevmode\lower\@linkdim\hbox{%
1848 \special{button:  \number\wd\@tempboxa\space \number\ht\@tempboxa\space
1849  #2}%
1850 \hy@colorlink{\csname @#1color\endcsname}#3\hy@endcolorlink}%
1851 \@linkdim\ht\@tempboxa
1852 \advance\@linkdim by -6.5\p@
1853 \raise\@linkdim\hbox{}%
1854 \else
1855 \setbox\@tempboxa=\hbox{#3}%
1856 \special{button:  \number\wd\@tempboxa\space \number\ht\@tempboxa\space
1857  #2}%
1858 \hy@colorlink{\csname @#1color\endcsname}#3\hy@endcolorlink

1859 \fi 1860}

1861\def\hyper@linkurl#1#2{%
1862\bgroup\hyper@chars
1863 \ifhy@raiselinks
1864 \setbox\@tempboxa=\hbox{#1}%
1865 \@linkdim\dp\@tempboxa
1866 \leavevmode\lower\@linkdim\hbox{%
1867 \special{button:  \number\wd\@tempboxa\space \number\ht\@tempboxa\space
1868  launch: \wwwbrowser\space
1869  #2}%
1870 \hy@colorlink{\@urlcolor}#1\hy@endcolorlink}%
1871 \@linkdim\ht\@tempboxa
1872 \advance\@linkdim by -6.5\p@
1873 \raise\@linkdim\hbox{}%
1874 \else
1875 \setbox\@tempboxa=\hbox{#1}%
1876 \special{button:  \number\wd\@tempboxa\space \number\ht\@tempboxa\space
1877  launch: \wwwbrowser\space
1878  #2}%
1879 \hy@colorlink{\@urlcolor}#1\hy@endcolorlink

1880 \fi

1881\egroup

1882}

1883\def\hyper@linkfile#1#2#3{%
1884\bgroup\hyper@chars
1885 \ifhy@raiselinks
1886 \setbox\@tempboxa=\hbox{#1}%
1887 \@linkdim\dp\@tempboxa
1888 \leavevmode\lower\@linkdim\hbox{%

1889 \special{button:  \number\wd\@tempboxa\space \number\ht\@tempboxa\space
1890  #3,\space file: #2}%
1891 \hy@colorlink{\@filecolor}#1\hy@endcolorlink}%
1892 \@linkdim\ht\@tempboxa
1893 \advance\@linkdim by -6.5\p@
1894 \raise\@linkdim\hbox{}%
1895 \else
1896 \setbox\@tempboxa=\hbox{#1}%
1897 \special{button:  \number\wd\@tempboxa\space \number\ht\@tempboxa\space
1898  #3,\space file: #2}%
1899 \hy@colorlink{\@filecolor}#1\hy@endcolorlink

1900 \fi

1901\egroup

1902}

1903\def\@pdfproducer{dviwindo + Distiller}
1904\def\PDF@FinishDoc{
1905 \special{PDF: Keywords \@pdfkeywords}%
1906 \special{PDF: Title \@pdftitle}%
1907 \special{PDF: Creator \@pdfcreator}%
1908 \special{PDF: Author \@pdfauthor}%
1909 \special{PDF: Producer \@pdfproducer}%
1910 \special{PDF: Subject \@pdfsubject}%

1911}

1912\def\PDF@SetupDoc{
1913 \ifx\@baseurl\@empty\else
1914 \special{PDF: Base \@baseurl}%

1915 \fi

1916 \ifx\@pdfpagescrop\@empty\else
1917 \special{PDF: BBox \@pdfpagescrop}%

1918 \fi

1919 \pdfmark{pdfmark=/DOCVIEW,
1920 Page=\@pdfstartpage,
1921 View=\@pdfstartview,
1922 PageMode=\@pdfpagemode

1923 }

1924 \ifx\@pdfpagescrop\@empty\else
1925 \pdfmark{pdfmark=/PAGES,CropBox=\@pdfpagescrop}%

1926 \fi

1927 \pdfmark{pdfmark=/PUT,Raw={
1928 \string{Catalog\string} <<
1929 /ViewerPreferences <<
1930 \ifhy@toolbar\else /HideToolbar true \fi
1931 \ifhy@menubar\else /HideMenubar true \fi
1932 \ifhy@windowui\else /HideWindowUI true \fi
1933 \ifhy@fitwindow /FitWindow true \fi
1934 \ifhy@centerwindow /CenterWindow true \fi

1935 >>

1936 \ifx\pdf@pagelayout\@empty\else/PageLayout /\pdf@pagelayout\space\fi
1937 >>}}%

1938} 1939⟨/dviwindo⟩ 1940⟨∗dvipdfm⟩

Hyperref driver for dvipdfm dvi to PDF converter. Provided by Mark Wicks (mwicks@kettering.edu)

1941\newsavebox{\pdfm@box}
1942\def\@pdfm@mark#1{\special{pdf:#1}}
1943\def\@pdfm@dest#1{\@pdfm@mark{ dest (#1) [ @thispage /\@pdfview\space @xpos @ypos ]}}
1944\providecommand\@pdfview{XYZ}
1945\providecommand\@pdfborder{0 0 1}
1946\def\hyper@anchor#1{%
1947 \@pdfm@dest{#1}%

1948}

1949\def\pdfm@rect{width \the\wd\pdfm@box\space
1950 height \the\ht\pdfm@box\space
1951 depth \the\dp\pdfm@box}%
1952\def\hyper@anchorstart#1{%
1953 \hy@activeanchortrue
1954 \@pdfm@dest{#1}%

1955}

1956\def\hyper@anchorend{%
1957 \hy@activeanchorfalse

1958}

1959\def\hyper@linkstart#1#2{%
1960 \global\edef\hyper@currentanchor{#2}%
1961 \gdef\hyper@currentlinktype{#1}%
1962 \begin{lrbox}{\pdfm@box}%
1963 \hy@colorlink{\csname @#1color\endcsname}%

1964}

1965\def\hyper@linkend{%
1966 \hy@endcolorlink
1967 \end{lrbox}%
1968 \edef\@foo{\csname @\hyper@currentlinktype bordercolor\endcsname}%
1969 \mbox{\@pdfm@mark{ ann \pdfm@rect
1970 << /Type /Annot /Subtype
1971  /Link
1972  /Border [ \@pdfborder ]
1973  /C [ \@foo ]
1974  /A << /S /GoTo
1975  /D (\hyper@currentanchor)

1976>>

1977 >>}\usebox{\pdfm@box}}%

1978}

1979\def\hyper@link#1#2#3{%
1980 \sbox{\pdfm@box}{\hy@colorlink{\csname @#1color\endcsname}#3\hy@endcolorlink}%
1981 \edef\@foo{\csname @#1bordercolor\endcsname}%
1982 \mbox{\@pdfm@mark{ ann \pdfm@rect
1983 << /Type /Annot /Subtype /Link
1984  /Border [ \@pdfborder ]
1985  /C [ \@foo ]
1986  /A << /S /GoTo

1987  /D (#2)

1988>>

1989 >>}\usebox{\pdfm@box}}%

1990}

1991\def\hyper@linkfile#1#2#3{%
1992 \sbox{\pdfm@box}{\hy@colorlink{\@filecolor}#1\hy@endcolorlink}%
1993 \edef\@foo{\csname @#1bordercolor\endcsname}%
1994 \mbox{\@pdfm@mark{ ann \pdfm@rect
1995 << /Type /Annot /Subtype /Link
1996  /Border [ \@pdfborder ]
1997  /C [ \@filebordercolor ]
1998  /A << /S /GoToR
1999  /F (#2)
2000  /D \ifx\\#3\\[ 0 \@pdfstartview]\else(#3)\fi\space
2001 /NewWindow true

2002>>

2003 >>}\usebox{\pdfm@box}}%

2004}

2005\def\hyper@linkurl#1#2{%
2006 \sbox{\pdfm@box}{\hy@colorlink{\@urlcolor}#1\hy@endcolorlink}%
2007 \mbox{\@pdfm@mark{ ann \pdfm@rect
2008 << /Type /Annot /Subtype /Link
2009  /Border [ \@pdfborder ]
2010  /C [ \@urlbordercolor ]
2011  /A << /S /URI
2012  /URI (#2)

2013>>

2014 >>}\usebox{\pdfm@box}}%

2015}

2016\def\Acrobatmenu#1#2{%
2017 \sbox{\pdfm@box}{\hy@colorlink{\@menucolor}#2\hy@endcolorlink}%
2018 \mbox{\@pdfm@mark{ ann \pdfm@rect
2019 << /Type /Annot /Subtype /Link
2020  /A << /S /Named /N /#1 >>
2021  /Border [ \@pdfborder ]
2022  /C [ \@menubordercolor ]
2023 >>}\usebox{\pdfm@box}}%

2024}

2025\def\@pdfproducer{dvipdfm}
2026\def\PDF@FinishDoc{
2027\special{pdf: docinfo <<
2028 /Title (\@pdftitle)
2029 /Subject(\@pdfsubject)
2030 /Creator (\@pdfcreator)
2031 /Author (\@pdfauthor)
2032 /Producer (\@pdfproducer)
2033 /Keywords (\@pdfkeywords) >>}%

2034}

2035\def\PDF@SetupDoc{%
2036\special{pdf: docview <<

2037 /Page \@pdfstartpage\space
2038 /View \@pdfstartview\space
2039 /URI << /Base (\@baseurl) >>
2040 /PageMode \@pdfpagemode
2041 /ViewerPreferences <<
2042 \ifhy@toolbar\else /HideToolbar true \fi
2043 \ifhy@menubar\else /HideMenubar true \fi
2044 \ifhy@windowui\else /HideWindowUI true \fi
2045 \ifhy@fitwindow /FitWindow true \fi
2046 \ifhy@centerwindow /CenterWindow true \fi

2047 >>

2048 \ifx\pdf@pagelayout\@empty\else/PageLayout /\pdf@pagelayout\space\fi
2049 >>}%

2050}

2051\AtBeginDocument{%
2052 \ifhy@colorlinks
2053 \def\@pdfborder{0 0 0}%

2054 \fi 2055}

¡/dvipdfm¿ Hyperref drivers for VTeX typesetting system, provided by MicroPress, May 1998. They require VTeX version 6.02 or newer; see http://www.micropress-inc.com/ for details.

2056⟨∗hvtexhtml⟩

2057\RequirePackage{vtexhtml}
2058\newif\if@Localurl
2059\def\PDF@FinishDoc{}
2060\def\PDF@SetupDoc{%
2061 \ifx\@baseurl\@empty\else
2062 \special{!direct <base href="\@baseurl">}%

2063 \fi 2064}

2065\def\@urltype{url}
2066\def\hyper@link#1#2#3{%
2067 \leavevmode\special{!direct <a
2068  href=\hyper@quote\hyper@hash#2\hyper@quote>}#3\special{!direct </a>}%

2069}

2070\def\hyper@linkurl#1#2{%
2071 {\hyper@chars
2072 \leavevmode\MathBSuppress=1\relax
2073 \special{!direct <a href=\hyper@quote#2\hyper@quote>}%
2074 #1\MathBSuppress=0\relax\special{!direct </a>}}%

2075}

2076\def\hyper@linkfile#1#2#3{%
2077 \hyper@linkurl{#1}{file:#2\ifx\\#3\\\else\##3\fi}%

2078}

2079\def\hyper@linkstart#1#2{%
2080 \def\@tempa{#1}\ifx\@tempa\@urltype
2081  \@Localurltrue
2082  \special{!direct <A href=\hyper@quote#2\hyper@quote>}%

2083 \else
2084  \@Localurlfalse
2085  {\hyper@chars\special{!aref #2}}%

2086 \fi 2087}

2088\def\hyper@linkend{
2089 \if@Localurl
2090 \special{!endaref}%
2091 \else
2092 \special{!direct </a>}%

2093 \fi 2094}

2095\def\hyper@anchorstart#1{%
2096 {\hyper@chars\special{!aname #1}%
2097 \special{!direct <a name=\hyper@quote#1\hyper@quote>}}%
2098 \hy@activeanchortrue

2099}

2100\def\hyper@anchorend{\special{!direct </a>}\hy@activeanchorfalse}
2101\def\hyper@anchor#1{%
2102 {\let\protect=\string
2103 \leavevmode\special{!aname #1}%
2104 \special{!direct <a name=\hyper@quote #1\hyper@quote>}}%
2105 \hy@activeanchortrue
2106 \bgroup\anchor@spot\egroup
2107 \special{!direct </a>}%
2108 \hy@activeanchorfalse

2109}

2110\def\@Form[#1]{\typeout{Sorry, TeXpider does not yet support FORMs}}
2111\def\@endForm{}
2112\def\@Gauge[#1]#2#3#4{% parameters, label, minimum, maximum
2113 \typeout{Sorry, TeXpider does not yet support FORM gauges}%

2114}

2115\def\@TextField[#1]#2{% parameters, label
2116 \typeout{Sorry, TeXpider does not yet support FORM text fields}%

2117 }

2118\def\@CheckBox[#1]#2{% parameters, label
2119 \typeout{Sorry, TeXpider does not yet support FORM checkboxes}%

2120 }

2121\def\@ChoiceMenu[#1]#2#3{% parameters, label, choices
2122 \typeout{Sorry, TeXpider does not yet support FORM choice menus}%

2123}

2124\def\@PushButton[#1]#2{% parameters, label
2125 \typeout{Sorry, TeXpider does not yet support FORM pushbuttons}%

2126}

2127\def\@Reset[#1]#2{\typeout{Sorry, TeXpider does not yet support FORMs}}
2128\def\@Submit[#1]#2{\typeout{Sorry, TeXpider does not yet support FORMs}}

2129⟨/hvtexhtml⟩ 2130⟨∗hvtex⟩

2131\AtBeginDocument{%
2132 \ifhy@colorlinks

2133 \def\pdfBorderAttrs{/Border [0 0 0]}%

2134 \fi 2135}

2136\def\@pdfborder{0 0 1}%
2137\def\pdfBorderAttrs{/Border [\@pdfborder]}%
2138\def\CurrentBorderColor{\@linkbordercolor}
2139\def\hyper@anchor#1{%
2140 {\let\protect=\string\special{!aname #1;\@pdfview}}%
2141 \hy@activeanchortrue
2142 \hy@colorlink{\@anchorcolor}\anchor@spot\hy@endcolorlink
2143 \hy@activeanchorfalse

2144}

2145\def\hyper@anchorstart#1{%
2146 {\hyper@chars\special{!aname #1;\@pdfview}}%
2147 \hy@activeanchortrue

2148}

2149\def\hyper@anchorend{%
2150 \hy@activeanchorfalse

2151}

2152\def\@urltype{url}
2153\def\hyper@linkstart#1#2{%
2154 \hy@colorlink{\csname @#1color\endcsname}%
2155 \edef\CurrentBorderColor{\csname @#1bordercolor\endcsname}%
2156 \def\@tempa{#1}\ifx\@tempa\@urltype
2157 \special{!aref <u=/Type /Action /S /URI /URI (#2)>;a=<\pdfBorderAttrs \space /C [\CurrentBorderColor]>}%
2158 \else
2159 \special{!aref #2;a=<\pdfBorderAttrs\space /C [\CurrentBorderColor]>}%

2160 \fi 2161}

2162\def\hyper@linkend{%
2163 \special{!endaref}%
2164 \hy@endcolorlink

2165}

2166\def\hyper@linkfile#1#2#3{%
2167 \leavevmode
2168 \special{!aref <f=#2>#3;a=<\pdfBorderAttrs\space /C [\@filebordercolor]>}%
2169 \hy@colorlink{\@filecolor}#1\hy@endcolorlink
2170 \special{!endaref}%

2171}

2172\def\hyper@linkurl#1#2{%
2173 \bgroup
2174 \hyper@chars
2175 \leavevmode
2176 \special{!aref <u=/Type /Action /S /URI /URI (#2)>;a=<\pdfBorderAttrs\space /C [\@urlbordercolor]>}%
2177 \hy@colorlink{\@urlcolor}#1\hy@endcolorlink
2178 \special{!endaref}%
2179 \egroup

2180}

2181\def\hyper@link#1#2#3{%
2182 \edef\CurrentBorderColor{\csname @#1bordercolor\endcsname}%

2183 \leavevmode
2184 \special{!aref #2;a=<\pdfBorderAttrs\space /C [\CurrentBorderColor]>}%
2185 \hy@colorlink{\csname @#1color\endcsname}#3\hy@endcolorlink
2186 \special{!endaref}%

2187}

2188\def\hyper@image#1#2{%
2189 \hyper@linkurl{#2}{#1}}

2190

2191\def\Acrobatmenu#1#2{%
2192 \def\CurrentBorderColor{\@menubordercolor\endcsname}%
2193 \leavevmode
2194 \special{!aref <u=/S /Named /N /#1>;a=<\pdfBorderAttrs \space /C [\CurrentBorderColor]>}%
2195 \hy@colorlink{\@menucolor}#2\hy@endcolorlink\special{!endaref}%

2196} 2197%

2198\def\@pdfproducer{VTeX}
2199\def\PDF@SetupDoc{%
2200\ifx\@pdfpagescrop\@empty\else
2201\special{!pdfinfo b=<\@pdfpagescrop>}%

2202\fi

2203\special{!onopen Page\@pdfstartpage}%

2204}%

2205\def\PDF@FinishDoc{%
2206\special{!pdfinfo p=<\@pdfpagemode>}%
2207\special{!pdfinfo u=<\@baseurl>}%
2208\special{!pdfinfo a=<\@pdfauthor>}%
2209\special{!pdfinfo t=<\@pdftitle>}%
2210\special{!pdfinfo s=<\@pdfsubject>}%
2211\special{!pdfinfo c=<\@pdfcreator>}%
2212\special{!pdfinfo r=<\@pdfproducer>}%
2213\special{!pdfinfo k=<\@pdfkeywords>}%

2214} 2215⟨/hvtex⟩ 2216⟨∗pdfmark | dvipdf⟩

2.4 Direct pdfmark support (dvipdf and pdfmark)

2217\def\hyper@anchor#1{%
2218 {\pdfmark[\anchor@spot]{pdfmark=/DEST,linktype=anchor,View=/\@pdfview \@pdfviewparams,DestAnchor=#1}}%

2219} 2220⟨∗dvipdf⟩

2221\def\hyper@anchorstart#1{\hy@activeanchortrue}
2222\def\hyper@anchorend{\hy@activeanchorfalse}
2223\def\hyper@linkstart#1#2{%
2224 \hy@colorlink{\csname @#1color\endcsname}%
2225 \global\edef\hyper@currentanchor{#2}%

2226}

2227\def\hyper@linkend{%
2228\hy@endcolorlink

2230⟨/dvipdf⟩ 2231⟨∗pdfmark⟩

2232\@ifundefined{hyper@anchorstart}{}{\endinput}
2233\def\hyper@anchorstart#1{%
2234 \PSHyperAnchorStart
2235 \global\edef\hyper@currentanchor{#1}%
2236 \hy@activeanchortrue

2237}

2238\def\hyper@anchorend{%
2239 \PSHyperAnchorEnd
2240 \pdfmark{pdfmark=/DEST,linktype=anchor,View=/\@pdfview  \@pdfviewparams,
2241  DestAnchor=\hyper@currentanchor,
2242  Rect=\pdf@bbox}%
2243 \hy@activeanchorfalse

2244}

2245\def\hyper@linkstart#1#2{%
2246 \ifhy@breaklinks\else
2247  \leavevmode\hbox\bgroup

2248 \fi

2249 \hy@colorlink{\csname @#1color\endcsname}%
2250 \PSHyperLinkStart
2251 \global\edef\hyper@currentanchor{#2}%
2252 \gdef\hyper@currentlinktype{#1}%

2253}

2254\def\hyper@linkend{%
2255  \PSHyperLinkEnd
2256  \edef\@foo{\csname @\hyper@currentlinktype bordercolor\endcsname}%
2257  \pdfmark{pdfmark=/ANN,linktype=link,Subtype=/Link,
2258  Dest=\hyper@currentanchor,
2259  AcroHighlight=\@pdfhighlight,
2260  Border=\@pdfborder,Color=\@foo,Rect=\pdf@bbox}%
2261 \hy@endcolorlink
2262 \ifhy@breaklinks\else\egroup\fi

2263}

2264\def\hyper@pagetransition{%
2265 \ifx\@pdfpagetransition\@empty
2266 \else
2267 \pdfmark{pdfmark=/PUT,Raw={{ThisPage}
2268  << /Trans << /S /\@pdfpagetransition\space >> >>}}%

2269 \fi 2270} 2271⟨/pdfmark⟩

2272\def\hyper@image#1#2{%
2273 \hyper@linkurl{#2}{#1}}

2274Wha

2275\def\hyper@link#1#2#3{%
2276  \edef\@foo{\csname @#1bordercolor\endcsname}%
2277  \bgroup

2278⟨dvipdf⟩ \pdfmark[#3]{pdfmark=/LNK,{},linktype=#1,AcroHighlight=\@pdfhighlight,Border=\@pdfborder,Color=\@foo,Dest=#2}%
2279⟨pdfmarkbase⟩ \pdfmark[#3]{Color=\@foo,linktype=#1,AcroHighlight=\@pdfhighlight,Border=\@pdfborder,pdfmark=/ANN,Subtype=/Link,Dest=#2}%
2280  \egroup

2281}

2282\newtoks\pdf@docset
2283\def\@pdfproducer{dvips + Distiller}
2284\def\PDF@FinishDoc{%
2285 \pdfmark{pdfmark=/DOCINFO,
2286 Title=\@pdftitle,
2287 Subject=\@pdfsubject,
2288 Creator= \@pdfcreator,
2289 Author=\@pdfauthor,
2290 Producer= \@pdfproducer,
2291 Keywords=\@pdfkeywords

2292 }% 2293}

2294\def\PDF@SetupDoc{%
2295 \ifx\@baseurl\@empty\def\@dobaseurl{}\else
2296  \def\@dobaseurl{}%

2297 \fi

2298 \pdfmark{pdfmark=/DOCVIEW,
2299 Page=\@pdfstartpage,
2300 View=\@pdfstartview,
2301 URI={<< /Base (\@baseurl) >>},
2302 PageMode=\@pdfpagemode

2303 }

2304 \ifx\@pdfpagescrop\@empty\else
2305 \pdfmark{pdfmark=/PAGES,CropBox=\@pdfpagescrop}%

2306 \fi

2307 \pdfmark{pdfmark=/PUT,Raw={
2308 \string{Catalog\string} <<
2309 /ViewerPreferences <<
2310 \ifhy@toolbar\else /HideToolbar true \fi
2311 \ifhy@menubar\else /HideMenubar true \fi
2312 \ifhy@windowui\else /HideWindowUI true \fi
2313 \ifhy@fitwindow /FitWindow true \fi
2314 \ifhy@centerwindow /CenterWindow true \fi

2315 >>

2316 \ifx\pdf@pagelayout\@empty\else/PageLayout /\pdf@pagelayout\space\fi
2317 >>}}%

2318} 2319⟨/pdfmark | dvipdf⟩ 2320⟨∗pdfmarkbase | dvipdf⟩

We define a single macro, pdfmark, which uses the ‘keyval’ system to define the various allowable keys; these are exactly as listed in the pdfmark reference for Acrobat 3.0. The only addition is pdfmark which specifies the type of pdfmark to create (like ANN, LINK etc). The surrounding round and square brackets in the pdfmark commands are supplied, but you have to put in / characters as needed for the values.

2321\def\pdfmark{\@ifnextchar[{\pdfmark@}{\pdfmark@[]}}

2322\def\pdfmark@[#1]#2{%
2323  \edef\@processme{\noexpand\pdf@toks={ \the\pdf@defaulttoks}}%
2324  \@processme
2325  \let\pdf@type\relax
2326  \setkeys{PDF}{#2}%
2327  \ifx\pdf@type\relax
2328  \hyper@warn{no pdfmark type specified in #2!!}%
2329  \ifx\\#1\\\relax\else\pdf@rect{#1}\fi
2330  \else
2331  \ifx\\#1\\\relax
2332⟨pdfmarkbase⟩ \literalps@out{[\the\pdf@toks\space \pdf@type\space pdfmark}%
2333⟨dvipdf⟩ \literalps@out{/ANN >>}%
2334  \else
2335  \hy@colorlink{\@ifundefined{@\pdf@linktype color}%
2336  {\@linkcolor}%
2337  {\csname @\pdf@linktype color\endcsname}}%
2338  \pdf@rect{#1}%
2339⟨pdfmarkbase⟩ \literalps@out{[\the\pdf@toks\space \pdf@type\space pdfmark}%
2340⟨dvipdf⟩ \literalps@out{/ANN >>}%
2341  \hy@endcolorlink

2342 \fi 2343 \fi 2344}

The complicated bit is working out the right enclosing rectangle of some piece of TEX text, needed by the /Rect key. This solution originates with Toby Thain (tobyt@netspace.net.au).

2345\newsavebox{\pdf@box}
2346\def\pdf@rect#1{%
2347⟨dvipdf⟩ \literalps@out{/ANN \pdf@type \the\pdf@toks\space <<}#1
2348 \leavevmode
2349 \sbox\pdf@box{#1}%
2350 \dimen@\ht\pdf@box
2351 \leavevmode\lower\dp\pdf@box\hbox{\PSHyperRectStart}%

If the text has to be horizontal mode stuff then just unbox the saved box like this, which saves executing it twice, which can mess up counters etc (thanks DPC…).

2352 \ifhy@breaklinks\unhbox\else\box\fi\pdf@box

but if it can have multiple paragraphs you’d need one of these, but in that case the mea-

 sured box size would be wrong anyway. \ifhy@breaklinks#1\else\box\pdf@box\fi
 \ifhy@breaklinks{#1}\else\box\pdf@box\fi
2353 \raise\dimen@\hbox{\PSHyperRectEnd}%
2354 \pdf@addtoks{[\pdf@bbox]}{Rect}%

2355}

All the supplied material is stored in a token list; since I do not feel sure I quite understand these, things may not work as expected with expansion. We’ll have to experiment.

2356\newtoks\pdf@toks
2357\newtoks\pdf@defaulttoks
2358\pdf@defaulttoks={ }%
2359\def\pdf@addtoks#1#2{%
2360 \edef\@processme{\pdf@toks{\the\pdf@toks\space /#2 #1}}%

2361 \@processme

2362}

2363\def\pdf@addtoksx#1{%
2364 \edef\@processme{\pdf@toks{\the\pdf@toks\space #1}}%
2365 \@processme

2366}

2367\def\PDFdefaults#1{%
2368 \pdf@defaulttoks={#1}%

2369}

This is the list of allowed keys. See the Acrobat manual for an explanation.

2370% what is the type of pdfmark?
2371\define@key{PDF}{pdfmark}{\def\pdf@type{#1}}
2372% what is the link type?
2373\define@key{PDF}{linktype}{\def\pdf@linktype{#1}}
2374\def\pdf@linktype{link}
2375% parameter is a stream of PDF
2376\define@key{PDF}{Raw}{\pdf@addtoksx{#1}}
2377% parameter is a name
2378\define@key{PDF}{Action}{\pdf@addtoks{#1}{Action}}
2379% parameter is a array
2380\define@key{PDF}{Border}{\pdf@addtoks{[#1]}{Border}}
2381% parameter is a array
2382\define@key{PDF}{Color}{\pdf@addtoks{[#1]}{Color}}
2383% parameter is a string
2384\define@key{PDF}{Contents}{\pdf@addtoks{(#1)}{Contents}}
2385% parameter is a integer
2386\define@key{PDF}{Count}{\pdf@addtoks{#1}{Count}}
2387% parameter is a array
2388\define@key{PDF}{CropBox}{\pdf@addtoks{[#1]}{CropBox}}
2389% parameter is a string
2390\define@key{PDF}{DOSFile}{\pdf@addtoks{(#1)}{DOSFile}}
2391% parameter is a string or file
2392\define@key{PDF}{DataSource}{\pdf@addtoks{(#1)}{DataSource}}
2393% parameter is a destination
2394\define@key{PDF}{Dest}{\ifx\\#1\\\else\pdf@addtoks{/#1}{Dest}\fi}
2395\define@key{PDF}{DestAnchor}{\ifx\\#1\\\else
2396  \pdf@addtoks{/#1 }{Dest}\fi}
2397% parameter is a string
2398\define@key{PDF}{Dir}{\pdf@addtoks{(#1)}{Dir}}
2399% parameter is a string
2400\define@key{PDF}{File}{\pdf@addtoks{(#1)}{File}}
2401% parameter is a int
2402\define@key{PDF}{Flags}{\pdf@addtoks{#1}{Flags}}
2403% parameter is a name
2404\define@key{PDF}{AcroHighlight}{\pdf@addtoks{#1}{H}}
2405% parameter is a string
2406\define@key{PDF}{ID}{\pdf@addtoks{[#1]}{ID}}
2407% parameter is a string
2408\define@key{PDF}{MacFile}{\pdf@addtoks{(#1)}{MacFile}}

2409% parameter is a string
2410\define@key{PDF}{ModDate}{\pdf@addtoks{(#1)}{ModDate}}
2411% parameter is a string
2412\define@key{PDF}{Op}{\pdf@addtoks{(#1)}{Op}}
2413% parameter is a Boolean
2414\define@key{PDF}{Open}{\pdf@addtoks{#1}{Open}}
2415% parameter is a integer or name
2416\define@key{PDF}{Page}{\pdf@addtoks{#1}{Page}}
2417% parameter is a name
2418\define@key{PDF}{PageMode}{\pdf@addtoks{#1}{PageMode}}
2419% parameter is a string
2420\define@key{PDF}{Params}{\pdf@addtoks{(#1)}{Params}}
2421% parameter is a array
2422\define@key{PDF}{Rect}{\pdf@addtoks{[#1]}{Rect}}
2423% parameter is a integer
2424\define@key{PDF}{SrcPg}{\pdf@addtoks{#1}{SrcPg}}
2425% parameter is a name
2426⟨pdfmarkbase⟩\define@key{PDF}{Subtype}{\pdf@addtoks{#1}{Subtype}}
2427⟨dvipdf⟩\define@key{PDF}{Subtype}{\pdf@addtoks{#1}{}}
2428% parameter is a string
2429\define@key{PDF}{Title}{\pdf@addtoks{(#1)}{Title}}
2430% parameter is a string
2431\define@key{PDF}{Unix}{\pdf@addtoks{(#1)}{Unix}}
2432% parameter is a string
2433\define@key{PDF}{UnixFile}{\pdf@addtoks{(#1)}{UnixFile}}
2434% parameter is an array
2435\define@key{PDF}{View}{\pdf@addtoks{[#1]}{View}}
2436% parameter is a string
2437\define@key{PDF}{WinFile}{\pdf@addtoks{(#1)}{WinFile}}

These are the keys used in the DOCINFO section.

2438\define@key{PDF}{Author}{\pdf@addtoks{(#1)}{Author}}
2439\define@key{PDF}{CreationDate}{\pdf@addtoks{(#1)}{CreationDate}}
2440\define@key{PDF}{Creator}{\pdf@addtoks{(#1)}{Creator}}
2441\define@key{PDF}{Producer}{\pdf@addtoks{(#1)}{Producer}}
2442\define@key{PDF}{Subject}{\pdf@addtoks{(#1)}{Subject}}
2443\define@key{PDF}{Keywords}{\pdf@addtoks{(#1)}{Keywords}}
2444\define@key{PDF}{ModDate}{\pdf@addtoks{(#1)}{ModDate}}
2445\define@key{PDF}{Base}{\pdf@addtoks{(#1)}{Base}}
2446\define@key{PDF}{URI}{\pdf@addtoks{#1}{URI}}

2447⟨/pdfmarkbase | dvipdf⟩ 2448⟨∗pdfmark | dvipdf⟩

2449\def\Acrobatmenu#1#2{%
2450 \pdfmark[#2]{linktype=menu,pdfmark=/ANN,AcroHighlight=\@pdfhighlight,
2451  Border=\@pdfborder,Action=<< /Subtype /Named /N /#1 >>,Subtype=/Link}}

And now for some useful examples:

2452\def\PDFNextPage{\@ifnextchar[{\PDFNextPage@}{\PDFNextPage@[]}}
2453\def\PDFNextPage@[#1]#2{%
2454 \pdfmark[#2]{#1,Border=\@pdfborder,Color=.2 .1 .5,
2455 pdfmark=/ANN,Subtype=/Link,Page=/Next}}

2456\def\PDFPreviousPage{\@ifnextchar[{\PDFPreviousPage@}{\PDFPreviousPage@[]}}
2457\def\PDFPreviousPage@[#1]#2{%
2458 \pdfmark[#2]{#1,Border=\@pdfborder,Color=.4 .4 .1,
2459 pdfmark=/ANN,Subtype=/Link,Page=/Prev}}
2460\def\PDFOpen#1{%
2461 \pdfmark{#1,pdfmark=/DOCVIEW}%

2462}

This is not as simple as it looks; if we make the argument of this macro eg \pageref{foo} and expect it to expand to ‘3’, we need a special version of \pageref which does not produce ‘3 ’…. David Carlisle looked at this bit and provided the solution, as ever!

2463\def\PDFPage{\@ifnextchar[{\PDFPage@}{\PDFPage@[]}}
2464\def\PDFPage@[#1]#2#3{%
2465 \let\pageref\simple@pageref
2466 \pdfmark[#3]{#1,Page=#2,AcroHighlight=\@pdfhighlight,Border=\@pdfborder,
2467 Color=\@pagebordercolor,pdfmark=/ANN,Subtype=/Link}}
2468\def\simple@pageref#1{%
2469 \expandafter\ifx\csname r@#1\endcsname\relax

2470 0%

2471 \else
2472  \expandafter\expandafter\expandafter
2473  \@secondoffive\csname r@#1\endcsname
2474 \fi}

This will only work if you use Distiller 2.1 or higher.

2475\def\hyper@linkurl#1#2{%
2476 \bgroup\hyper@chars
2477⟨pdfmarkbase⟩ \pdfmark[#1]{pdfmark=/ANN,linktype=url,AcroHighlight=\@pdfhighlight,Border=\@pdfborder,Color=\@urlbordercolor,
2478⟨dvipdf⟩ \pdfmark[#1]{pdfmark=/LNK,linktype=url,AcroHighlight=\@pdfhighlight,Border=\@pdfborder,Color=\@urlbordercolor,
2479⟨pdfmarkbase⟩ Action={<< /Subtype /URI /URI (#2) >>},Subtype=/Link}%
2480⟨dvipdf⟩ Action=URI /URI (#2)}%
2481 \egroup

2482}

2483\def\hyper@linkfile#1#2#3{%
2484 \bgroup

2485⟨∗pdfmark⟩

2486\pdfmark[#1]{pdfmark=/ANN,Subtype=/Link,
2487 AcroHighlight=\@pdfhighlight,Border=\@pdfborder,
2488 linktype=file,Color=\@filebordercolor,
2489 Action=<<
2490  /S /GoToR
2491\ifhy@newwindow
2492  /NewWindow true

2493\fi

2494  /F (#2)
2495  /D \ifx\\#3\\[0 \@pdfstartview]\else(#3)\fi
2496  >>}%

2497⟨/pdfmark⟩ 2498⟨∗dvipdf⟩

2499\pdfmark[#1]{pdfmark=/LNK,linktype=file,
2500 AcroHighlight=\@pdfhighlight,Border=\@pdfborder,

2501 Color=\@filebordercolor,
2502 Action=<<
2503  /S /GoToR
2504\ifhy@newwindow
2505  /NewWindow true

2506\fi

2507  /F (#2)
2508  /D \ifx\\#3\\[0 \@pdfstartview]\else(#3)\fi
2509  >>}%

2510⟨/dvipdf⟩

2511 \egroup

2512} 2513⟨/pdfmark | dvipdf⟩

2.5 Driver-specific form support

2.5.1 pdfmarks

2514⟨∗pdfmark⟩

2515\long\def\@Form[#1]{%
2516\AtBeginDvi{\special{!
2517[ /_objdef {pdfDocEncoding}
2518 /type /dict
2519/OBJ pdfmark
2520[ {pdfDocEncoding}
2521 <</Type /Encoding
2522/Differences [ 24 /breve /caron /circumflex /dotaccent
2523/hungarumlaut /ogonek /ring /tilde 39 /quotesingle 96 /grave 128
2524/bullet /dagger /daggerdbl /ellipsis /emdash /endash /florin /fraction
2525/guilsinglleft /guilsinglright /minus /perthousand /quotedblbase
2526/quotedblleft /quotedblright /quoteleft /quoteright /quotesinglbase
2527/trademark /fi /fl /Lslash /OE /Scaron /Ydieresis /Zcaron /dotlessi
2528/lslash /oe /scaron /zcaron 164 /currency 166 /brokenbar 168 /dieresis
2529/copyright /ordfeminine 172 /logicalnot /.notdef /registered /macron
2530/degree /plusminus /twosuperior /threesuperior /acute /mu 183
2531/periodcentered /cedilla /onesuperior /ordmasculine 188 /onequarter
2532/onehalf /threequarters 192 /Agrave /Aacute /Acircumflex /Atilde
2533/Adieresis /Aring /AE /Ccedilla /Egrave /Eacute /Ecircumflex
2534/Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde
2535/Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash
2536/Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /germandbls
2537/agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla
2538/egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex
2539/idieresis /eth /ntilde /ograve /oacute /ocircumflex /otilde
2540/odieresis /divide /oslash /ugrave /uacute /ucircumflex /udieresis
2541/yacute /thorn /ydieresis ]

2542>>

2543/PUT pdfmark
2544[ /_objdef {ZaDb}
2545 /type /dict
2546/OBJ pdfmark

2547[ {ZaDb}

2548 <<

2549 /Type /Font
2550 /Subtype /Type1
2551 /Name /ZaDb
2552 /BaseFont /ZapfDingbats

2553 >>

2554/PUT pdfmark
2555[ /_objdef {Helv}
2556 /type /dict
2557/OBJ pdfmark
2558[ {Helv}

2559 <<

2560 /Type /Font
2561 /Subtype /Type1
2562 /Name /Helv
2563 /BaseFont /Helvetica
2564 /Encoding {pdfDocEncoding}

2565 >>

2566/PUT pdfmark
2567[ /_objdef {aform}
2568 /type /dict
2569/OBJ pdfmark
2570[ /_objdef {afields}
2571 /type /array
2572/OBJ pdfmark
2573[/BBox [0 0 100 100] /_objdef {Check} /BP pdfmark
25741 0 0 setrgbcolor /ZapfDingbats 80 selectfont 20 20 moveto (4) show
2575[/EP pdfmark
2576[/BBox [0 0 100 100] /_objdef {Cross} /BP pdfmark
25771 0 0 setrgbcolor /ZapfDingbats 80 selectfont 20 20 moveto (8) show
2578[/EP pdfmark
2579[/BBox [0 0 250 100] /_objdef {Submit} /BP pdfmark 0.6 setgray 0 0 250
2580100 rectfill 1 setgray 2 2 moveto 2 98 lineto 248 98 lineto 246 96
2581lineto 4 96 lineto 4 4 lineto fill 0.34 setgray 248 98 moveto 248 2
2582lineto 2 2 lineto 4 4 lineto 246 4 lineto 246 96 lineto fill
2583/Helvetica 76 selectfont 0 setgray 8 22.5 moveto (Submit) show
2584[/EP pdfmark
2585[/BBox [0 0 250 100] /_objdef {SubmitP} /BP pdfmark 0.6 setgray 0 0
2586250 100 rectfill 0.34 setgray 2 2 moveto 2 98 lineto 248 98 lineto 246
258796 lineto 4 96 lineto 4 4 lineto fill 1 setgray 248 98 moveto 248 2
2588lineto 2 2 lineto 4 4 lineto 246 4 lineto 246 96 lineto fill
2589/Helvetica 76 selectfont 0 setgray 10 20.5 moveto (Submit) show
2590[/EP pdfmark
2591[ {aform}

2592 <<

2593  /Fields {afields}
2594  /DR << /Font << /ZaDb {ZaDb} /Helv {Helv} >> >>
2595  /DA (/Helv 10 Tf 0 g )
2596  /NeedAppearances true

2597 >>

2598/PUT pdfmark
2599[ \string{Catalog\string}

2600 <<

2601  /AcroForm {aform}

2602 >>

2603/PUT pdfmark

2604}}%

2605 \setkeys{Form}{#1}%

2606}

2607\def\@endForm{}
2608\def\@Gauge[#1]#2#3#4{% parameters, label, minimum, maximum
2609 \typeout{Sorry, pdfmark drivers do not support FORM gauges}%

2610}

2611\def\@TextField[#1]#2{% parameters, label
2612 \def\Fld@name{#2}%
2613 \def\Fld@default{}%
2614 \let\Fld@value\@empty
2615 \def\Fld@width{\DefaultWidthofText}%
2616 \def\Fld@height{\DefaultHeightofText}%
2617 \bgroup
2618 \Field@toks={ }%
2619 \setkeys{Field}{#1}%
2620 \ifFld@hidden\def\Fld@width{1sp}\fi
2621 \ifx\Fld@value\@empty\def\Fld@value{\Fld@default}\fi
2622 \ifFld@multiline
2623 \def\Fld@height{4\DefaultHeightofText}%

2624 \fi

2625 \LayoutTextField{#2}{%
2626 \pdfmark[\MakeTextField{\Fld@width}{\Fld@height}]{%
2627 pdfmark=/ANN,Raw={\PDFForm@Text}}}%
2628 \egroup

2629}

2630\def\@ChoiceMenu[#1]#2#3{% parameters, label, choices
2631 \def\Fld@name{#2}%
2632 \def\Fld@default{}%
2633 \def\Fld@width{\DefaultWidthofChoiceMenu}%
2634 \def\Fld@height{\DefaultHeightofChoiceMenu}%
2635 \bgroup
2636 \Fld@menulength=0
2637 \@tempdima\z@
2638 \@for\@curropt:=#3\do{
2639  \expandafter\Fld@checkequals\@curropt==\\%
2640  \advance\Fld@menulength by 1
2641  \settowidth{\@tempdimb}{\@currDisplay}%
2642  \ifdim\@tempdimb>\@tempdima\@tempdima\@tempdimb\fi

2643 }%

2644 \advance\@tempdima by 15\p@
2645 \Field@toks={ }%
2646 \setkeys{Field}{#1}%

2647 \ifFld@hidden\def\Fld@width{1sp}\fi
2648 \LayoutChoiceField{#2}{%
2649 \ifFld@radio
2650 \@@Radio{#3}%
2651 \else

2652 {%

2653 \ifdim\Fld@width<\@tempdima
2654  \ifdim\@tempdima<1cm\@tempdima1cm\fi
2655  \edef\Fld@width{\the\@tempdima}%

2656 \fi

2657 \def\Fld@flags{}%
2658 \ifFld@combo\def\Fld@flags{/Ff 917504}\fi
2659 \ifFld@popdown\def\Fld@flags{/Ff 131072}\fi
2660 \ifx\Fld@flags\@empty
2661  \@tempdima=\the\Fld@menulength\Fld@charsize
2662  \advance\@tempdima by 2\Fld@borderwidth bp
2663  \edef\Fld@height{\the\@tempdima}%

2664 \fi

2665 \@@Listbox{#3}%

2666 }}% 2667 \fi

2668 \egroup

2669}

2670\def\@@Radio#1{%
2671 \Fld@listcount=0
2672 \@for\@curropt:=#1\do{%
2673 \expandafter\Fld@checkequals\@curropt==\\%
2674 \advance\Fld@listcount by 1
2675 \@currDisplay\space\pdfmark[\MakeRadioField{\Fld@width}{\Fld@height}]{
2676 pdfmark=/ANN,Raw={\PDFForm@Radio
2677  /AP <<
2678  /N <<
2679  /\@currValue\space {Check}

2680 >> 2681 >>

2682 }} }% deliberate space between radio buttons

2683}

2684\newcount\Fld@listcount
2685\def\@@Listbox#1{%
2686 \Choice@toks={ }%
2687 \Fld@listcount=0
2688 \@for\@curropt:=#1\do{%
2689 \expandafter\Fld@checkequals\@curropt==\\%
2690 \advance\Fld@listcount by 1
2691 \edef\@processme{%
2692  \Choice@toks{\the\Choice@toks [(\@currValue) (\@currDisplay)]}%
2693 }\@processme

2694 }%

2695 \pdfmark[\MakeChoiceField{\Fld@width}{\Fld@height}]{
2696 pdfmark=/ANN,Raw={\PDFForm@List}}%

2698\def\@PushButton[#1]#2{% parameters, label
2699 \def\Fld@name{#2}%
2700 \bgroup
2701 \Field@toks={ }%
2702 \setkeys{Field}{#1}%
2703 \ifFld@hidden\def\Fld@width{1sp}\fi
2704 \LayoutPushButtonField{%
2705 \pdfmark[\MakeButtonField{#2}]{
2706 pdfmark=/ANN,Raw={
2707  \PDFForm@Push
2708}}}%
2709 \egroup

2710}

2711\def\@Submit[#1]#2{%
2712 \Field@toks={ }%
2713 \def\Fld@width{\DefaultWidthofSubmit}%
2714 \def\Fld@height{\DefaultHeightofSubmit}%
2715 \bgroup
2716 \def\Fld@name{Submit}%
2717 \setkeys{Field}{#1}%
2718 \ifFld@hidden\def\Fld@width{1sp}\fi
2719 \pdfmark[\MakeButtonField{#2}]{
2720 pdfmark=/ANN,Raw={\PDFForm@Submit
2721  /AP << /N {Submit} /D {SubmitP} >>

2722}}%

2723\egroup

2724}

2725\def\@Reset[#1]#2{%
2726 \Field@toks={ }%
2727 \def\Fld@width{\DefaultWidthofReset}%
2728 \def\Fld@height{\DefaultHeightofReset}%
2729 \bgroup
2730 \def\Fld@name{Reset}%
2731 \setkeys{Field}{#1}%
2732 \ifFld@hidden\def\Fld@width{1sp}\fi
2733 \pdfmark[\MakeButtonField{#2}]{%
2734 pdfmark=/ANN,Raw={\PDFForm@Reset}}%
2735 \egroup

2736}

2737\def\@CheckBox[#1]#2{% parameters, label
2738 \def\Fld@name{#2}%
2739 \def\Fld@default{0}%
2740 \bgroup
2741 \def\Fld@width{\DefaultWidthofCheckBox}%
2742 \def\Fld@height{\DefaultHeightofCheckBox}%
2743 \Field@toks={ }%
2744 \setkeys{Field}{#1}%
2745 \ifFld@hidden\def\Fld@width{1sp}\fi
2746 \LayoutCheckField{#2}{%

2747 \pdfmark[\MakeCheckField{\Fld@width}{\Fld@height}]{%
2748 pdfmark=/ANN,Raw={\PDFForm@Check}}}%
2749\egroup

2750} 2751⟨/pdfmark⟩

2.5.2 dvipdf

2752⟨∗dvipdf⟩

2753\def\@Form[#1]{\typeout{Sorry, I do not support FORMs}}
2754\def\@endForm{}
2755\def\@Gauge[#1]#2#3#4{% parameters, label, minimum, maximum
2756 \typeout{Sorry, dvipdf does not support FORM gauges}%

2757}

2758\def\@TextField[#1]#2{% parameters, label
2759 \typeout{Sorry, dvipdf does not support FORM text fields}%

2760 }

2761\def\@CheckBox[#1]#2{% parameters, label
2762 \typeout{Sorry, dvipdf does not support FORM checkboxes}%

2763 }

2764\def\@ChoiceMenu[#1]#2#3{% parameters, label, choices
2765 \typeout{Sorry, dvipdf does not support FORM choice menus}%

2766}

2767\def\@PushButton[#1]#2{% parameters, label
2768 \typeout{Sorry, dvipdf does not support FORM pushbuttons}%

2769}

2770\def\@Reset[#1]#2{\typeout{Sorry, dvipdf does not support FORMs}}
2771\def\@Submit[#1]#2{\typeout{Sorry, dvipdf does not support FORMs}}

2772⟨/dvipdf⟩

2.5.3 HyperTeX

2773⟨∗hypertex⟩

2774\def\@Form[#1]{\typeout{Sorry, HyperTeX does not support FORMs}}
2775\def\@endForm{}
2776\def\@Gauge[#1]#2#3#4{% parameters, label, minimum, maximum
2777 \typeout{Sorry, HyperTeX does not support FORM gauges}%

2778}

2779\def\@TextField[#1]#2{% parameters, label
2780 \typeout{Sorry, HyperTeX does not support FORM text fields}%

2781 }

2782\def\@CheckBox[#1]#2{% parameters, label
2783 \typeout{Sorry, HyperTeX does not support FORM checkboxes}%

2784 }

2785\def\@ChoiceMenu[#1]#2#3{% parameters, label, choices
2786 \typeout{Sorry, HyperTeX does not support FORM choice menus}%

2787}

2788\def\@PushButton[#1]#2{% parameters, label
2789 \typeout{Sorry, HyperTeX does not support FORM pushbuttons}%

2790}

2791\def\@Reset[#1]#2{\typeout{Sorry, HyperTeX does not support FORMs}}
2792\def\@Submit[#1]#2{\typeout{Sorry, HyperTeX does not support FORMs}}

2793⟨/hypertex⟩

2.5.4 TeX4ht

2794⟨∗tex4ht⟩

2795\def\@Form[#1]{%
2796 \setkeys{Form}{#1}%
2797 \HCode{<form action="\Form@action" method="\Form@method">}%

2798}

2799\def\@endForm{\HCode{</form>}}
2800\def\@Gauge[#1]#2#3#4{% parameters, label, minimum, maximum
2801 \typeout{Sorry, TeX4ht does not support gauges}%

2802}

2803\def\@TextField[#1]#2{% parameters, label
2804 \let\reserved@a\@empty
2805 \def\Fld@name{#2}%
2806 \def\Fld@default{}%
2807 \bgroup
2808 \Field@toks={ }%
2809 \setkeys{Field}{#1}%
2810 \HCode{<label for="\Fld@name">#2</label>}%
2811 \ifFld@password
2812 \@@PasswordField
2813 \else
2814 \@@TextField

2815 \fi

2816 \egroup

2817}

2818\def\@@PasswordField{%
2819 \HCode{<input type="password"
2820 id="\Fld@name"
2821 name="\Fld@name"
2822 \ifFld@hidden type="hidden"\fi
2823 value="\Fld@default" \the\Field@toks>}%

2824}

2825

2826\def\@@TextField{%
2827 \ifFld@multiline
2828 \HCode{<textarea
2829 \ifFld@readonly readonly \fi
2830 id="\Fld@name"
2831 name="\Fld@name"
2832 \ifFld@hidden type="hidden"\fi
2833 \the\Field@toks>}%
2834 \Fld@default
2835 \HCode{</textarea>}%
2836 \else
2837 \HCode{<input type="textbox"
2838 \ifFld@readonly readonly \fi
2839 id="\Fld@name"
2840 name="\Fld@name"

2841 \ifFld@hidden type="hidden"\fi
2842 value="\Fld@default" \the\Field@toks>

2843 }% 2844 \fi 2845}

2846\def\@ChoiceMenu[#1]#2#3{% parameters, label, choices
2847 \def\Fld@name{#2}%
2848 \def\Fld@default{}%
2849 \let\reserved@a\relax
2850 \bgroup
2851 \expandafter\Fld@findlength#3\\
2852 \Field@toks={ }%
2853 \setkeys{Field}{#1}%

2854 #2%

2855 \ifFld@radio
2856 \expandafter\@@Radio#3\\%
2857 \else
2858 \expandafter\@@Menu#3\\%

2859 \fi

2860 \egroup

2861}

2862\def\Fld@findlength#1\\{%
2863 \Fld@menulength=0%
2864 \@for\@curropt:=#1\do{\advance\Fld@menulength by 1}

2865}

2866\def\@@Menu#1\\{%
2867 \HCode{<select size="\the\Fld@menulength"
2868 name="\Fld@name"  \the\Field@toks>}%
2869 \@for\@curropt:=#1\do{
2870 \expandafter\Fld@checkequals\@curropt==\\%
2871 \HCode{<option
2872 \ifx\@curropt\Fld@default selected \fi
2873  value="\@currValue">\@currDisplay</option>}%

2874 }%

2875 \HCode{</select>}%

2876}

2877\def\@@Radio#1\\{%
2878 \@for\@curropt:=#1\do{%
2879 \expandafter\Fld@checkequals\@curropt==\\%
2880 \HCode{<input type="radio"
2881 \ifx\@curropt\Fld@default checked \fi
2882 name="\Fld@name"
2883 value="\@currValue" \the\Field@toks>}\@currDisplay}%

2884}

2885\def\@PushButton[#1]#2{% parameters, label
2886 \def\Fld@name{#2}%
2887 \bgroup
2888 \Field@toks={ }%
2889 \setkeys{Field}{#1}%
2890 \HCode{<input type="button"

2891 name="\Fld@name"
2892 value="#2"  \the\Field@toks>}%
2893 \HCode{</button>}%
2894 \egroup

2895}

2896\def\@Submit[#1]#2{%
2897 \HCode{<button type="submit">#2</button>}%

2898}

2899\def\@Reset[#1]#2{%
2900 \HCode{<button type="reset">#2</button>}%

2901}

2902\def\@CheckBox[#1]#2{% parameters, label
2903 \let\reserved@a\@empty
2904 \def\Fld@name{#2}%
2905 \def\Fld@default{0}%
2906 \bgroup
2907 \Field@toks={ }%
2908 \setkeys{Field}{#1}%
2909 \HCode{<input type="checkbox"
2910 \ifFld@checked checked \fi
2911 \ifFld@disabled disabled \fi
2912 \ifFld@readonly readonly \fi
2913 name="\Fld@name"
2914 \ifFld@hidden type="hidden"\fi
2915 value="\Fld@default" \the\Field@toks>#2}%
2916 \egroup

2917} 2918⟨/tex4ht⟩

2.5.5 pdfTeX

2919⟨∗pdftex⟩

2920\def\@Gauge[#1]#2#3#4{% parameters, label, minimum, maximum
2921 \typeout{Sorry, pdftex does not support FORM gauges}%

2922}

2923\RequirePackage{pifont}%
2924\def\MakeFieldObject#1#2{\setbox0=\hbox{#1}%
2925 \pdfform0%
2926 \expandafter\edef\csname #2Object\endcsname{\the\pdflastform\space 0 R}%
2927 \hbox to 0pt{\hskip-\maxdimen{\pdfrefform \the\pdflastform}}%

2928}%

2929\def\@Form[#1]{%
2930 \@ifundefined{textcolor}{\let\textcolor\@gobble}{}
2931 \setkeys{Form}{#1}%
2932 \pdfcatalog{/AcroForm \OBJ@acroform\space 0 R}%
2933 \MakeFieldObject{\ding{123}}{Ding}%
2934 \MakeFieldObject{\fbox{\textcolor{yellow}{\textsf{Submit}}}}{Submit}%
2935 \MakeFieldObject{\fbox{\textcolor{yellow}{\textsf{SubmitP}}}}{SubmitP}%

2936}

2937\def\@endForm{}
2938\def\@Gauge[#1]#2#3#4{% parameters, label, minimum, maximum

2939 \typeout{Sorry, pdfmark drivers do not support FORM gauges}%

2940}

2941\def\@TextField[#1]#2{% parameters, label
2942 \def\Fld@name{#2}%
2943 \def\Fld@default{}%
2944 \let\Fld@value\@empty
2945 \def\Fld@width{\DefaultWidthofText}%
2946 \def\Fld@height{\DefaultHeightofText}%
2947 \bgroup
2948 \Field@toks={ }%
2949 \setkeys{Field}{#1}%
2950 \ifFld@hidden\def\Fld@width{1sp}\fi
2951 \ifx\Fld@value\@empty\def\Fld@value{\Fld@default}\fi
2952 \ifFld@multiline
2953 \def\Fld@height{4\DefaultHeightofText}%

2954 \fi

2955 \LayoutTextField{#2}{%
2956 \pdfannotlink user {\PDFForm@Text}%
2957 \MakeTextField{\Fld@width}{\Fld@height}\pdfendlink}%
2958\egroup

2959}

2960\def\@ChoiceMenu[#1]#2#3{% parameters, label, choices
2961 \def\Fld@name{#2}%
2962 \def\Fld@default{}%
2963 \def\Fld@width{\DefaultWidthofChoiceMenu}%
2964 \def\Fld@height{\DefaultHeightofChoiceMenu}%
2965 \bgroup
2966 \Fld@menulength=0
2967 \@tempdima\z@
2968 \@for\@curropt:=#3\do{
2969  \expandafter\Fld@checkequals\@curropt==\\%
2970  \advance\Fld@menulength by 1
2971  \settowidth{\@tempdimb}{\@currDisplay}%
2972  \ifdim\@tempdimb>\@tempdima\@tempdima\@tempdimb\fi

2973 }%

2974 \advance\@tempdima by 15\p@
2975 \Field@toks={ }%
2976 \setkeys{Field}{#1}%
2977 \ifFld@hidden\def\Fld@width{1sp}\fi
2978 \LayoutChoiceField{#2}{%
2979 \ifFld@radio
2980 \@@Radio{#3}%
2981 \else

2982 {%

2983 \ifdim\Fld@width<\@tempdima
2984  \ifdim\@tempdima<1cm\@tempdima1cm\fi
2985  \edef\Fld@width{\the\@tempdima}%

2986 \fi

2987 \def\Fld@flags{}%
2988 \ifFld@combo\def\Fld@flags{/Ff 917504}\fi

2989 \ifFld@popdown\def\Fld@flags{/Ff 131072}\fi
2990 \ifx\Fld@flags\@empty
2991  \@tempdima=\the\Fld@menulength\Fld@charsize
2992  \advance\@tempdima by 2\Fld@borderwidth bp
2993  \edef\Fld@height{\the\@tempdima}%

2994 \fi

2995 \@@Listbox{#3}%

2996 }}% 2997 \fi

2998 \egroup

2999}

3000\def\@@Radio#1{%
3001 \Fld@listcount=0
3002 \@for\@curropt:=#1\do{%
3003 \expandafter\Fld@checkequals\@curropt==\\%
3004 \advance\Fld@listcount by 1
3005 \@currDisplay\space
3006 \leavevmode\pdfannotlink user {\PDFForm@Radio
3007  /AP <<
3008  /N <<

Laurent.Guillope@math.univ-nantes.fr (Laurent Guillope) persuades me that this was wrong: /\Fld@name\the\Fld@listcount. But I leave it here to remind me that it is untested.

3009/\@currValue\space \DingObject

3010 >> 3011 >> 3012 }%

3013 \MakeRadioField{\Fld@width}{\Fld@height}\pdfendlink
3014 \space}% deliberate space between radio buttons

3015}

3016\newcount\Fld@listcount
3017\def\@@Listbox#1{%
3018 \Choice@toks={ }%
3019 \Fld@listcount=0
3020 \@for\@curropt:=#1\do{%
3021 \expandafter\Fld@checkequals\@curropt==\\%
3022 \advance\Fld@listcount by 1
3023 \edef\@processme{%
3024  \Choice@toks{\the\Choice@toks [(\@currValue) (\@currDisplay)]}%
3025 }\@processme

3026 }%

3027 \leavevmode\pdfannotlink user {\PDFForm@List}%
3028 \MakeChoiceField{\Fld@width}{\Fld@height}\pdfendlink

3029}

3030\def\@PushButton[#1]#2{% parameters, label
3031 \def\Fld@name{#2}%
3032 \bgroup
3033 \Field@toks={ }%
3034 \setkeys{Field}{#1}%

3035 \ifFld@hidden\def\Fld@width{1sp}\fi
3036 \LayoutPushButtonField{\leavevmode\pdfannotlink user {\PDFForm@Push}%
3037 \MakeButtonField{#2}\pdfendlink}%
3038 \egroup

3039}

3040\def\@Submit[#1]#2{%
3041 \Field@toks={ }%
3042 \def\Fld@width{\DefaultWidthofSubmit}%
3043 \def\Fld@height{\DefaultHeightofSubmit}%
3044 \bgroup
3045 \def\Fld@name{Submit}%
3046 \setkeys{Field}{#1}%
3047 \ifFld@hidden\def\Fld@width{1sp}\fi
3048 \leavevmode\pdfannotlink user {\PDFForm@Submit
3049  /AP << /N \SubmitObject\space /D \SubmitPObject >>
3050}\MakeButtonField{#2}\pdfendlink
3051\egroup

3052}

3053\def\@Reset[#1]#2{%
3054 \Field@toks={ }%
3055 \def\Fld@width{\DefaultWidthofReset}%
3056 \def\Fld@height{\DefaultHeightofReset}%
3057 \bgroup
3058 \def\Fld@name{Reset}%
3059 \setkeys{Field}{#1}%
3060 \ifFld@hidden\def\Fld@width{1sp}\fi
3061 \leavevmode\pdfannotlink user {\PDFForm@Reset}%
3062 \MakeButtonField{#2}\pdfendlink
3063 \egroup

3064}

3065\def\@CheckBox[#1]#2{% parameters, label
3066 \def\Fld@name{#2}%
3067 \def\Fld@default{0}%
3068 \bgroup
3069 \def\Fld@width{\DefaultWidthofCheckBox}%
3070 \def\Fld@height{\DefaultHeightofCheckBox}%
3071 \Field@toks={ }%
3072 \setkeys{Field}{#1}%
3073 \ifFld@hidden\def\Fld@width{1sp}\fi
3074 \LayoutCheckField{#2}{%
3075 \pdfannotlink user {\PDFForm@Check}%
3076 \MakeCheckField{\Fld@width}{\Fld@height}\pdfendlink}\egroup

3077}

3078\pdfobj { <</Type /Encoding
3079/Differences [ 24 /breve /caron /circumflex /dotaccent /hungarumlaut
3080/ogonek /ring /tilde 39 /quotesingle 96 /grave 128 /bullet /dagger /daggerdbl                   /ellipsis /emdash /endash /florin /fraction /guilsinglleft
3081/guilsinglright /minus /perthousand /quotedblbase /quotedblleft
3082/quotedblright /quoteleft  /quoteright /quotesinglbase /trademark /fi /fl /Lslash /OE
3083/Scaron /Ydieresis /Zcaron /dotlessi /lslash /oe /scaron /zcaron
3084164 /currency 166 /brokenbar 168 /dieresis /copyright /ordfeminine 172

3085/logicalnot /.notdef /registered /macron /degree /plusminus
3086/twosuperior /threesuperior /acute /mu 183 /periodcentered /cedilla /onesuperior
3087/ordmasculine 188 /onequarter /onehalf /threequarters 192 /Agrave /Aacute
3088/Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla /Egrave /Eacute
3089/Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde                   /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply
3090/Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn
3091/germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring /ae
3092/ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute
3093/icircumflex /idieresis /eth /ntilde /ograve /oacute /ocircumflex
3094/otilde /odieresis /divide /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /ydieresis ]

3095>> }

3096\edef\OBJ@pdfdocencoding{\the\pdflastobj}

3097

3098\pdfobj {

3099 <<

3100 /Type /Font
3101 /Subtype /Type1
3102 /Name /ZaDb
3103 /BaseFont /ZapfDingbats

3104>> 3105}

3106\edef\OBJ@ZaDb{\the\pdflastobj}

3107

3108\pdfobj {  <<
3109 /Type /Font
3110 /Subtype /Type1
3111 /Name /Helv
3112 /BaseFont /Helvetica
3113 /Encoding \OBJ@pdfdocencoding\space 0 R

3114 >> 3115}

3116\edef\OBJ@Helv{\the\pdflastobj}

3117

3118\pdfobj {

3119 <<

3120  /Fields []
3121  /DR << /Font << /ZaDb \OBJ@ZaDb\space 0 R /Helv \OBJ@Helv\space0 R >> >>
3122  /DA (/Helv 10 Tf 0 g )
3123  /NeedAppearances true

3124 >> 3125}

3126\edef\OBJ@acroform{\the\pdflastobj}

3127⟨/pdftex⟩ 3128⟨∗pdfform⟩

3129\def\PDFForm@Check{
3130  /Subtype /Widget
3131\ifFld@hidden /F 6 \else /F 4 \fi
3132  /T (\Fld@name)
3133  /Q \Fld@align\space
3134  /BS << /W \Fld@borderwidth\space /S /\Fld@borderstyle\space >>

3135  /MK <<
3136  /BC [ \Fld@bordercolor\space]
3137\ifx\Fld@bcolor\@empty
3138 \else
3139  /BG [ \Fld@bcolor\space]

3140\fi

3141  /CA (H)

3142 >>

3143  /DA (/ZaDb \strip@pt\Fld@charsize\space Tf \Fld@color\space rg)
3144  /FT /Btn
3145  /H /P
3146 \ifFld@checked /V /Yes \else /V /Off \fi

3147}

3148\def\PDFForm@Push{
3149  /Subtype /Widget
3150\ifFld@hidden     /F 6 \else /F 4 \fi
3151  /T (\Fld@name)
3152  /FT /Btn
3153  /Ff 65540
3154  /H /P
3155  /BS << /W \Fld@borderwidth\space /S /\Fld@borderstyle\space >>
3156  /MK <<
3157  /BC [ \Fld@bordercolor\space]

3158 >>

3159  /A << /S /JavaScript /JS (\Fld@onclick;) >>

3160}

3161\def\PDFForm@List{         /Subtype /Widget
3162\ifFld@hidden     /F 6 \else /F 4 \fi
3163  /T (\Fld@name)
3164  /FT /Ch
3165  /Q \Fld@align\space
3166  /BS << /W \Fld@borderwidth\space /S /\Fld@borderstyle\space >>
3167  /MK <<
3168  /BC [ \Fld@bordercolor\space]
3169\ifx\Fld@bcolor\@empty
3170 \else
3171  /BG [ \Fld@bcolor\space]

3172\fi 3173 >>

3174  /DA (/Helv \strip@pt\Fld@charsize\space Tf \Fld@color\space rg )
3175  /Opt [ \the\Choice@toks ]
3176  /DV (\Fld@default)
3177  \Fld@flags

3178}

3179\def\PDFForm@Radio{
3180  /Subtype /Widget
3181\ifFld@hidden     /F 6 \else /F 4 \fi
3182  /T (\Fld@name)
3183  /FT /Btn
3184  /Ff 49152

3185  /H /P
3186  /BS << /W \Fld@borderwidth\space /S /\Fld@borderstyle\space >>
3187  /MK <<
3188  /BC [ \Fld@bordercolor\space]
3189\ifx\Fld@bcolor\@empty
3190 \else
3191  /BG [ \Fld@bcolor\space]

3192\fi

3193  /CA (H)

3194 >>

3195  /DA (/ZaDb \strip@pt\Fld@charsize\space Tf \Fld@color\space rg)
3196 \ifx\@currValue\Fld@default
3197  /V /\Fld@default\space
3198 \else
3199  /V /Off

3200 \fi 3201}

3202\def\PDFForm@Text{
3203  /Subtype /Widget
3204\ifFld@hidden     /F 6 \else /F 4 \fi
3205  /T (\Fld@name)
3206  /Q \Fld@align\space
3207  /FT /Tx
3208  /BS << /W \Fld@borderwidth\space /S /\Fld@borderstyle\space >>
3209  /MK <<
3210  /BC [ \Fld@bordercolor\space]
3211\ifx\Fld@bcolor\@empty
3212 \else
3213  /BG [ \Fld@bcolor\space]

3214\fi 3215 >>

3216  /DA (/Helv \strip@pt\Fld@charsize\space Tf \Fld@color\space rg )
3217  /DV (\Fld@default)
3218/AA <<
3219%  K input (keystroke) format
3220\ifx\Fld@keystroke@code\@empty\else
3221 /K << /S /JavaScript /JS (\Fld@keystroke@code) >>

3222\fi

3223\ifx\Fld@format@code\@empty\else
3224% F display format
3225 /F << /S /JavaScript /JS (\Fld@format@code) >>

3226\fi

3227% V validation
3228\ifx\Fld@validate@code\@empty\else
3229 /V << /S /JavaScript /JS (\Fld@validate@code) >>

3230\fi

3231% C calculation
3232\ifx\Fld@calculate@code\@empty\else
3233 /C << /S /JavaScript /JS (\Fld@calculate@code) >>

3234\fi

3236  /V (\Fld@value)
3237 \ifFld@multiline
3238  \ifFld@readonly\Ff 4097 \else /Ff 4096 \fi
3239 \else
3240 \ifFld@password
3241  \ifFld@readonly\Ff 8193 \else /Ff 8192 \fi

3242 \fi 3243 \fi

3244 \ifnum\Fld@maxlen>0/MaxLen \Fld@maxlen \fi

3245}

3246\def\PDFForm@Submit{
3247  /Subtype /Widget
3248\ifFld@hidden     /F 6 \else /F 4 \fi
3249  /T (\Fld@name)
3250  /FT /Btn
3251  /Ff 65540
3252  /H /P
3253  /BS << /W \Fld@borderwidth\space /S /\Fld@borderstyle\space >>
3254  /MK <<
3255  /BC [ \Fld@bordercolor\space]

3256 >>

3257  /A <<
3258  /S /SubmitForm
3259  /F <<
3260  /FS /URL
3261  /F (\Form@action)

3262 >>

3263\ifForm@html /Flags 4 \fi

3264 >> 3265}

3266\def\PDFForm@Reset{
3267  /Subtype /Widget
3268\ifFld@hidden     /F 6 \else /F 4 \fi
3269  /T (\Fld@name)
3270  /FT /Btn
3271  /H /P
3272  /DA (/Helv \strip@pt\Fld@charsize\space Tf 0 0 1 rg)
3273  /Ff 65540
3274  /MK <<
3275  /BC [ \Fld@bordercolor\space]
3276%               /CA (Clear)
3277%               /AC (Done)

3278 >>

3279  /BS << /W \Fld@borderwidth\space /S /\Fld@borderstyle\space >>
3280  /A << /S /ResetForm >>

3281} 3282⟨/pdfform⟩ 3283⟨∗outlines⟩

3 Bookmarks in the PDF file

This was originally developed by Yannis Haralambous (it was the separate repere.sty); it needed the repere or makebook.pl post-processor to work properly. Now redundant, as it is done entirely in L^{A}TEX macros.

To write out the current section title, and its rationalized number, we have to intercept the \@sect command, which is rather dangerous. But how else to see the information we need?

3284\let\H@old@sect\@sect
3285\def\@sect#1#2#3#4#5#6[#7]#8{%
3286 \H@old@sect{#1}{#2}{#3}{#4}{#5}{#6}[{#7}]{#8}%
3287⟨dvipdf⟩ \literalps@out{/BOOK <<}%%

If the sectioning internal commands are abused and beaten, what are we to do? Answer, nothing if the first parameter is empty.

3288 \ifx\\#1\\\else
3289 \ifnum#2>\c@secnumdepth\else
3290  \ifhy@naturalnames
3291  \edef\@thishlabel{\csname the#1\endcsname}%
3292  \else
3293  \edef\@thishlabel{\csname theH#1\endcsname}%

3294 \fi

3295⟨dvipdf⟩\literalps@out{/BOOK /title (#7) \space /level #1.\@thishlabel\space >> }%%
3296⟨!dvipdf⟩\@writetorep{\csname the#1\endcsname}{#7}{#1.\@thishlabel}{#2}\fi

3297 \fi 3298}

Unfortunately, that only works if the section headings use the standard \@startsection macros. Chapters and parts typically don’t. This makes it almost impossible to get 100% right, so we just intercept the code in the standard styles.

3299\let\H@old@part\@part
3300\def\@part[#1]#2{%
3301 \H@old@part[{#1}]{#2}%
3302⟨dvipdf⟩\literalps@out{/BOOK << }%%
3303⟨dvipdf⟩ \literalps@out{/BOOK /title (#1) /level part.\theHpart\space >> } %%

3304⟨∗!dvipdf⟩

3305 \ifhy@naturalnames
3306 \@writetorep{\thepart}{#1}{part.\thepart}{-1}%
3307 \else
3308 \@writetorep{\thepart}{#1}{part.\theHpart}{-1}%

3309 \fi 3310⟨/!dvipdf⟩ 3311}

3312\let\H@old@chapter\@chapter
3313\def\@chapter[#1]#2{%
3314⟨dvipdf⟩\literalps@out{/BOOK << }%
3315 \H@old@chapter[{#1}]{#2}%
3316⟨dvipdf⟩ \literalps@out{/BOOK /title (#1) \space /level chapter.\theHchapter \space >>}

3317⟨∗!dvipdf⟩

3318 \ifhy@naturalnames

3319 \@writetorep{\thechapter}{#1}{chapter.\thechapter}{0}%
3320 \else
3321 \@writetorep{\thechapter}{#1}{chapter.\theHchapter}{0}%

3322 \fi 3323⟨/!dvipdf⟩ 3324 }

3325\expandafter\def\csname Parent-4\endcsname{}
3326\expandafter\def\csname Parent-3\endcsname{}
3327\expandafter\def\csname Parent-2\endcsname{}
3328\expandafter\def\csname Parent-1\endcsname{}
3329\expandafter\def\csname Parent0\endcsname{}
3330\expandafter\def\csname Parent1\endcsname{}
3331\expandafter\def\csname Parent2\endcsname{}
3332\expandafter\def\csname Parent3\endcsname{}
3333\expandafter\def\csname Parent4\endcsname{}

3.1 Dealing with PDFDocEncoding

This section was written by Heiko Oberdiek; the code replaces an earlier version by David Carlisle.

Bookmarks and the document information strings use PDFDocEncoding, in which:

• Chars can be specified directly or by an octal notation: Umlaut a (\"a)= \344

• Unmatched brackets (( or )) must not be used, instead they can be specified with

     the glyph name commands \textparenleft and \textparenright.

• With AcrobatReader 3.01 (Win 3.11) I could not verify the special meaning of \b (backspace to generate special accented letters that are not part of the PDFDocEncoding) or \n (two line entries) for example.

The L^{A}TEX solution to handle different encodings is the fontencoding mechanism. So I have written a “PDFDocEncoding-fontencoding-definition” file “pd1enc.def”. Here all 8bit and special 7bit characters are mapped to their octal sequence. These glyphs are now accessible by the standard naming scheme “\text¡glyphname¿” (e. g. \textcopyright) or by the normal TEX commands to produce accents (\c C\"asar). The same TEX string can now be written in the document’s encoding to write chapters, sections, headlines, or the table of contents. Before the same string is written as bookmark (the .out file), only the encoding has to be changed to the PDFDocEncoding (PD1) to get a correct “encoded” output. This method is sufficient for the document information.

The bookmark case is more complicate. Simple strings with umlauts or accented characters are handled by the normal method. But if the user is writing a section title, he can use the whole TEX language with math formulas, logos, several fonts, — in the bookmarks only one font and one encoding can be used. So what can be done?

1. One method is to use a ”second optional“ argument of the sectioning commands to specify the bookmark entry. (I haven’t implemented this method, because I think that there are too many packages that overload the sectioning commands and I don’t want to go into incompatiblity trouble. But if wanted, this can easily be done.)

2. Use of a macro to define the next string for a bookmark entry:

 \pdfbookmarkstring{Hello World, this is a bookmark}
 \section{Hello World, this isn't part of the bookmarks}
 \section{This string is in the bookmarks, too}

creates the bookmarks:

       1 Hello World, this is a bookmark
       2 This string is in the bookmarks, too

and the table of contents:

       1 Hello World, this isn't part of the bookmarks
       2 This string is in the bookmarks, too

3. While writing a bookmark a switch can be set and a macro can ask if it be set or not and produce the right output:

       \section{This is \ifbookmark{a bookmark}{a heading}}
       \section{The role of \ifbookmark{water}{H$_2$O}}

4. Common commands can be redefined while writing a bookmark. But this solution can not be complete because there are a nearly infinite number of commands to be redefined.

Therefore, we defined \Hy@PDFDef to do the work; ie changing the encoding, and redefining some commands:

1. required for encoding: \0, \1, ...

2. (La)TEXcommands that produce character output: \$, \#, \ , ~, \dots, \ldots, …

3. Commands of language packages (german, ...): \grlqq, \flq, …

4. Optional: Other commands like font switching: \textbf, …

For defining the command that holds the string there two possibilities:

1. weak form: use \edef to get the fontencoding mechanism work. Advantage:

more compatible with old code than the strong form. Disadvantage: stomach commands (\relax, ...) are not expanded further, they become part of the output string. The users have to scan the result to detect wrong artefacts.

2. strong form: converting to output string via \expandafter\string\csname <string>\endcsname.

The string is expanded like edef, but stomach commands that make the PDF output string dirty cause an error at run-time. So the user is forced to give the correct code for the bookmark, info, author, ... entries.

The default is the weak form.

3334\newwrite\@outlinefile
3335\def\@writetorep#1#2#3#4{\ifx\WriteBookmarks\relax{}%
3336  \else\@@writetorep{#1}{#2}{#3}{#4}\fi}
3337\def\@@writetorep#1#2#3#4{%
3338  \PDFbookmarktrue
3339  \@tempcnta#4
3340  \expandafter\xdef\csname Parent#4\endcsname{#3}%
3341  \advance\@tempcnta by -1
3342  \ifx\Hy@bookmarkstring\relax
3343  \Hy@PDFDef\Hy@bookmarkstring{#2}%

3344 \fi

3345  \Hy@PDFDef\@tempa{#1 }%
3346  \protected@write\@outlinefile%

3347 {%

3348  \expandafter\let\csname T1-cmd\endcsname\@gobble
3349  \let\@tabacckludge\@empty
3350  \let\IeC\@firstofone

3351 }{%

3352  \ifhy@bookmarksnumbered
3353  \protect\BOOKMARK[#4]{#3}%
3354  {\@tempa\Hy@bookmarkstring}{\csname Parent\the\@tempcnta\endcsname}%
3355  \else
3356  \protect\BOOKMARK[#4]{#3}%
3357  {\Hy@bookmarkstring}{\csname Parent\the\@tempcnta\endcsname}%

3358 \fi 3359 }%

3360  \PDFbookmarkfalse
3361  \global\let\Hy@bookmarkstring\relax

3362}

3363\let\Hy@bookmarkstring\relax
3364\newcommand*{\ifbookmark}{%
3365 \ifPDFbookmark
3366  \expandafter\@firstoftwo
3367 \else
3368  \expandafter\@secondoftwo

3369 \fi 3370}

Tobias Oetiker rightly points out that we need a way to force a bookmark entry. So we introduce \pdfbookmark, with two parameters, the title, and a symbolic name. By default this is at level 1, but we can reset that with the optional first argument.

3371\def\pdfbookmark{\@ifnextchar[{\pdf@bookmark}{\pdf@bookmark[0]}}
3372\def\pdf@bookmark[#1]#2#3{%
3373 \@writetorep{}{#2}{#3.#1}{#1}%
3374 \hyper@anchorstart{#3.#1}\hyper@anchorend

3375}

3376\def\BOOKMARK{\@ifnextchar[{\@BOOKMARK}{\@BOOKMARK[1]}}

The macros for calculating structure of outlines are derived from those by Petr Olsak used in the texinfopdf macros.

The VTEX section comes straight from them, as is.

3377⟨∗hvtex⟩

3378\newcount\@serial@counter\@serial@counter=1\relax
3379\def\@openstatus{c}% Closed - default
3380\def\@BOOKMARK #1#2#3{%
3381 \toks@={#2}%
3382 \expandafter\edef\csname @count@#1\endcsname{\the\@serial@counter}%
3383 \edef\@mycount{\the\@serial@counter}%
3384 \advance\@serial@counter by 1\relax
3385 \edef\@parcount{\expandafter\ifx\csname @count@#3\endcsname\relax 0\else\csname @count@#3\endcsname\fi}%
3386 \special{!outline #1;p=\@parcount,i=\@mycount,s=\@openstatus,t=\the\toks@}%

3387 }%

3388\def\ReadBookmarks{%
3389 \ifhy@bookmarksopen\def\@openstatus{o}\fi
3390 \InputIfFileExists{\jobname.out}{}{}%
3391 \ifx\WriteBookmarks\relax\else
3392  \immediate\openout\@outlinefile=\jobname.out

3393 \fi 3394} 3395⟨/hvtex⟩ 3396⟨∗!hvtex⟩

3397\def\ReadBookmarks{%
3398 \begingroup
3399 \escapechar=`\\%
3400 \let\escapechar\@gobble %
3401 \def\@BOOKMARK [##1]##2##3##4{\calc@bm@number{##4}}%
3402 \InputIfFileExists{\jobname.out}{}{}%
3403 \ifx\WriteBookmarks\relax\global\let\WriteBookmarks\relax\fi
3404 \def\@BOOKMARK[##1]##2##3##4{%
3405 \def\@tempx{##3}%

3406⟨∗pdftex⟩

3407 \pdfoutline goto

3408⟨pdftexold⟩ name{##2!}% 3409⟨!pdftexold⟩ name{##2}%

3410  count\@bookmarkopenstatus\check@bm@number{##2}{%
3411 \expandafter\strip@prefix\meaning\@tempx}%

3412⟨/pdftex⟩ 3413⟨∗pdfmark⟩

3414 \pdfmark{pdfmark=/OUT,Count=\@bookmarkopenstatus\check@bm@number{##2},
3415  Dest=##2,Title=\expandafter\strip@prefix\meaning\@tempx}%

3416⟨/pdfmark⟩ 3417⟨∗dvipdfm⟩

3418 \special{pdf: outline ##1
3419  << /Title (\expandafter\strip@prefix\meaning\@tempx)
3420  /A << /S /GoTo
3421  /D (##2)

3422 >> 3423 >> 3424 }% 3425⟨/dvipdfm⟩ 3426 }% 3427 {%

3428  \def\WriteBookmarks{0}%
3429  \InputIfFileExists{\jobname.out}{}{}%

3430 }%

3431 %{\escapechar\m@ne\InputIfFileExists{\jobname.out}{}{}}%
3432 \ifx\WriteBookmarks\relax\else
3433  \immediate\openout\@outlinefile=\jobname.out

3434 \fi

3435 \endgroup

3436}

3437\def\check@bm@number#1{\expandafter \ifx\csname#1\endcsname \relax 0%
3438  \else \csname#1\endcsname \fi}
3439\def\calc@bm@number#1{\@tempcnta=\check@bm@number{#1}\relax
3440  \advance\@tempcnta by1
3441  \expandafter\xdef\csname#1\endcsname{\the\@tempcnta}}

3442⟨/!hvtex⟩ 3443⟨/outlines⟩ 3444⟨∗repere⟩

3445\newwrite\@reperefile
3446\immediate\openout\@reperefile=\jobname.rep
3447\def\@writetorep#1#2#3#4{%
3448  \protected@write\@reperefile
3449  {\def\TeX{TeX}%
3450  \def\LaTeX{LaTeX}%
3451  \let\label\@gobble
3452  \let\index\@gobble
3453  \let\glossary\@gobble}%
3454  {(#1) <#2>}%

3455} 3456⟨/repere⟩ 3457⟨∗pdfmark⟩

We have to allow for \baselineskip having an optional stretch and shrink (you meet this in slide packages, for instance), so we need to strip off the junk. David Carlisle, of course, wrote this bit of code.

3458\begingroup
3459 \catcode`P=12
3460 \catcode`T=12
3461 \lowercase{\endgroup
3462\gdef\rem@ptetc#1.#2PT#3!{#1\ifnum#2>\z@.#2\fi}}
3463\def\strip@pt@and@otherjunk#1{\expandafter\rem@ptetc\the#1!}

3464⟨/pdfmark⟩

3.2 Device dependent setup

Unfortunately, some parts of the pdfmark PostScript code depend on vagaries of the dvi driver. We isolate here all the problems.

3.2.1 Rokicki’s dvips

dvips thinks in 10ths of a big point, its coordinate space is resolution dependent, and its y axis starts at the top of the page. Other drivers can and will be different!

The work is done in SDict, because we add in some header definitions in a moment.

3465⟨∗dvips⟩

3466\input{pdfmark.def}%
3467\def\@pdfborder{0 0 12}
3468\providecommand\@pdfview{XYZ}
3469\providecommand\@pdfviewparams{ pdf@hoff pdf@voff null}
3470\def\literalps@out#1{\special{ps:SDict begin #1 end}}%

The calculation of upper left y is done without raising the point in TEX, by simply adding on the current \baselineskip to the current y. This is usually too much, so we remove a notional 2 points.

We have to see what the current baselineskip is, and convert it to the dvips coordinate system.

3471\def\pdf@setheight{\literalps@out{%
3472 \strip@pt@and@otherjunk\baselineskip
3473 \space 2 sub dup
3474 /HyperBasePt exch def
3475 PDFToDvips /HyperBaseDvips exch def

3476 }% 3477}

3478\def\PSHyperAnchorStart{\literalps@out{HyperStart }}
3479\def\PSHyperAnchorEnd{%
3480 \pdf@setheight
3481 \literalps@out{HyperAutoEnd HyperAutoVoff }%

3482}

3483\def\PSHyperLinkStart{\literalps@out{HyperStart }}
3484\def\PSHyperLinkEnd{%
3485 \pdf@setheight
3486 \literalps@out{HyperAutoEnd}%

3487}

3488\def\PSHyperRectStart{\literalps@out{HyperStart }}
3489\def\PSHyperRectEnd{\literalps@out{HyperEnd HyperVoff }}

Do not ask what this rubbish is. Trying to make pdfmark get the right destination for views.

3490\AtBeginDvi{\special{!

Unless I am going mad, this appears to be the relationship between the default coordinate system (PDF), and dvips;

  /DvipsToPDF { .01383701 div Resolution div } def
  /PDFToDvips { .01383701 mul Resolution mul } def

the latter’s coordinates are resolution dependent, but what that .01383701 is, who knows? well, almost everyone except me, I expect… And yes, Maarten Gelderman <mgelderman@econ.vu.nl> points out that its 1/72.27 (the number of points to an inch, big points to inch is 1/72). This also suggests that the code would be more understandable (and exact) if 0.013 div would be replaced by 72.27 mul, so here we go. If this isn’t right, I’ll revert it.

3491/DvipsToPDF { 72.27 mul Resolution div } def
3492/PDFToDvips { 72.27 div Resolution mul } def

The rectangle around the links starts off exactly the size of the box; we will to make it slightly bigger, 1 point on all sides.

3493/HyperBorder  { 1 PDFToDvips } def
3494% the distance from the top of the page to the current point, in
3495% PDF coordinates
3496/HyperVoff {
3497 currentpoint exch pop vsize 72 sub
3498 exch DvipsToPDF sub /pdf@voff exch def
3499 } def

the distance from the top of the page to a point \baselineskip above the current point in PDF coordinates

3500/HyperAutoVoff {
3501 currentpoint exch pop
3502  vsize 72 sub exch DvipsToPDF
3503  HyperBasePt sub % baseline skip
3504  sub /pdf@voff exch def
3505 } def

the x and y coordinates of the current point, in PDF coordinates

3506/HyperStart {
3507 currentpoint
3508  HyperBorder add /pdf@lly exch def
3509  dup DvipsToPDF  /pdf@hoff exch def
3510  HyperBorder sub /pdf@llx exch def
3511} def

the x and y coordinates of the current point, minus the baselineskip

3512/HyperAutoEnd  {
3513 currentpoint
3514  HyperBaseDvips sub /pdf@ury exch def
3515  /pdf@urx exch def
3516} def
3517 /HyperEnd  {
3518 currentpoint
3519  HyperBorder sub /pdf@ury exch def
3520  HyperBorder add /pdf@urx exch def
3521 } def
3522 systemdict
3523 /pdfmark known not
3524 {userdict /pdfmark systemdict /cleartomark get put} if

3525}}

3526\AtBeginDocument{%
3527 \ifhy@colorlinks
3528 \def\@pdfborder{0 0 0}%

3529 \fi

3530 \special{papersize=\special@paper}%

3531} 3532⟨/dvips⟩

3.2.2 Textures

At the suggestion of Jacques Distler (distler@golem.ph.utexas.edu), try to derive a suitable driver for Textures. This is a copy of dvips, with some guesses about Textures behaviour.

3533⟨∗textures⟩

3534\def\literalps@out#1{\special{rawpostscript #1}}%
3535\def\pdf@setheight{\literalps@out{%
3536 \strip@pt@and@otherjunk\baselineskip
3537 \space 2 sub
3538 PDFToDvips /HyperBase exch def

3539 }% 3540}

3541\providecommand\@pdfview{XYZ pdf@hoff pdf@voff null}
3542\providecommand\@pdfviewparams{ pdf@hoff pdf@voff null}

3543%

These are called at the start and end of unboxed links; their job is to leave available PS variables called pdf@llx pdf@lly pdf@urx pdf@ury, which are the coordinates of the bounding rectangle of the link, and pdf@hoff pdf@voff which are the PDF page offsets. The Rect pair are called at the LL and UR corners of a box known to TEX.

3544\def\PSHyperAnchorStart{\literalps@out{HyperStart }}
3545\def\PSHyperAnchorEnd{%
3546 \pdf@setheight
3547 \literalps@out{HyperAutoEnd HyperAutoVoff }%

3548}

3549\def\PSHyperLinkStart{\literalps@out{HyperStart }}
3550\def\PSHyperLinkEnd{%
3551 \pdf@setheight
3552 \literalps@out{HyperAutoEnd}%

3553}

3554\def\PSHyperRectStart{\literalps@out{HyperStart }}
3555\def\PSHyperRectEnd{\literalps@out{HyperEnd HyperVoff }}
3556\special{prepostscript

Textures lives in normal points, I think. So conversion from one coordinate system to another involves doing nothing.

3557/vsize { \hy@pageheight } def
3558/DvipsToPDF { } def
3559/PDFToDvips { } def
3560/HyperBorder  { 1 PDFToDvips } def
3561/HyperVoff {
3562 currentpoint exch pop vsize 72 sub
3563 exch DvipsToPDF sub /pdf@voff exch def

3564 } def
3565/HyperAutoVoff {
3566 currentpoint exch pop
3567  vsize 72 sub exch DvipsToPDF
3568  HyperBase sub % baseline skip
3569  sub /pdf@voff exch def
3570 } def
3571/HyperStart {
3572 currentpoint
3573  HyperBorder add /pdf@lly exch def
3574  dup DvipsToPDF  /pdf@hoff exch def
3575  HyperBorder sub /pdf@llx exch def
3576} def
3577/HyperAutoEnd  {
3578 currentpoint
3579  HyperBase sub /pdf@ury exch def
3580  /pdf@urx exch def
3581} def
3582 /HyperEnd  {
3583 currentpoint
3584  HyperBorder sub /pdf@ury exch def
3585  HyperBorder add /pdf@urx exch def
3586 } def
3587 systemdict
3588 /pdfmark known not
3589 {userdict /pdfmark systemdict /cleartomark get put} if

3590}

3591\AtBeginDocument{%
3592 \ifhy@colorlinks
3593 \def\@pdfborder{0 0 0}%

3594 \fi 3595}

3596\def\@pdfborder{0 0 1}
3597\AtBeginDocument{%
3598\def\@pdfproducer{Textures + Distiller}}

3599⟨/textures⟩

3.2.3 dvipsone

3600% Over-ride the default setup macro in pdfmark driver to use Y\&Y
3601% |\special| commands.

3602⟨∗dvipsone⟩

3603\def\@pdfborder{0 0 65781}
3604\input{pdfmark.def}%
3605\def\@pdfproducer{dvipsone + Distiller}
3606\def\PDF@FinishDoc{
3607 \special{PDF: Keywords \@pdfkeywords}%
3608 \special{PDF: Title \@pdftitle}%
3609 \special{PDF: Creator \@pdfcreator}%
3610 \special{PDF: Author \@pdfauthor}%

3611 \special{PDF: Producer \@pdfproducer}%
3612 \special{PDF: Subject \@pdfsubject}%

3613}

3614\def\PDF@SetupDoc{
3615 \pdfmark{pdfmark=/DOCVIEW,
3616 Page=\@pdfstartpage,
3617 View=\@pdfstartview,
3618 URI={<< /Base (\@baseurl) >>},
3619 PageMode=\@pdfpagemode

3620 }%

3621 \ifx\@pdfpagescrop\@empty\else
3622 \pdfmark{pdfmark=/PAGES,CropBox=\@pdfpagescrop}%

3623 \fi

3624 \pdfmark{pdfmark=/PUT,Raw={
3625 \string{Catalog\string} <<
3626 /ViewerPreferences <<
3627 \ifhy@toolbar\else /HideToolbar true \fi
3628 \ifhy@menubar\else /HideMenubar true \fi
3629 \ifhy@windowui\else /HideWindowUI true \fi
3630 \ifhy@fitwindow /FitWindow true \fi
3631 \ifhy@centerwindow /CenterWindow true \fi

3632 >>

3633 \ifx\pdf@pagelayout\@empty\else/PageLayout /\pdf@pagelayout\space\fi
3634 >>}}%

3635}

3636\def\literalps@out#1{\special{ps:#1}}%
3637\def\pdf@setheight{\literalps@out{%
3638 \strip@pt@and@otherjunk\baselineskip
3639 \space 2 sub
3640 PDFToDvips /HyperBase exch def

3641 }% 3642}

3643\providecommand\@pdfview{XYZ}
3644\providecommand\@pdfviewparams{ gsave revscl currentpoint grestore 72 add
3645 exch pop null exch null}

3646%

These are called at the start and end of unboxed links; their job is to leave available PS variables called pdf@llx pdf@lly pdf@urx pdf@ury, which are the coordinates of the bounding rectangle of the link, and pdf@hoff pdf@voff which are the PDF page offsets. These latter are currently not used in the dvipsone setup. The Rect pair are called at the LL and UR corners of a box known to TEX.

3647\def\PSHyperAnchorStart{\literalps@out{HyperStart }}
3648\def\PSHyperAnchorEnd{%
3649 \pdf@setheight
3650 \literalps@out{HyperAutoEnd HyperAutoVoff }%

3651}

3652\def\PSHyperLinkStart{\literalps@out{HyperStart }}
3653\def\PSHyperLinkEnd{%
3654 \pdf@setheight

3655 \literalps@out{HyperAutoEnd}%

3656}

3657\def\PSHyperRectStart{\literalps@out{HyperStart }}
3658\def\PSHyperRectEnd{\literalps@out{HyperEnd HyperVoff }}
3659\special{headertext=

dvipsone lives in scaled points; does this mean 65536 or 65781?

3660/DvipsToPDF { 65781 div  } def
3661/PDFToDvips { 65781 mul } def
3662/HyperBorder  { 1 PDFToDvips } def
3663/HyperVoff {
3664 currentpoint exch pop DvipsToPDF /pdf@voff exch def
3665 } def
3666/HyperAutoVoff {
3667 currentpoint exch pop
3668  HyperBase sub % baseline skip
3669  DvipsToPDF /pdf@voff exch def
3670 } def
3671/HyperStart {
3672 currentpoint
3673  HyperBorder add /pdf@lly exch def
3674  dup   DvipsToPDF /pdf@hoff exch def
3675  HyperBorder sub /pdf@llx exch def
3676} def
3677/HyperAutoEnd  {
3678 currentpoint
3679  HyperBase sub /pdf@ury exch def
3680  /pdf@urx exch def
3681} def
3682/HyperEnd  {
3683 currentpoint
3684  HyperBorder sub /pdf@ury exch def
3685  HyperBorder add /pdf@urx exch def
3686 } def
3687 systemdict
3688 /pdfmark known not
3689 {userdict /pdfmark systemdict /cleartomark get put} if

3690}

3691\AtBeginDocument{%
3692 \ifhy@colorlinks
3693 \def\@pdfborder{0 0 0}%

3694 \fi 3695} 3696⟨/dvipsone⟩ 3697⟨∗dvipdf⟩

3698\def\literalps@out#1{\special{pdf: #1}}%
3699\AtBeginDocument{%
3700 \ifhy@colorlinks
3701 \def\@pdfborder{0 0 0}%

3702 \fi

3704\def\@pdfborder{0 0 1}

3705⟨/dvipdf⟩ 3706⟨∗tex4ht⟩

3707\RequirePackage[htex4ht]{tex4ht}
3708\def\PDF@FinishDoc{}
3709\def\PDF@SetupDoc{%
3710 \ifx\@baseurl\@empty\else
3711 \special{t4ht=<base href="\@baseurl">}%

3712 \fi 3713}

3714\def\hyper@anchor#1{%
3715 {\let\protect=\string\special{t4ht=<A name=\hyper@quote #1\hyper@quote>}}%
3716 \hy@activeanchortrue
3717 \hy@colorlink{\@anchorcolor}\anchor@spot\hy@endcolorlink
3718 \special{t4ht=</A>}%
3719 \hy@activeanchorfalse

3720}

3721\def\hyper@anchorstart#1{%
3722 {\hyper@chars\special{t4ht=<A name=\hyper@quote#1\hyper@quote>}}%
3723 \hy@activeanchortrue

3724}

3725\def\hyper@anchorend{%
3726 \special{t4ht=</A>}%
3727 \hy@activeanchorfalse

3728}

3729\def\@urltype{url}
3730\def\hyper@linkstart#1#2{%
3731 \hy@colorlink{\csname @#1color\endcsname}%
3732 \def\@tempa{#1}\ifx\@tempa\@urltype
3733  \special{t4ht=<A href=\hyper@quote#2\hyper@quote>}%
3734 \else
3735 {\hyper@chars\special{t4ht=<A href=\hyper@quote\##2\hyper@quote>}}%

3736 \fi 3737}

3738\def\hyper@linkend{%
3739 \special{t4ht=</A>}%
3740 \hy@endcolorlink

3741}

3742\def\hyper@linkfile#1#2#3{%
3743 \hyper@linkurl{#1}{file:#2\ifx\\#3\\\else\##3\fi}%

3744}

3745\def\hyper@linkurl#1#2{%
3746 \ifhy@raiselinks
3747 \setbox\@tempboxa=\hbox{#1}%
3748 \@linkdim\dp\@tempboxa
3749 \leavevmode\lower\@linkdim\hbox{%
3750  {\hyper@chars\special{t4ht=<A href=\hyper@quote#2\hyper@quote>}}%

3751 }%

3752 \hy@colorlink{\@urlcolor}#1\hy@endcolorlink

3753 \@linkdim\ht\@tempboxa
3754 \advance\@linkdim by -6.5\p@
3755 \raise\@linkdim\hbox{\special{t4ht=</A>}}%
3756 \else
3757 {\hyper@chars
3758 \special{t4ht=<A href=\hyper@quote#2\hyper@quote>}%
3759 \hy@colorlink{\@urlcolor}#1\hy@endcolorlink
3760 \special{t4ht=</A>}}%

3761 \fi 3762}

3763\def\hyper@link#1#2#3{%
3764 \hyper@linkurl{#3}{\##2}%

3765}

3766\def\hyper@image#1#2{%
3767 {\hyper@chars
3768 \special{t4ht=<img src=\hyper@quote#1\hyper@quote>}}}

3769⟨/tex4ht⟩ 3770⟨∗tex4htcfg⟩

3771\Preamble{html}
3772 \begin{document}
3773\EndPreamble
3774\def\TeX{TeX}
3775\def\OMEGA{Omega}
3776\def\LaTeX{LaTeX}
3777\def\LaTeXe{LaTeX2e}
3778\def\eTeX{e-\TeX}
3779\def\MF{Metafont}

3780⟨/tex4htcfg⟩

This was contributed by Heiko Oberdiek oberdiek@ruf.uni-freiburg.de

3781⟨∗pd1enc⟩

3782\ProvidesFile{pd1enc.def}
3783 [1998/10/28 v0.1 PDFDocEncoding (Heiko Oberdiek)]
3784% accents
3785\DeclareFontEncoding{PD1}{}{}
3786\DeclareTextAccent{\`}{PD1}{96} % grave
3787\DeclareTextAccent{\'}{PD1}{180} % acute
3788\DeclareTextAccent{\^}{PD1}{26} % circumflex
3789\DeclareTextAccent{\~}{PD1}{31} % tilde
3790\DeclareTextAccent{\"}{PD1}{168} % dieresis
3791\DeclareTextAccent{\r}{PD1}{30} % ring
3792\DeclareTextAccent{\v}{PD1}{25} % caron
3793\DeclareTextAccent{\.}{PD1}{27} % dotaccent
3794\DeclareTextAccent{\c}{PD1}{184} % cedilla

3795%

3796\DeclareTextCommand{\textbreve}{PD1}{\030} % breve
3797\DeclareTextCommand{\textcaron}{PD1}{\031} % caron
3798\DeclareTextCommand{\textcircumflex}{PD1}{\032} % circumflex
3799\DeclareTextCommand{\textdotaccent}{PD1}{\033} % dotaccent
3800\DeclareTextCommand{\texthungarumlaut}{PD1}{\034} % hungarumlaut

3801\DeclareTextCommand{\textogonek}{PD1}{\035} % ogonek
3802\DeclareTextCommand{\textring}{PD1}{\036} % ring
3803\DeclareTextCommand{\textasciitilde}{PD1}{\037} % tilde
3804% \040 space
3805% \041 exclam
3806\DeclareTextCommand{\textquotedbl}{PD1}{\string"} % quotedbl \042
3807\DeclareTextCommand{\textnumbersign}{PD1}{\043} % numbersign
3808\DeclareTextCommand{\textdollar}{PD1}{\044} % dollar
3809\DeclareTextCommand{\textpercent}{PD1}{\045} % percent
3810\DeclareTextCommand{\textampersand}{PD1}{\046} % ampersand
3811% \047 quotesingle
3812\DeclareTextCommand{\textparenleft}{PD1}{\string\(} % parenleft \050
3813\DeclareTextCommand{\textparenright}{PD1}{\string\)} % parenright \051
3814% \052 asterisk
3815% \053 plus
3816% \054 comma
3817% \055 hyphen
3818% \056 period
3819% \057 slash
3820% \060..\071 0..9
3821% \072 colon
3822% \073 semicolon
3823\DeclareTextCommand{\textless}{PD1}{<} % less \074
3824% \075 equal
3825\DeclareTextCommand{\textgreater}{PD1}{>} % greater \076
3826% \077 question
3827% \080 at
3828% \081..\132 A..Z
3829% \133 bracketleft
3830\DeclareTextCommand{\textbackslash}{PD1}{\string\\} % backslash \134
3831% \135 bracketright
3832\DeclareTextCommand{\textasciicircum}{PD1}{\136} % asciicircum
3833\DeclareTextCommand{\textunderscore}{PD1}{\137} % underscore
3834% \140 grave
3835% \141..\172 a..z
3836\DeclareTextCompositeCommand{\.}{PD1}{i}{i} % i
3837\DeclareTextCommand{\textbraceleft}{PD1}{\173} % braceleft
3838\DeclareTextCommand{\textbar}{PD1}{|} % bar
3839\DeclareTextCommand{\textbraceright}{PD1}{\175} % braceright
3840\DeclareTextCommand{\textasciitilde}{PD1}{\176} % asciitilde
3841% No glyph \177 in PDFDocEncoding
3842\DeclareTextCommand{\textbullet}{PD1}{\200} % bullet
3843\DeclareTextCommand{\textdagger}{PD1}{\201} % dagger
3844\DeclareTextCommand{\textdaggerdbl}{PD1}{\202} % daggerdbl
3845\DeclareTextCommand{\textellipsis}{PD1}{\203} % ellipsis
3846\DeclareTextCommand{\textemdash}{PD1}{\204} % emdash
3847\DeclareTextCommand{\textendash}{PD1}{\205} % endash
3848\DeclareTextCommand{\textflorin}{PD1}{\206} % florin
3849\DeclareTextCommand{\textfractionmark}{PD1}{\207} % fraction
3850\DeclareTextCommand{\guilsinglleft}{PD1}{\210} % guilsinglleft

3851\DeclareTextCommand{\guilsinglright}{PD1}{\211} % guilsinglright
3852\DeclareTextCommand{\textminus}{PD1}{\212} % minus
3853\DeclareTextCommand{\textperthousand}{PD1}{\213} % perthousand
3854\DeclareTextCommand{\quotedblbase}{PD1}{\214} % quotedblbase
3855\DeclareTextCommand{\textquotedblleft}{PD1}{\215} % quotedblleft
3856\DeclareTextCommand{\textquotedblright}{PD1}{\216} % quotedblright
3857\DeclareTextCommand{\textquoteleft}{PD1}{\217} % quoteleft
3858\DeclareTextCommand{\textquoteright}{PD1}{\220} % quoteright
3859\DeclareTextCommand{\quotesinglbase}{PD1}{\221} % quotesinglbase
3860\DeclareTextCommand{\texttrademark}{PD1}{\222} % trademark
3861\DeclareTextCommand{\textfi}{PD1}{\223} % fi ??
3862\DeclareTextCommand{\textfl}{PD1}{\224} % fl ??
3863\DeclareTextCommand{\L}{PD1}{\225} % Lslash
3864\DeclareTextCommand{\OE}{PD1}{\226} % OE
3865\DeclareTextCompositeCommand{\v}{PD1}{S}{\227} % Scaron
3866\DeclareTextCompositeCommand{\"}{PD1}{Y}{\230} % Ydieresis
3867\DeclareTextCompositeCommand{\v}{PD1}{Z}{\231} % Zcaron
3868\DeclareTextCommand{\i}{PD1}{\232} % dotlessi
3869\DeclareTextCommand{\l}{PD1}{\233} % lslash
3870\DeclareTextCommand{\oe}{PD1}{\234} % oe
3871\DeclareTextCompositeCommand{\v}{PD1}{s}{\235} % scaron
3872\DeclareTextCompositeCommand{\v}{PD1}{z}{\236} % zcaron
3873% No glyph \237 in PDFDocEncoding
3874% No glyph \240 in PDFDocEncoding
3875\DeclareTextCommand{\textexclamdown}{PD1}{\241} % exclamdown
3876\DeclareTextCommand{\textcent}{PD1}{\242} % cent
3877\DeclareTextCommand{\textsterling}{PD1}{\243} % sterling
3878\DeclareTextCommand{\textcurrency}{PD1}{\244} % currency
3879\DeclareTextCommand{\textyen}{PD1}{\245} % yen
3880\DeclareTextCommand{\textbrokenbar}{PD1}{\246} % brokenbar
3881\DeclareTextCommand{\textsection}{PD1}{\247} % section
3882\DeclareTextCommand{\textdieresis}{PD1}{\250} % dieresis
3883\DeclareTextCommand{\textcopyright}{PD1}{\251} % copyright
3884\DeclareTextCommand{\textordfeminine}{PD1}{\252} % ordfeminine
3885\DeclareTextCommand{\guillemotleft}{PD1}{\253} % guillemotleft
3886\DeclareTextCommand{\textlogicalnot}{PD1}{\254} % logicalnot
3887% No glyph \255 in PDFDocEncoding
3888\DeclareTextCommand{\textregistered}{PD1}{\256} % registered
3889\DeclareTextCommand{\textmacron}{PD1}{\257} % macron
3890\DeclareTextCommand{\textdegree}{PD1}{\260} % degree
3891\DeclareTextCommand{\textplusminus}{PD1}{\261} % plusminus
3892\DeclareTextCommand{\texttwosuperior}{PD1}{\262} % twosuperior
3893\DeclareTextCommand{\textthreesuperior}{PD1}{\263} % threesuperior
3894\DeclareTextCommand{\textacute}{PD1}{\264} % acute
3895\DeclareTextCommand{\textmu}{PD1}{\265} % mu
3896\DeclareTextCommand{\textparagraph}{PD1}{\266} % paragraph
3897\DeclareTextCommand{\textperiodcentered}{PD1}{\267} % periodcentered
3898\DeclareTextCommand{\textcedilla}{PD1}{\270} % cedilla
3899\DeclareTextCommand{\textonesuperior}{PD1}{\271} % onesuperior
3900\DeclareTextCommand{\textordmasculine}{PD1}{\272} % ordmasculine

3901\DeclareTextCommand{\guillemotright}{PD1}{\273} % guillemotright
3902\DeclareTextCommand{\textonequarter}{PD1}{\274} % onequarter
3903\DeclareTextCommand{\textonehalf}{PD1}{\275} % onehalf
3904\DeclareTextCommand{\textthreequarters}{PD1}{\276} % threequarters
3905\DeclareTextCommand{\textquestiondown}{PD1}{\277} % questiondown
3906\DeclareTextCompositeCommand{\`}{PD1}{A}{\300} % Agrave
3907\DeclareTextCompositeCommand{\'}{PD1}{A}{\301} % Aacute
3908\DeclareTextCompositeCommand{\^}{PD1}{A}{\302} % Acircumflex
3909\DeclareTextCompositeCommand{\~}{PD1}{A}{\303} % Atilde
3910\DeclareTextCompositeCommand{\"}{PD1}{A}{\304} % Adieresis
3911\DeclareTextCompositeCommand{\r}{PD1}{A}{\305} % Aring
3912\DeclareTextCommand{\AE}{PD1}{\306} % AE
3913\DeclareTextCompositeCommand{\c}{PD1}{C}{\307} % Ccedilla
3914\DeclareTextCompositeCommand{\`}{PD1}{E}{\310} % Egrave
3915\DeclareTextCompositeCommand{\'}{PD1}{E}{\311} % Eacute
3916\DeclareTextCompositeCommand{\^}{PD1}{E}{\312} % Ecircumflex
3917\DeclareTextCompositeCommand{\"}{PD1}{E}{\313} % Edieresis
3918\DeclareTextCompositeCommand{\`}{PD1}{I}{\314} % Igrave
3919\DeclareTextCompositeCommand{\'}{PD1}{I}{\315} % Iacute
3920\DeclareTextCompositeCommand{\^}{PD1}{I}{\316} % Icircumflex
3921\DeclareTextCompositeCommand{\"}{PD1}{I}{\317} % Idieresis
3922\DeclareTextCommand{\DH}{PD1}{\320} % Eth
3923\DeclareTextCommand{\DJ}{PD1}{\320} % Eth
3924\DeclareTextCompositeCommand{\~}{PD1}{N}{\321} % Ntilde
3925\DeclareTextCompositeCommand{\`}{PD1}{O}{\322} % Ograve
3926\DeclareTextCompositeCommand{\'}{PD1}{O}{\323} % Oacute
3927\DeclareTextCompositeCommand{\^}{PD1}{O}{\324} % Ocircumflex
3928\DeclareTextCompositeCommand{\~}{PD1}{O}{\325} % Otilde
3929\DeclareTextCompositeCommand{\"}{PD1}{O}{\326} % Odieresis
3930\DeclareTextCommand{\textmultiply}{PD1}{\327} % multiply
3931\DeclareTextCommand{\O}{PD1}{\330} % Oslash
3932\DeclareTextCompositeCommand{\`}{PD1}{U}{\331} % Ugrave
3933\DeclareTextCompositeCommand{\'}{PD1}{U}{\332} % Uacute
3934\DeclareTextCompositeCommand{\^}{PD1}{U}{\333} % Ucircumflex
3935\DeclareTextCompositeCommand{\"}{PD1}{U}{\334} % Udieresis
3936\DeclareTextCompositeCommand{\'}{PD1}{Y}{\335} % Yacute
3937\DeclareTextCommand{\TH}{PD1}{\336} % Thorn
3938\DeclareTextCommand{\ss}{PD1}{\337} % germandbls
3939\DeclareTextCompositeCommand{\`}{PD1}{a}{\340} % agrave
3940\DeclareTextCompositeCommand{\'}{PD1}{a}{\341} % aacute
3941\DeclareTextCompositeCommand{\^}{PD1}{a}{\342} % acircumflex
3942\DeclareTextCompositeCommand{\~}{PD1}{a}{\343} % atilde
3943\DeclareTextCompositeCommand{\"}{PD1}{a}{\344} % adieresis
3944\DeclareTextCompositeCommand{\r}{PD1}{a}{\345} % aring
3945\DeclareTextCommand{\ae}{PD1}{\346} % ae
3946\DeclareTextCompositeCommand{\c}{PD1}{c}{\347} % ccedilla
3947\DeclareTextCompositeCommand{\`}{PD1}{e}{\350} % egrave
3948\DeclareTextCompositeCommand{\'}{PD1}{e}{\351} % eacute
3949\DeclareTextCompositeCommand{\^}{PD1}{e}{\352} % ecircumflex
3950\DeclareTextCompositeCommand{\"}{PD1}{e}{\353} % edieresis

3951\DeclareTextCompositeCommand{\`}{PD1}{i}{\354} % igrave
3952\DeclareTextCompositeCommand{\`}{PD1}{\i}{\354} % igrave
3953\DeclareTextCompositeCommand{\'}{PD1}{i}{\355} % iacute
3954\DeclareTextCompositeCommand{\'}{PD1}{\i}{\355} % iacute
3955\DeclareTextCompositeCommand{\^}{PD1}{i}{\356} % icircumflex
3956\DeclareTextCompositeCommand{\^}{PD1}{\i}{\356} % icircumflex
3957\DeclareTextCompositeCommand{\"}{PD1}{i}{\357} % idieresis
3958\DeclareTextCompositeCommand{\"}{PD1}{\i}{\357} % idieresis
3959\DeclareTextCommand{\dh}{PD1}{\360} % eth
3960\DeclareTextCompositeCommand{\~}{PD1}{n}{\361} % ntilde
3961\DeclareTextCompositeCommand{\`}{PD1}{o}{\362} % ograve
3962\DeclareTextCompositeCommand{\'}{PD1}{o}{\363} % oacute
3963\DeclareTextCompositeCommand{\^}{PD1}{o}{\364} % ocircumflex
3964\DeclareTextCompositeCommand{\~}{PD1}{o}{\365} % otilde
3965\DeclareTextCompositeCommand{\"}{PD1}{o}{\366} % odieresis
3966\DeclareTextCommand{\textdivide}{PD1}{\367} % divide
3967\DeclareTextCommand{\o}{PD1}{\370} % oslash
3968\DeclareTextCompositeCommand{\`}{PD1}{u}{\371} % ugrave
3969\DeclareTextCompositeCommand{\'}{PD1}{u}{\372} % uacute
3970\DeclareTextCompositeCommand{\^}{PD1}{u}{\373} % ucircumflex
3971\DeclareTextCompositeCommand{\"}{PD1}{u}{\374} % udieresis
3972\DeclareTextCompositeCommand{\'}{PD1}{y}{\375} % yacute
3973\DeclareTextCommand{\th}{PD1}{\376} % thorn
3974\DeclareTextCompositeCommand{\"}{PD1}{y}{\377} % ydieresis

3975%

3976\DeclareTextCommand{\SS}{PD1}{SS}
3977\DeclareTextCommand{\textcelsius}{PD1}{\textdegree C}

3978%

3979% Aliases (german.sty)
3980\DeclareTextCommand{\textglqq}{PD1}{\quotedblbase}
3981\DeclareTextCommand{\textgrqq}{PD1}{\textquotedblleft}
3982\DeclareTextCommand{\textglq}{PD1}{\quotesinglbase}
3983\DeclareTextCommand{\textgrq}{PD1}{\textquoteleft}
3984\DeclareTextCommand{\textflqq}{PD1}{\guillemotleft}
3985\DeclareTextCommand{\textfrqq}{PD1}{\guillemotright}
3986\DeclareTextCommand{\textflq}{PD1}{\guilsinglleft}
3987\DeclareTextCommand{\textfrq}{PD1}{\guilsinglright}

3988%

3989% Aliases (math names)
3990\DeclareTextCommand{\textneg}{PD1}{\textlogicalnot}
3991\DeclareTextCommand{\texttimes}{PD1}{\textmultiply}
3992\DeclareTextCommand{\textdiv}{PD1}{\textdivide}
3993\DeclareTextCommand{\textpm}{PD1}{\textplusminus}
3994\DeclareTextCommand{\textcdot}{PD1}{\textperiodcentered}
3995\DeclareTextCommand{\textbeta}{PD1}{\ss}

3996⟨/pd1enc⟩