Debian Codegraph @

texmf-dist/source/latex/hyper/hyper.dtx

raw
1 % \iffalse
2 %% File: hyper.dtx Copyright (C) 1995--1999 Michael Mehlich
3 %% This program can be redistributed and/or modified under the terms
4 %% of the LaTeX Project Public License Distributed from CTAN
5 %% archives in directory macros/latex/base/lppl.txt; either
6 %% version 1 of the License, or any later version.
7 %<*driver>
8 \documentclass[letterpaper]{ltxdoc}
9 \usepackage{tabularx}
10 \makeatletter
11 \let\TX@vwarn\relax
12 \makeatother
13 \IfFileExists{hyper.sty}{%
14 \message{*** Generating hypertext documentation ***}
15 \usepackage[color,fixhyperbox,pagetop]{hyper}%
16 }{%
17 \def\hyperURL##1##2##3##4{##4}
18 }
19 \def\AmS{{\protect\usefont{OMS}{cmsy}{m}{n}%
20 A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}}
21 \def\amslatex{{\protect\AmS-\protect\LaTeXe}}
22 \def\CWEB{{\scshape Cweb}}
23 %</driver>
24 \def\fileversion{V4.2d}
25 \def\filedate{1999/03/09}
26 \def\docdate{1999/03/09}
27 %<*driver>
28 \begin{document}
29 \hbadness=10000
30 \hfuzz100pt
31 \title{HyperText Documents with \LaTeXe\\\fileversion}
32 \author{Michael Mehlich}
33 \date{\docdate}
34 \maketitle
35 \tableofcontents
36 \DocInput{hyper.dtx}
37 \end{document}
38 %</driver>
39 % \fi
40 % \CheckSum{5034}
41 %%
42 %% \CharacterTable
43 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
44 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
45 %% Digits \0\1\2\3\4\5\6\7\8\9
46 %% Exclamation \! Double quote \" Hash (number) \#
47 %% Dollar \$ Percent \% Ampersand \&
48 %% Acute accent \' Left paren \( Right paren \)
49 %% Asterisk \* Plus \+ Comma \,
50 %% Minus \- Point \. Solidus \/
51 %% Colon \: Semicolon \; Less than \<
52 %% Equals \= Greater than \> Question mark \?
53 %% Commercial at \@ Left bracket \[ Backslash \\
54 %% Right bracket \] Circumflex \^ Underscore \_
55 %% Grave accent \` Left brace \{ Vertical bar \|
56 %% Right brace \} Tilde \~}
57 %%
58 % \MakeShortVerb{|}
59 %
60 % \title{Hyper\LaTeXe}
61 % \maketitle
62 %
63 % \section{Introduction}
64 % Traditional texts only have a linear structure given by its series of
65 % characters. But this is not sufficient for any kind of documents one
66 % may think of. Thus, recently the number of documents using a more
67 % complex graphical structure (called ``hyper text'' documents) have
68 % increased.
69 %
70 % This package provides the generation of such documents based on the
71 % already given structure of \LaTeXe{}-documents without the document
72 % writer having to consider new commands.
73 %
74 % \section{Usage}
75 %
76 % Just insert |\usepackage{hyper}| in the preamble of your
77 % \LaTeX2e--document as the last package to be loaded.\par
78 % If you use the theorem package define the theorems via
79 % |\newtheorem| after inserting the hyper package.\medskip
80 %
81 % You may also give some options for the package, i.e.\ instead of
82 % the command above you may use |\usepackage[<option list>]{hyper}|
83 % in your preamble.\medskip
84 %
85 % \noindent Currently the following options are known:
86 % \begin{itemize}
87 % \item |yes|, |no|
88 % determine whether the hypertext marks are inserted
89 % or not (default is |yes|)
90 % \item |fixhyperbox|
91 % modifies the position of the html-marks in the |dvi|-file
92 % so that |dvips| creates the right bounding boxes for
93 % the hyper references; it is highly recommended to use
94 % this option (though for compatibility reasons with earlier
95 % versions this is not the default setting); note, that the
96 % text of the reference is packed into a horizontal box (|\hbox|)
97 % due to the need of measuring its size
98 % \item |black|, |gray|, |color|
99 % determine the colors anchors and references
100 % are printed in (default is |black|);\newline
101 % the colors can be changed by
102 % |\definecolor{refcolor}{rgb}{|\emph{r}|,|\emph{g}|,|\emph{b}|}|
103 % for references,
104 % |\definecolor{undefrefcolor}{rgb}{|\emph{r}|,|\emph{g}|,|\emph{b}|}|
105 % for unresolved references, and
106 % |\definecolor{anchorcolor}{rgb}{|\emph{r}|,|\emph{g}|,|\emph{b}|}|
107 % for anchors where \emph{r}, \emph{g}, \emph{b} stand for the
108 % red, green, and blue, respectively, values (between 0.0 and 1.0)
109 % of the color (cf.\ |graphics| package)
110 % \item |pagenumber|, |pagetop|
111 % determine whether a page number refers to the page
112 % number of the respectively page or to the top of
113 % the page
114 % \item |indexcmds| has to be given explicitely whenever an
115 % index or glossary file has been created using
116 % this package if the file is not regenerated using
117 % the commands |\makeindex| and |\makeglossary|,
118 % respectively.
119 % \item |backcitepages|, |backcitesections| introduce back references
120 % from the bibliography to the pages and sections,
121 % respectively, they have been cited in
122 % \item |amsart|, |amsbook|, |amsdtx|, |amsldoc|, |amsproc|, |article|,
123 % |book|, |cweb|, |letter|, |ltxdoc|, |ltxguide|, |ltnews|, |proc|,
124 % |report|, |slides|
125 % determine the document class for which the
126 % modifications are loaded
127 % (default is the document class given via
128 % |\documentclass| if it can be derived)
129 % \item |leqno|
130 % adds modifications for the document class option
131 % |leqno| (will be used automagically for known
132 % document classes)
133 % \item |amsmath|, |amstex|, |amsthm|, |doc|, |fancyheadings|, |ftnright|, |longtable|,
134 % |natbib|, |subeqnarray|, |theorem|, |upref|
135 % add modifications for the corresponding package
136 % (will be used automagically)
137 % \item |xr|
138 % add modifications for the package |xr| and
139 % redefine it's internal macro |\externaldocument|
140 % addint a new parameter determining the URL--address
141 % of the document for the cross references used
142 % (will be used automagically)
143 % \item |harvard| add modifications for the respectively packages that
144 % are part of the distribution but provided by other
145 % authors
146 % \item |<other>|
147 % add a modification file |<other>.hyp| that has to
148 % be provided by yourself
149 % \end{itemize}
150 %
151 % \section{Macros Provided}
152 % The following macros are defined by the package and may be used:
153 % \begin{itemize}
154 % \item |\hyperanchor#1#2|
155 % lets |#1| being the hypertext anchor for |#2|
156 % (|#1| may neither be a natural number nor beginning
157 % with |page.| or |fn.|)
158 % \item |\blindhyperanchor#1|
159 % lets |#1| being a hypertext anchor
160 % (|#1| may neither be a natural number nor beginning
161 % with |page.| or |fn.|)
162 % \item |\hyperreference#1#2|
163 % lets |#2| being a hypertext reference to the anchor |#1|,
164 % (|#1| may not start with a |[|)
165 % \item |\hyperURL#1#2#3#4|
166 % lets |#4| being a hypertext reference to an external URL
167 % with type |#1|, domain |#2|, and document |#3|, i.e.\
168 % to the URL |#1://#2/#3|
169 % \item |\labeltext#1#2|
170 % lets |#1| being the hypertext capable (\LaTeXe) reference to the text |#2|
171 % and prints |#2|
172 % \item |\noref[#1]#2|
173 % lets |#1| being a hypertext reference to the
174 % anchor defined by the \LaTeXe reference |#2| without printing the reference
175 % (|#1| is not optional!)
176 % \item |\ref[#1]#2|
177 % is the same as \LaTeXe's original |#1~\ref{#2}| except that
178 % the hypertext reference is provided from the complete
179 % |#1~\ref{#2}| instead of |\ref{#2}| only
180 % \item |\pageref[#1]#2|
181 % is the same as |\ref| except that we get a reference to the
182 % page number
183 % \item |\refcurrent#1|
184 % lets |#1| being a hypertext reference to the last numerical anchor
185 % that has been generated
186 % \item |\refnext#1|
187 % lets |#1| being a hypertext reference to the next numerical anchor
188 % that will be generated
189 % \end{itemize}
190 %
191 % \noindent The following macros are redefined when using the
192 % corresponding packages:
193 % \begin{itemize}
194 % \item for |xr|:
195 % \begin{itemize}
196 % \item |\externaldocument(#1)[#2]#3|, |\externaldocument[#1](#2)#3|
197 % are equivalent to the original |\externaldocument| of the
198 % |xr|--package except for the additional parameter surrounded
199 % by |(||)| determining the URL--address of the external
200 % document (the URL--type |file:| is added automagically)
201 % (default is |#3.dvi|)
202 % \end{itemize}
203 % \end{itemize}
204 %
205 % \noindent The following macros are provided when using the option |backcitepages|
206 % or |backcitesections| (definitions show default value):
207 % \begin{itemize}
208 % \item |\def\hyperbackcitepage{Cited on page~}| is the text preceeding a
209 % back reference to a single page number.
210 % \item |\def\hyperbackcitepages{Cited on pages~}| is the text preceeding a
211 % back reference to multiple page numbers.
212 % \item |\def\hyperbackcitesection{Cited in~}| is the text preceeding a
213 % back reference to a single section reference.
214 % \item |\def\hyperbackcitesections{Cited in~}| is the text preceeding a
215 % back reference to multiple section references.
216 % \item |\def\hyperbackcitenormalseparator{, }| is the text between two
217 % page numbers or section references (except for the last pair).
218 % \item |\def\hyperbackcitefinalseparatorpair{ and~}| is the text
219 % between the page numbers or section references if there are
220 % exactly two entries.
221 % \item |\def\hyperbackcitefinalseparatorlist{, and~}| is the text
222 % between the last pair page numbers or section references if
223 % there are more than two entries.
224 % \end{itemize}
225 % \section{Viewing Hyper\LaTeXe--documents}
226 %
227 % There are several methods that can be used to view the dvi--documents
228 % with html--marks resulting from using this package.
229 %
230 % \begin{itemize}
231 % \item For UNIX$^{\mathrm{TM}}$--systems with the graphical user interface
232 % |X| there is a modification of |xdvi| called |xhdvi| available at any CTAN-site.
233 % \item For systems running under NeXTSTEP$^{\mathrm{TM}}$ there exists a
234 % Hyper\TeX-capable modification of |TeXview|, called |HyperTeXview|.
235 % \item There exists a variant of |dvips| (called |dvihps|) translating hyperdvi--files to
236 % hyperps--files containing the html--marks when using the parameter |-z|.
237 % (|emtex| provides this feature with |dvips|).\par
238 % \noindent The resulting files can be viewed using a HyperPS-capable Postscript-viewer,
239 % (e.g. a hacked version of |ghostview| (for UNIX$^{\mathrm{TM}}$) or the actual |gsview|
240 % (for Windows$^{\mathrm{TM}}$))
241 % \item Another way is to use |dvihps| to get a HyperPS--file ready to be handled by
242 % the Acrobat$^{\mathrm{TM}}$--distiller available from Adobe
243 % or by ghostscript's |pdfwriter|--output--device
244 % which both can translate hyperps--files to |pdf|--files that can be viewed
245 % using an Acrobat$^{\mathrm{TM}}$--reader or any other |pdf|--reader.
246 % \end{itemize}
247 %
248 % \section{Bugs}
249 % Currently there are only a few known problems. Unfortunately they
250 % cannot be avoided. You have to care about this:
251 % \begin{itemize}
252 % \item If you write your bibliographies with the |thebibliograpy|-environment
253 % by hand (not using bibtex) you may get an error message due to a
254 % command not matching its definition. This can be avoided by providing
255 % an empty line or a |\par| command at the end of each bibliographic entry
256 % (with |\bibitem|) including the last entry before |\end{thebibliography}|.
257 % \item If you include an index or glossary file into the current
258 % document you may get a message from \LaTeX{} like
259 % |Undefined control sequence.| $\ldots$ |\hyperpage|.
260 % This is due to you not using |\makeindex| or |\makeglossary|
261 % in the preamble. In this case just add the package option
262 % |indexcmds| when loading the hyper--package.
263 % \item In indexing commands you can't use |]| without surrounding braces.
264 % If you do, \TeX{} will parse the command in a wrong way.
265 % To get the sorting of the index right you therefore should use
266 % |\index{A[zzzzB@A{]}B}| instead of |\index{A]B}|.
267 % \item Similarly, a protected $\mid$, i.e.\ |"|$\mid$ is not handled
268 % correctly. Use a similar method as above to circumnavigate
269 % this problem.
270 % \end{itemize}
271 % \vskip0.5em
272 % \noindent There is another problem in connection with (a html-capable) |dvips| and paper formats different
273 % from |letter|. Apparently the positions for the |html|-specials are not computed correctly. The package
274 % provides a perl-script that allows to modify the positions of these specials.
275 % When using e.g.\ a4paper you have to call |perl dvi2pdf.pl -z "-s0,50" -nopdf <normal parameters to dvips>|
276 % to create an appropriate ps-file.
277 % Note, that the script |dvi2pdf.pl| has to be configured
278 % and has only been tested on a Windows$^{\mathrm{TM}}$ system.
279 % \vskip0.5em
280 % \noindent Other problems are not known so far. But surely there are some
281 % (otherwise the history would not be already that long).
282 % Thus, if you detect one please report it with the package version and
283 % a small example to\medskip
284 %
285 % | Michael Mehlich|\par
286 % | [email protected]|
287 %
288 % \section{Related Work, Acknowledgement}
289 % Sebastian Rahtz has written another package for adding
290 % HyperText--capabilities to \LaTeX{}. His package
291 % |hyperref| has been developed in parallel with this one
292 % and uses a slightly different realization for getting
293 % similar results. Some of the ideas found there have been
294 % added to this package, too.
295 % Thus, I have to give a special thank to him.
296 %
297 % Thanks also to Ulrich Fuchs for further suggestions.
298 %
299 % \StopEventually{}
300 %
301 % \section{History}
302 % \leavevmode
303 % \begin{tabularx}{\textwidth}{|c|l|X|r@{.}l|}
304 % \hline
305 % When & By & What & \multicolumn{2}{|c|}{V}
306 % \\ \hline\hline
307 % 1998/10/29 & Michael Mehlich &
308 % fixed macro name for |amsthm|
309 % & 4&2d
310 % \\ \hline
311 % 1998/10/28 & Michael Mehlich &
312 % corrected problem with wrong references produced
313 % & 4&2c
314 % \\ \hline
315 % 1997/09/22 & Michael Mehlich &
316 % corrected problem with |\uppercase| and |\lowercase| in internally used names
317 % & 4&2b
318 % \\ \hline
319 % 1997/09/15 & Michael Mehlich &
320 % corrected problem with |\noalign| in |eqnarray| environment
321 % & 4&2a
322 % \\ \hline
323 % 1997/08/28 & Michael Mehlich &
324 % corrected definition of new hyper anchor name to appear
325 % only locally within |\labeltext|\newline
326 % redefined |\label| for |amstex.sty|\newline
327 % added support for package |subeqnarray|
328 % & 4&2
329 % \\ \hline
330 % 1997/08/24 & Michael Mehlich &
331 % reduced problems when adding or removing the |hyper|-package\newline
332 % patched around problem in interaction of option |fixhyperbox| with
333 % |dvips|\newline
334 % problem with undefined hyper references when using cross references
335 % provided by the package |xr| resolved
336 % & 4&1
337 % \\ \hline
338 % 1997/07/14 & Michael Mehlich &
339 % corrected bug when creating cross-references between documents
340 % (bug was introduced when introducing resolution of nested html-marks)
341 % & 4&0h
342 % \\ \hline
343 % 1997/05/28 & Michael Mehlich &
344 % ensured hyper references for footnotes being created
345 % even if footnote is moved to the next page
346 % (but not further)\newline
347 % corrected marks introduced by the index environment |\theindex|
348 % in the classes |report| and |book|\newline
349 % changed mechanism for change flags
350 % & 4&0g
351 % \\ \hline
352 % 1997/05/07 & Michael Mehlich &
353 % redirected output for special hyper informations to main auxiliary file
354 % & 4&0f
355 % \\ \hline
356 % 1997/04/25 & Michael Mehlich &
357 % changed catcodes for reading the parameters of |\hyperURL|
358 % & 4&0e
359 % \\ \hline
360 % 1997/04/17 & Michael Mehlich &
361 % resolved some problem with the |cweb|-package modifications
362 % & 4&0d
363 % \\ \hline
364 % 1997/03/25 & Michael Mehlich &
365 % resolved problem with wrong footnote references when using package |footnpag|
366 % (this also corrects the former wrong naming of anchors for footnotes)
367 % & 4&0c
368 % \\ \hline
369 % 1997/03/21 & Michael Mehlich &
370 % removed bug in interaction of package with |cweb|'s chunk naming mechanism
371 % & 4&0b
372 % \\ \hline
373 % \end{tabularx}
374 % \newpage
375 % \begin{tabularx}{\textwidth}{|c|l|X|r@{.}l|}
376 % \hline
377 % When & By & What & \multicolumn{2}{|c|}{V}
378 % \\ \hline\hline
379 % 1997/03/08 & Michael Mehlich &
380 % added color for external URL added by |\hyperURL|
381 % & 4&0a
382 % \\ \hline
383 % 1997/03/01 & Michael Mehlich &
384 % added check for anchor existing before introducing reference to it\newline
385 % added check whether the anchors have changed beween two \LaTeXe\ runs\newline
386 % added handling of nested html-marks by unnesting (shit, this conflicts with
387 % the option |fixhyperbox|)\newline
388 % added option |fixhyperbox|\newline
389 % changed creation of anchor names for footnotes due to illegal names and
390 % duplicated names in the old version\newline
391 % improved extension package |backcites|\newline
392 % added handling of sorted citations for package |natbib|\newline
393 % changed macros for package |natbib|\newline
394 % added support for common package |fancyheadings| (this was needed for handling
395 % page references to page numbers when creating pages with empty headers
396 % and footers)\newline
397 % modified header and footer modification for inserting appropriate
398 % anchors and references
399 % & 4&0
400 % \\ \hline
401 % 1997/02/03 & Michael Mehlich &
402 % allow |\makeindex| and |\makeglossary| to appear after including the package\newline
403 % corrected mishandling of |pagetop|\newline
404 % changed colors for references and anchors\newline
405 % added documentation about how to change colors for colored references and anchors
406 % & 3&0c
407 % \\ \hline
408 % 1997/01/12 & Michael Mehlich &
409 % corrected problem with loop occurring on even pages
410 % & 3&0b
411 % \\ \hline
412 % 1996/11/01 & Michael Mehlich &
413 % corrected problem with empty headings causing an overful hbox\newline
414 % bug of having two page anchors on empty pages in case of |pagetop| removed\newline
415 % adapted to current version of |natbib|
416 % & 3&0a
417 % \\ \hline
418 % \end{tabularx}
419 % \newpage
420 % \begin{tabularx}{\textwidth}{|c|l|X|r@{.}l|}
421 % \hline
422 % When & By & What & \multicolumn{2}{|c|}{V}
423 % \\ \hline\hline
424 % 1996/10/26 & Michael Mehlich &
425 % added code for bibliographic references with |natbib|\newline
426 % added possibility of let pagelinks go to the top of the page
427 % & 3&0
428 % \\ \hline
429 % 1996/10/21 & Michael Mehlich &
430 % corrected problem with empty page style
431 % & 2&8a
432 % \\ \hline
433 % 1996/01/07 & Michael Mehlich &
434 % adapted to current version of latex
435 % & 2&8
436 % \\ \hline
437 % 1995/12/19 & Michael Mehlich &
438 % adapted to current version of the cweb--package
439 % & 2&7b
440 % \\ \hline
441 % 1995/10/22 & Michael Mehlich &
442 % made reference commands robust
443 % & 2&7a
444 % \\ \hline
445 % 1995/09/24 & Michael Mehlich &
446 % added support for the \CWEB\ document class
447 % & 2&7
448 % \\ \hline
449 % 1995/07/13 & Michael Mehlich &
450 % |\hyper@next| changed to |\fragilerefnext| to avoid problems when writing
451 % the command into the |.toc|--file
452 % & 2&6a
453 % \\ \hline
454 % 1995/07/06 & Michael Mehlich &
455 % |\hyperbackcite| occurred mistakenly in each file\newline
456 % bug fix in redefinition of |theindex|-environment in |doc.hyp|\newline
457 % handling of footnotes corrected\newline
458 % modified |\@xeqncr| instead of |\@eqncr|\newline
459 % adapted redefinition of captions for |longtable| to current
460 % version of |longtable|
461 % & 2&6
462 % \\ \hline
463 % 1995/07/04 & Michael Mehlich &
464 % correction of optional parameter of |\\| in eqnarray--environment
465 % mistakenly ignored
466 % & 2&5d
467 % \\ \hline
468 % 1995/06/14 & Michael Mehlich &
469 % corrected |\hyper@oddfoot|
470 % & 2&5c
471 % \\ \hline
472 % 1995/05/29 & Michael Mehlich &
473 % added support for contribution |harvard.hyp|,
474 % changed automatical uploading of packages to
475 % conditional uploading (tests if the package
476 % really exists)
477 % & 2&5b
478 % \\ \hline
479 % 1995/05/23 & Michael Mehlich &
480 % changed wrong page numbers for certain
481 % document classes
482 % & 2&5a
483 % \\ \hline
484 % 1995/05/10 & Michael Mehlich &
485 % added support for backcites
486 % &2&5
487 % \\ \hline
488 % 1995/05/08 & Michael Mehlich &
489 % internal handling of references to pages simplified\newline
490 % bug in |xr.hyp| fixed\newline
491 % anchor on empty pages added
492 % & 2&4c
493 % \\ \hline
494 % 1995/05/07 & Michael Mehlich &
495 % let |\item| accept |]| in optional argument
496 % & 2&4b
497 % \\ \hline
498 % \end{tabularx}
499 % \newpage
500 % \begin{tabularx}{\textwidth}{|c|l|X|r@{.}l|}
501 % \hline
502 % When & By & What & \multicolumn{2}{|c|}{V}
503 % \\ \hline\hline
504 % 1995/04/20 & Michael Mehlich &
505 % added new option |indexcmds|
506 % & 2&4a
507 % \\ \hline
508 % 1995/04/20 & Michael Mehlich &
509 % added support for |amstex|
510 % & 2&4
511 % \\ \hline
512 % 1995/04/18 & Michael Mehlich &
513 % corrected bug in index (reported by Ulrich Fuchs)
514 % & 2&3a
515 % \\ \hline
516 % 1995/02/12 & Michael Mehlich &
517 % support for package |xr| added\newline
518 % handling of options improved
519 % & 2&3
520 % \\ \hline
521 % 1995/02/11 & Michael Mehlich &
522 % definition of |\label| corrected (bug introduced at 1995/01/31)
523 % & 2&2b
524 % \\ \hline
525 % 1995/02/02 & Michael Mehlich &
526 % macros for |amsthm| changed according to new definition in amslatex
527 % & 2&2a
528 % \\ \hline
529 % 1995/02/01 & Michael Mehlich &
530 % support for package |amslatex| added\newline
531 % support for package |longtable| added
532 % & 2&2
533 % \\ \hline
534 % 1995/01/31 & Michael Mehlich &
535 % support for package |theorem| added\newline
536 % catcodes of \verb+|+, |@|, and |!| for parsing the parameters of
537 % |\index| and |\glossary| changed\newline
538 % |\@makecaption| modified\newline
539 % hypertext references in |eqnarray| corrected\newline
540 % redefinition of |\label| changed
541 % & 2&1
542 % \\ \hline
543 % 1995/01/30 & Michael Mehlich &
544 % handling of series of page numbers for index/glossary added\newline
545 % |\protected@write| stopped from inserting an extra space
546 % & 2&0b
547 % \\ \hline
548 % 1995/01/29 & Michael Mehlich &
549 % references from headers to sections for bibliography, index, glossary, and
550 % table of contents added
551 % & 2&0a
552 % \\ \hline
553 % 1995/01/26 & Michael Mehlich &
554 % options to be handled are determined automagically now\newline
555 % protected the anchor and reference adding macros instead of {\tt"}\newline
556 % some internal algorithms changed\newline
557 % some macro--names changed
558 % & 2&0
559 % \\ \hline
560 % 1995/01/25 & Michael Mehlich & handling of index and glossary added & 1&3
561 % \\ \hline
562 % 1995/01/24 & Michael Mehlich &
563 % handling of options changed\newline
564 % color support for anchors and references added
565 % & 1&2
566 % \\ \hline
567 % 1995/01/24 & Michael Mehlich &
568 % |\noref| added\newline
569 % bug in writing wrong page numbers to auxiliary files removed
570 % & 1&1
571 % \\ \hline
572 % 1995/01/20 & Michael Mehlich &
573 % protected {\tt"} for compatibility with the package |german.sty|
574 % & 1&0g
575 % \\ \hline
576 % 1995/01/12 & Michael Mehlich &
577 % first official version
578 % & 1&0
579 % \\ \hline
580 % \end{tabularx}
581 %
582 % \clearpage
583 %
584 % \section{The Realization}
585 %
586 % \subsection{The Package Header}
587 % We need a version of \LaTeX2e{} dated with June 1, 1995 or newer.
588 % Thus, we just demand it.
589 % \begin{macrocode}
590 %<*hyper>
591 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
592 % \end{macrocode}
593 % Now we have to introduce ourself.
594 % \begin{macrocode}
595 \ProvidesPackage{hyper}[\filedate\space HyperLaTeX2e extension]
596 % \end{macrocode}
597 %
598 % \subsection{Special Characters}
599 % First of all let us reserve some characters which are important and are
600 % not preserved by every other package.
601 % \begin{macrocode}
602 \bgroup
603 \catcode`\!00\relax
604 \catcode`\"12\relax
605 !catcode`!\12!relax
606 !gdef!hyper@quote{"}
607 !gdef!hyper@backslash{\}
608 !global!edef!hyper@hash{!string#}
609 !global!edef!hyper@tilde{!string~}
610 !egroup
611 % \end{macrocode}
612 % For compatibility with other packages this may need to be extended.
613 % But for now we suppose this being sufficient.
614 %
615 % \subsection{The Basic Anchor/Reference-Entries}
616 % Let us set the output channel for special hyper informations first.
617 % \begin{macrocode}
618 \AtBeginDocument{\let\hyper@auxout\@auxout}
619 % \end{macrocode}
620 % We have to define some macros that allow us to insert the hypertext marks
621 % for anchors and references into the resulting dvi-file. This can be
622 % done by using the |\special|--macro.\par
623 % \noindent But before introducing them, we need some auxiliaries that allow
624 % us to write the hyper anchors to the auxiliary file and reread them at
625 % program start. This way we can check, whether we use a reference to an
626 % existing anchor; thus we can avoid introducing invalid references.
627 % This mechanism can additionally be used to check whether the hyper anchors
628 % may have changed between two \LaTeXe\ runs.\par
629 % \noindent This is also a good place to recheck whether there have been some
630 % undefined or multiply defined hyper anchors or forwarded references
631 % used in hyper references.
632 % \begin{macrocode}
633 \newcount\hyper@changed
634 \global\hyper@changed=0
635 \newcount\hyper@cnt%careful, this is used as a temporary counter in various places
636 \def\hyper@change#1{%set change value (powers of 2 only), in use: 1,2,4,8
637 \hyper@cnt\hyper@changed\relax%
638 \divide\hyper@cnt#1\relax%
639 \ifodd\hyper@cnt\else%
640 \global\advance\hyper@changed#1\relax%
641 \fi%
642 }
643 \def\newhyper#1#2{%
644 \bgroup%
645 \def\uppercase{<UPPERCASE>}%
646 \def\lowercase{<LOWERCASE>}%
647 \expandafter\ifx\csname hyper@#1\endcsname\relax\else%
648 \hyper@change2\relax%
649 \PackageWarningNoLine{hyper}%
650 {Hyper anchor #1 multiply defined}%
651 \fi%
652 \expandafter\global\expandafter\def\csname hyper@#1\endcsname{#2}%
653 \egroup%
654 }
655 \def\newhyper@check#1#2{%
656 \def\reserved@a{#2}%
657 \bgroup%
658 \def\uppercase{<UPPERCASE>}%
659 \def\lowercase{<LOWERCASE>}%
660 \expandafter\ifx\csname hyper@#1\endcsname\reserved@a\else%
661 \expandafter\ifx\csname hyper@new@#1\endcsname\reserved@a\else%
662 \global\hyper@change4\relax%
663 \fi%
664 \fi%
665 \egroup%
666 }
667 \let\hyper@enddocument\enddocument
668 \def\hyper@check@end{%
669 \ifodd\hyper@changed%1
670 \PackageWarningNoLine{hyper}{There were undefined hyper references}%
671 \fi%
672 \divide\hyper@changed2\relax%
673 \ifodd\hyper@changed%2
674 \PackageWarningNoLine{hyper}%
675 {There were multiply defined hyper anchors}%
676 \fi%
677 \divide\hyper@changed2\relax%
678 \ifodd\hyper@changed%4
679 \PackageWarningNoLine{hyper}%
680 {Hyper anchor(s) may have changed.\MessageBreak
681 Rerun to get hyper references right}%
682 \fi%
683 \divide\hyper@changed2\relax%
684 \ifodd\hyper@changed%8
685 \PackageWarningNoLine{hyper}%
686 {Footnote hyper reference(s) may have been forwarded\MessageBreak
687 to next page.\MessageBreak
688 Check result to ensure this being correct.\MessageBreak
689 If not rerun to get footnote hyper references right}%
690 \fi%
691 }
692 \def\enddocument{%
693 \let\hyper@@end\@@end%
694 \def\@@end{\hyper@check@end\hyper@@end}%
695 \let\newhyper\newhyper@check%
696 \hyper@enddocument%
697 }
698 \def\hyper@to@aux#1{%
699 \bgroup%
700 \def\uppercase{<UPPERCASE>}%
701 \def\lowercase{<LOWERCASE>}%
702 \expandafter\ifx\csname hyper@#1\endcsname\relax%
703 \expandafter\ifx\csname hyper@new@#1\endcsname\relax%
704 \expandafter\global%
705 \expandafter\expandafter\expandafter\def\csname hyper@new@#1\endcsname%
706 {{\@currentlabel}{\thepage}}%
707 \fi%
708 \fi%
709 \@bsphack%
710 \protected@write%
711 \hyper@auxout%
712 {}%
713 {\string\newhyper%
714 {#1}%
715 {{\@currentlabel}{\thepage}}%
716 }%
717 \@esphack%
718 \egroup%
719 }
720 % \end{macrocode}
721 % \noindent The macros |\hyperreference| |\hyperpagereference| and insert a html-reference
722 % to an internal label except when the first parameter begins with |[|. Then the
723 % parameter must have the form |[#1][#2]| where |#1| is an external URL and
724 % |#2| an anchor within this URL. This is used when generating cross references
725 % between documents.\par
726 % \noindent The whole stuff is complicated by two problems: We have to avoid
727 % nesting of the html-markups in the dvi-file and we have to tell |dvips| about the
728 % right dimension of the box by modifying the positions of the specials from which
729 % |dvips| gets the bounding box for a hyper reference (The latter one is optionally
730 % done when passing the corresponding parameter to the package).
731 % \begin{macrocode}
732 \newbox\hyper@box@text
733 \newbox\hyper@box@ref
734 \newdimen\hyper@fixdim
735 \newif\if@hyper@is@active
736 \@hyper@is@activefalse
737 \def\hyper@html{html:}
738 \bgroup
739 \catcode`\<12\catcode`\>12\relax%
740 \catcode`\:12\catcode`\=12\catcode`\/12\relax%
741 \gdef\hyper{%
742 \def\hyper@unnested@special##1##2##3{%
743 \special{\hyper@html##1}##3\special{\hyper@html##2}%
744 }%
745 \def\hyper@unnested@special@anchor@nofix##1##2##3{%
746 \special{\hyper@html##1}\hyper@anchor@color{##3}\special{\hyper@html##2}%
747 }%
748 \def\hyper@unnested@special@reference@nofix##1##2##3{%
749 \special{\hyper@html##1}\hyper@ref@color{##3}\special{\hyper@html##2}%
750 }%
751 \def\hyper@unnested@special##1##2{%
752 \hyper@fixdim\ht\hyper@box@text%
753 \advance\hyper@fixdim\dp\hyper@box@text%
754 \advance\hyper@fixdim-8pt%
755 \setbox\hyper@box@ref=\hbox{%
756 \parindent0pt\leftskip0pt\rightskip0pt%
757 \leftmargin0pt\rightmargin\wd\hyper@box@text\advance\rightmargin0.5pt%
758 \linewidth\rightmargin\textwidth\rightmargin%
759 \noindent\vbox{%
760 \hrule height \hyper@fixdim width 0pt%
761 \special{\hyper@html##1}\hbox to\linewidth{\hfill}%
762 \hrule height -\hyper@fixdim width 0pt%
763 \hbox to\linewidth{\hfill\special{\hyper@html##2}}%
764 \hrule height 0pt width 0pt%
765 }%
766 }%
767 \ht\hyper@box@ref0pt%
768 \dp\hyper@box@ref0pt%
769 \wd\hyper@box@ref0pt%
770 \hyper@fixdim\ht\hyper@box@text%
771 \advance\hyper@fixdim-8pt%
772 \hbox{\raise\hyper@fixdim\copy\hyper@box@ref\copy\hyper@box@text}%
773 \setbox\hyper@box@ref=\hbox{}%
774 }%
775 \def\hyper@unnested@special@anchor@fix##1##2##3{%
776 \setbox\hyper@box@text=\hbox{\hyper@anchor@color{##3}}%
777 \hyper@unnested@special{##1}{##2}%
778 \setbox\hyper@box@text=\hbox{}%
779 }%
780 \def\hyper@unnested@special@reference@fix##1##2##3{%
781 \setbox\hyper@box@text=\hbox{\hyper@ref@color{##3}}%
782 \hyper@unnested@special{##1}{##2}%
783 \setbox\hyper@box@text=\hbox{}%
784 }
785 \let\hyper@unnested@special@reference\hyper@unnested@special@reference@nofix%
786 \let\hyper@unnested@special@anchor\hyper@unnested@special@anchor@nofix%
787 \def\hyper@nested@special##1##2##3##4{%
788 \ifx\hyper@unnested@special@reference\hyper@unnested@special@reference@nofix%
789 \if@hyper@is@active%
790 \expandafter\expandafter\expandafter%
791 \special\expandafter\@firstoftwo\hyper@special@last%
792 {\def\hyper@special@last{{{\hyper@html##4}}{{\hyper@html##2}}}%
793 ##1{##2}{##4}{##3}%
794 }%
795 \expandafter\expandafter\expandafter%
796 \special\expandafter\@secondoftwo\hyper@special@last%
797 \else%
798 \def\hyper@special@last{{{\hyper@html##4}}{{\hyper@html##2}}}%
799 \@hyper@is@activetrue\relax%
800 ##1{##2}{##4}{##3}%
801 \@hyper@is@activefalse\relax%
802 \fi%
803 \else%
804 \if@hyper@is@active%
805 ##1{##2}{##4}{##3}%
806 \else%
807 \@hyper@is@activetrue\relax%
808 ##1{##2}{##4}{##3}%
809 \@hyper@is@activefalse\relax%
810 \fi%
811 \fi%
812 }%
813 \def\hyper@special@anchor{\hyper@nested@special\hyper@unnested@special@anchor}
814 \def\hyper@special@reference{\hyper@nested@special\hyper@unnested@special@reference}
815 \def\f@hyper@ref@ext[##1][##2][##3]\end@hyper@ref##4{%
816 \ifvmode\leavevmode\fi%
817 \hyper@special@reference%
818 {<a href=\hyper@quote##1##2\hyper@hash##3\hyper@quote>}%
819 {##4}%
820 {</a>}%
821 }%
822 \def\hyper@check@fn##1.##2.##3.##4\hyper@check@fn{%
823 \def\hyper@tmpa{fn}%mark for link to footnote
824 \def\hyper@tmpb{##1}%
825 \ifx\hyper@tmpa\hyper@tmpb{%
826 \ifx?##3\relax%
827 \global\let\hyper@forwarded@fn\@empty%
828 \else%
829 \hyper@cnt##3\relax% fetch page
830 \advance\hyper@cnt1\relax% advance page by one
831 \global\edef\hyper@forwarded@fn{fn.##2.\the\hyper@cnt}%create new link
832 \fi%
833 }%
834 \else%
835 \global\let\hyper@forwarded@fn\@empty%
836 \fi%
837 }%
838 \let\hyper@thepage\thepage%
839 \def\f@hyper@ref@int##1\end@hyper@ref##2{%
840 \ifvmode\leavevmode\fi%
841 \expandafter\ifx\csname hyper@##1\endcsname\relax%
842 \expandafter\ifx\csname hyper@new@##1\endcsname\relax%
843 \hyper@check@fn##1...\hyper@check@fn%
844 \ifx\hyper@forwarded@fn\@empty%
845 \PackageWarning{hyper}%
846 {Hyper reference `##1' for `##2' on page \hyper@thepage\space undefined}%
847 \hyper@change1\relax%
848 \hyper@undef@color{##2}%
849 \else%
850 \expandafter\ifx\csname hyper@\hyper@forwarded@fn\endcsname\relax%
851 \expandafter\ifx\csname hyper@new@\hyper@forwarded@fn\endcsname\relax%
852 \PackageWarning{hyper}%
853 {Hyper reference `##1' for `##2' %
854 on page \hyper@thepage\space undefined}%
855 \hyper@change1\relax%
856 \hyper@undef@color{##2}%
857 \else%
858 \hyper@change8\relax%
859 \PackageWarning{hyper}%
860 {Hyper reference `##1' for `##2' on page \hyper@thepage\space%
861 forwarded to `\hyper@forwarded@fn'}%
862 \hyper@special@reference%
863 {<a href=\hyper@quote\hyper@hash\hyper@forwarded@fn\hyper@quote>}%
864 {##2}%
865 {</a>}%
866 \fi%
867 \else%
868 \hyper@change8\relax%
869 \PackageWarning{hyper}%
870 {Hyper reference `##1' for `##2' on page \hyper@thepage\space%
871 forwarded to `\hyper@forwarded@fn'}%
872 \hyper@special@reference%
873 {<a href=\hyper@quote\hyper@hash\hyper@forwarded@fn\hyper@quote>}%
874 {##2}%
875 {</a>}%
876 \fi%
877 \fi%
878 \else%
879 \hyper@special@reference%
880 {<a href=\hyper@quote\hyper@hash##1\hyper@quote>}%
881 {##2}%
882 {</a>}%
883 \fi%
884 \else%
885 \hyper@special@reference%
886 {<a href=\hyper@quote\hyper@hash##1\hyper@quote>}%
887 {##2}%
888 {</a>}%
889 \fi%
890 }%
891 \def\f@hyper@ref{%
892 \@ifnextchar[{\f@hyper@ref@ext[]}{\f@hyper@ref@int}%
893 }%
894 \def\fragilehyperreference##1{%
895 \expandafter\expandafter\expandafter\f@hyper@ref##1\end@hyper@ref%
896 }%
897 \def\f@hyper@page@ref{%
898 \@ifnextchar[{\f@hyper@ref@page@ext[page.]}{\f@hyper@ref@int page.}%
899 }%
900 \def\fragilehyperpagereference##1{%
901 \expandafter\expandafter\expandafter%
902 \f@hyper@page@ref##1\end@hyper@ref%
903 }%
904 \def\fragilehyperanchor##1##2{%
905 \ifvmode\leavevmode\fi%
906 \hyper@special@anchor%
907 {<a name=\hyper@quote##1\hyper@quote>}%
908 {\hyper@to@aux{##1}%
909 ##2%
910 }%
911 {</a>}%
912 }%
913 \def\fragileblindhyperanchor##1{%
914 \hyper@special@anchor%
915 {<a name=\hyper@quote##1\hyper@quote>}%
916 {\hyper@to@aux{##1}}%
917 {</a>}%
918 }%
919 \def\fragilehyperURL##1##2##3##4{%
920 \ifvmode\leavevmode\fi%
921 \def\hyper@tmp{##4}%
922 \def\hyper@tmpa{##1}%
923 \def\hyper@tmpb{##2}%
924 \def\hyper@tmpc{##3}%
925 \ifx\hyper@tmp\@empty%
926 %
927 \else\ifx\hyper@tmpa\@empty%
928 \ifx\hyper@tmpb\@empty%
929 \ifx\hyper@tmpc\@empty%
930 {##4}%
931 \else%
932 \hyper@special@reference%
933 {<a href=\hyper@quote##3\hyper@quote>}%
934 {##4}%
935 {</a>}%
936 \fi%
937 \else\ifx\hyper@tmpc\@empty%
938 \hyper@special@reference%
939 {<a href=\hyper@quote//##2/\hyper@quote>}%
940 {##4}%
941 {</a>}%
942 \else%
943 \hyper@special@reference%
944 {<a href=\hyper@quote//##2/##3\hyper@quote>}%
945 {##4}%
946 {</a>}%
947 \fi\fi%
948 \else\ifx\hyper@tmpb\@empty%
949 \ifx\hyper@tmpc\@empty%
950 {##4}%
951 \else%
952 \hyper@special@reference%
953 {<a href=\hyper@quote##1:##3\hyper@quote>}%
954 {##4}%
955 {</a>}%
956 \fi%
957 \else\ifx\hyper@tmpc\@empty%
958 \hyper@special@reference%
959 {<a href=\hyper@quote##1://##2/\hyper@quote>}%
960 {##4}%
961 {</a>}%
962 \else%
963 \hyper@special@reference%
964 {<a href=\hyper@quote##1://##2/##3\hyper@quote>}%
965 {##4}%
966 {</a>}%
967 \fi\fi\fi\fi%
968 }%
969 }
970 \egroup
971 \hyper
972 % \end{macrocode}
973 % Sometimes we need this package without being allowed to insert
974 % the hypertext marks into the dvi--file. Note, thate |\hyper@fix| is
975 % defined for the sole purpose of having the same \TeX-output behaviour
976 % regardless whether we create or do not create hypertext markups.
977 % \begin{macrocode}
978 \def\nohyper{%
979 \def\hyper@fix##1{%
980 \ifx\hyper@unnested@special@reference\hyper@unnested@special@reference@nofix%
981 ##1%
982 \else%
983 \hbox{##1}%
984 \fi%
985 }
986 \def\fragilehyperreference##1##2{%
987 \ifvmode\leavevmode\fi\hyper@fix{\hyper@ref@color{##2}}%
988 }%
989 \def\fragilehyperpagereference##1##2{%
990 \ifvmode\leavevmode\fi\hyper@fix{\hyper@ref@color{##2}}%
991 }%
992 \def\fragilehyperanchor##1##2{%
993 \ifvmode\leavevmode\fi\hyper@anchor@color{##2}%
994 }%
995 \def\fragileblindhyperanchor##1{}%
996 \def\fragilehyperURL##1##2##3##4{%
997 \ifvmode\leavevmode\fi\hyper@fix{\hyper@ref@color{##4}}%
998 }%
999 }
1000 % \end{macrocode}
1001 % Now let's protect the fragile commands.
1002 % \begin{macrocode}
1003 \def\hyperreference{\protect\fragilehyperreference}
1004 \def\hyperpagereference{\protect\fragilehyperpagereference}
1005 \def\hyperanchor{\protect\fragilehyperanchor}
1006 \def\blindhyperanchor{\protect\fragileblindhyperanchor}
1007 \def\fragileChyperURL{%
1008 \bgroup%
1009 \catcode`\<12\catcode`\>12\catcode`\"12\relax%
1010 \catcode`\:12\catcode`\=12\catcode`\/12\relax%
1011 \catcode`\#12\catcode`\~12\relax%\catcode`\%12\relax%
1012 \finish@hyperURL%
1013 }
1014 \def\finish@hyperURL#1#2#3#4{%
1015 \fragilehyperURL{#1}{#2}{#3}{#4}%
1016 \egroup%
1017 }
1018 \def\hyperURL{\protect\fragileChyperURL}
1019 % \end{macrocode}
1020 %
1021 % \subsection{Colored Anchors/References}
1022 % Above we have used three macros |\hyper@ref@color|, |\hyper@undef@color|, and |\hyper@anchor@color|
1023 % with which we can modify the text that is printed to the document.
1024 % As their name indicates we want to use them to color the anchors resp.\
1025 % references. Hence we should define some variants of these macros.\par
1026 % \noindent The first variant prints the text in different colors.
1027 % \begin{macrocode}
1028 \def\hyper@color{%
1029 \definecolor{refcolor}{rgb}{0,0,1}%
1030 \definecolor{undefrefcolor}{rgb}{1,0,0}%
1031 \definecolor{anchorcolor}{rgb}{0,0.75,0.75}%
1032 \def\hyper@ref@color##1{\textcolor{refcolor}{##1}}%
1033 \def\hyper@undef@color##1{\textcolor{undefrefcolor}{##1}}%
1034 \def\hyper@anchor@color##1{\textcolor{anchorcolor}{##1}}%
1035 }
1036 % \end{macrocode}
1037 % If we do not have colors we may use gray text instead.
1038 % \begin{macrocode}
1039 \def\hyper@gray{%
1040 \definecolor{refcolor}{gray}{0.75}%
1041 \definecolor{undefrefcolor}{gray}{0.25}%
1042 \definecolor{anchorcolor}{gray}{0.5}%
1043 \def\hyper@ref@color##1{\textcolor{refcolor}{##1}}%
1044 \def\hyper@undef@color##1{\textcolor{undefrefcolor}{##1}}%
1045 \def\hyper@anchor@color##1{\textcolor{anchorcolor}{##1}}%
1046 }
1047 % \end{macrocode}
1048 % In ready to print documents we should not use these options but print
1049 % the text in ordinary black. This is also the default definition.
1050 % \begin{macrocode}
1051 \def\hyper@black{%
1052 \def\hyper@ref@color##1{##1}%
1053 \def\hyper@undef@color##1{##1}%
1054 \def\hyper@anchor@color##1{##1}%
1055 }
1056 \hyper@black
1057 % \end{macrocode}
1058 %
1059 % \subsection{Automatic Generation of Anchor Names}
1060 % As we want to insert hypertext marks automagically we need a service that
1061 % provides new names for anchors. The simplest solution is to let the
1062 % name be a natural number.\par
1063 % \noindent Thus we need an initialization for providing them.
1064 % \begin{macrocode}
1065 \newcount\hypercount
1066 \hypercount=0\relax
1067 \def\@currenthyper{}
1068 % \end{macrocode}
1069 % Now we can compute the next anchor from the last one generated.
1070 % \begin{macrocode}
1071 \def\hyper@setcurrent{%
1072 \global\advance\hypercount1\relax%
1073 \edef\@currenthyper{\the\hypercount}%
1074 }%
1075 \def\hyper@settype#1{%
1076 \edef\@currenthypertype{#1}%
1077 }%
1078 % \end{macrocode}
1079 % The automatic generation of anchor names leads to a little problem.
1080 % We have to ensure that |\@currenthyper| is expanded at an appropriate
1081 % time. Thus we define a macro that allow us to get an expanded
1082 % hypertext reference that follows a not yet expanded
1083 % token list.
1084 % \begin{macrocode}
1085 \def\hyper@ref@toggle#1#2#3{#3[\hyperreference{#1}{#2}]}
1086 \def\ref@by@expanded@hyper#1\end@hyper{{#1}}
1087 \def\callwithexpandedhyperref#1#2{%
1088 \expandafter\expandafter\expandafter\hyper@ref@toggle%
1089 \expandafter\ref@by@expanded@hyper\@currenthyper\end@hyper%
1090 {#2}{#1}%
1091 }
1092 % \end{macrocode}
1093 %
1094 % \subsection{HyperText Cross--Referencing for \LaTeXe}
1095 % For a replacement of \LaTeXe's cross--referencing features we need to
1096 % redefine the commands |\label| and |\ref|.\par
1097 % \noindent Let us first define a label command for writing the current
1098 % hypertext reference to the |.aux|--file. It must print four components
1099 % of a label: the hypertext--type, the hypertext--anchor, the \LaTeXe--anchor,
1100 % and the \LaTeXe--page. This is due to the fact that we need to know not only
1101 % the stuff we reference to but also the internal name of the anchor.
1102 % \begin{macrocode}
1103 \def\hyperlabel#1{\@bsphack
1104 \protected@write\hyper@auxout{}%
1105 {\string\newlabel{#1}%
1106 {{\@currenthypertype}{\@currenthyper}{\@currentlabel}{\thepage}}}%
1107 \@esphack}
1108 % \end{macrocode}
1109 % Now we need some auxiliary macros to be able to select each of the three
1110 % parts of the second argument of |\newlabel| that has been written to the
1111 % |.aux|--file. Note, that the third component may contain informations
1112 % about the URL of an external document (for cross referencing between
1113 % documents) that has to be stripped of a page
1114 % number before printing it.
1115 % \begin{macrocode}
1116 \def\hyper@secondoffour#1#2#3#4{#2}
1117 \def\hyper@thirdoffour#1#2#3#4{#3}
1118 \def\hyper@forthoffour#1#2#3#4{#4}
1119 \def\hyper@snd@forthoffour[#1][#2]\end@hyper{#2}
1120 \def\hyper@this@forthoffour#1\end@hyper{#1}
1121 \def\hyper@test@forthoffour{%
1122 \@ifnextchar[{\hyper@snd@forthoffour}{\hyper@this@forthoffour}%
1123 }
1124 \def\hyper@page@forthoffour#1#2#3#4{%
1125 \expandafter\hyper@test@forthoffour#4\end@hyper%
1126 }
1127 % \end{macrocode}
1128 % When setting a reference to an anchor we also have to add the corresponding
1129 % hypertext link into the dvi-file.
1130 % \begin{macrocode}
1131 \let\hyper@thepage\thepage
1132 \def\hyper@setref#1#2#3#4{%
1133 \ifx#1\relax%
1134 \protect\G@refundefinedtrue%
1135 #4\nfss@text{\reset@font\bfseries ??}%
1136 \@latex@warning{Reference `#3' on page \hyper@thepage \space undefined}%
1137 \else%
1138 \edef\hyper@tmp{\expandafter\hyper@secondoffour#1}%
1139 \ifx\hyper@tmp\@empty%
1140 \ifx#2\hyper@secondoffour%
1141 #4\null%
1142 \else\ifx#2\hyper@thirdoffour%
1143 #4\expandafter#2#1\null%
1144 \else%
1145 #4\expandafter#2#1\null%
1146 \fi\fi%
1147 \else%
1148 \ifx#2\hyper@secondoffour%
1149 \hyperreference{\expandafter\hyper@secondoffour#1}{#4}\null%
1150 \else\ifx#2\hyper@thirdoffour%
1151 \hyperreference%
1152 {\expandafter\hyper@secondoffour#1}%
1153 {#4\expandafter#2#1\null}\null%
1154 \else%
1155 \hyperpagereference%
1156 {\expandafter\hyper@forthoffour#1}%
1157 {#4\expandafter#2#1\null}\null%
1158 \fi\fi%
1159 \fi%
1160 \fi%
1161 }
1162 % \end{macrocode}
1163 % Proceeding from this we can define three macros |\hypernoref|, |\hyperref|,
1164 % and |\hyperpageref| that correspond to the same \LaTeXe--macros where the
1165 % hyper does not occur. But we want to do a little bit more. Thus an
1166 % additional optional argument may be given to these macros to allow
1167 % the user to reference from a whole text and not only from the number
1168 % to the anchor.
1169 % \begin{macrocode}
1170 \def\@@hypernoref[#1]#2{%
1171 \expandafter\hyper@setref\csname r@#2\endcsname%
1172 \hyper@secondoffour{#2}{#1}%
1173 }
1174 \def\@hypernoref[#1]{\@@hypernoref[#1]}
1175 \def\hypernoref{\@ifnextchar[{\@hypernoref}{\@@hypernoref[]}}
1176 \def\@@hyperref[#1]#2{%
1177 \expandafter\hyper@setref\csname r@#2\endcsname%
1178 \hyper@thirdoffour{#2}{#1}%
1179 }
1180 \def\@hyperref[#1]{\@@hyperref[#1~]}
1181 \def\hyperref{\@ifnextchar[{\@hyperref}{\@@hyperref[]}}
1182 \def\@@hyperpageref[#1]#2{%
1183 \expandafter\hyper@setref\csname r@#2\endcsname%
1184 \hyper@page@forthoffour{#2}{#1}%
1185 }
1186 \def\@hyperpageref[#1]{\@@hyperpageref[#1~]}
1187 \def\hyperpageref{\@ifnextchar[{\@hyperpageref}{\@@hyperpageref[]}}
1188 % \end{macrocode}
1189 % Now let's patch \LaTeXe's ref/label-system:
1190 % \begin{macrocode}
1191 \let\label\hyperlabel
1192 \def\noref{\protect\hypernoref}
1193 \def\ref{\protect\hyperref}
1194 \def\pageref{\protect\hyperpageref}
1195 % \end{macrocode}
1196 % Up to now we only can reference to anchors but haven't yet defined some.
1197 % This will be done in many of the following subsections.
1198 % \subsection{Other Cross--Referencing Features}
1199 % Though \LaTeXe{} has a very good reference mechanism this is not enough
1200 % for hypertext documents. The user should be able to add an anchor to
1201 % a text of his own choice.
1202 % \begin{macrocode}
1203 \def\labeltext#1#2{%
1204 \bgroup%
1205 \hyper@setcurrent%
1206 \hyper@settype{text}%
1207 \def\@currentlabel{#2}%
1208 \label{#1}%
1209 \hyperanchor{\@currenthyper}{#2}%
1210 \egroup%
1211 }
1212 % \end{macrocode}
1213 % But that is not enough. Some of the macros of this package define anchors
1214 % which cannot be caught by a |\label| command. But then it is the current or
1215 % the next anchor generated. The following macros will allow us to reference
1216 % to them:
1217 % \begin{macrocode}
1218 \def\refcurrent#1{\hyperreference{\@currenthyper}{#1}}
1219 \def\fragilerefnext#1#2{\bgroup%
1220 \hypercount=#1\relax\advance\hypercount1\relax%
1221 \hyperreference{\the\hypercount}{#2}%
1222 \egroup}
1223 \def\refnext#1{\protect\fragilerefnext{\the\hypercount}{#1}}
1224 % \end{macrocode}
1225 % This is especially usefull for inserting links from the table of contents
1226 % to an unnumbered section like e.g.\ the references of a document.\par
1227 % \noindent But wait, there is more. \LaTeXe{} not only uses |\ref| and
1228 % |\label| for it's referencing mechanism but also |\refstepcounter| to
1229 % determine to what the next |\label| should reference.
1230 % This has to be reflected for the hypertext stuff.
1231 % \begin{macrocode}
1232 \let\hyper@refstepcounter\refstepcounter
1233 \def\refstepcounter{\hyper@setcurrent\hyper@settype{counter}\hyper@refstepcounter}
1234 % \end{macrocode}
1235 % As we will patch some latex internals below we also need
1236 % a macro that allow us to forget the next |\refstepcounter|.
1237 % \begin{macrocode}
1238 \def\ignore@next@refstepcounter{%
1239 \def\refstepcounter##1{%
1240 \def\refstepcounter{\hyper@setcurrent\hyper@settype{counter}\hyper@refstepcounter}%
1241 }%
1242 }
1243 % \end{macrocode}
1244 %
1245 % \subsection{Handling Page Numbers}
1246 % We want to refer from the pages in the table of contents
1247 % to the corresponding page. Thus we have to recall the necessary
1248 % information when printing the table.
1249 % \begin{macrocode}
1250 \let\hyper@contentsline\contentsline
1251 \def\contentsline#1#2#3{%
1252 \hyper@contentsline{#1}{#2}{\hyperpagereference{#3}{#3}}%
1253 }
1254 % \end{macrocode}
1255 % The same is valid for indices and glossaries. But they are more
1256 % problematic. Hence we will handle them in a subsection of its own.\par
1257 % \noindent So far the result is a couple of references from page numbers
1258 % to pages. But we haven't defined the anchors they refer to.\par
1259 % \noindent To resolve this we have to modify headers and footers of
1260 % a page. This can be done for an arbitrary page style when we change
1261 % (misuse!) |\@begindvi|.\par
1262 % \noindent Let's provide to different styles for this purpose, one allowing
1263 % jumps to the page number, and one allowing jumps to the top of the page.
1264 % In the latter case we let the page numbers in the headers and footers refer
1265 % to the top of the page.
1266 % \begin{macrocode}
1267 \let\hyper@thepage\thepage
1268 \def\hyper@anchorpage{%
1269 \fragilehyperanchor{page.\hyper@thepage}{\hyper@thepage}%
1270 }
1271 \def\hyper@referencepage{%
1272 \fragilehyperreference{page.\hyper@thepage}{\hyper@thepage}%
1273 }
1274 \def\hyper@empty{\@empty}
1275 \def\hyper@evenhead{\@evenhead}
1276 \def\hyper@oddhead{\@oddhead}
1277 \def\hyper@evenfoot{\@evenfoot}
1278 \def\hyper@oddfoot{\@oddfoot}
1279 \def\hyper@modifyheadfoot@pagenumber{%
1280 \let\hyper@thehead\@thehead%
1281 \ifx\hyper@thehead\hyper@oddhead\let\hyper@thehead\@oddhead\fi%
1282 \ifx\hyper@thehead\hyper@evenhead\let\hyper@thehead\@evenhead\fi%
1283 \let\hyper@thefoot\@thefoot%
1284 \ifx\hyper@thefoot\hyper@oddfoot\let\hyper@thefoot\@oddfoot\fi%
1285 \ifx\hyper@thefoot\hyper@evenfoot\let\hyper@thefoot\@evenfoot\fi%
1286 \def\@thehead{%
1287 \ifnum\ifnum\ifx\hyper@thehead\@empty1\else0\fi%
1288 \ifx\hyper@thehead\hyper@empty1\else0\fi%
1289 >0 0\else1\fi%
1290 \ifnum\ifx\hyper@thefoot\@empty1\else0\fi%
1291 \ifx\hyper@thefoot\hyper@empty1\else0\fi%
1292 >0 0\else1\fi%
1293 >0\relax%
1294 \else%
1295 \blindhyperanchor{page.\thepage}%
1296 \fi%
1297 \let\hyper@thepage\thepage%
1298 \let\thepage\hyper@anchorpage%
1299 \ifx\hyper@thehead\@empty%
1300 \hfil%
1301 \else\ifx\hyper@thehead\hyper@empty%
1302 \hfil%
1303 \else%
1304 \hyper@thehead%
1305 \fi\fi%
1306 }%
1307 \def\@thefoot{%
1308 \let\hyper@thepage\thepage%
1309 \let\thepage\hyper@anchorpage%
1310 \ifx\hyper@thefoot\@empty%
1311 \hfil%
1312 \else\ifx\hyper@thefoot\hyper@empty%
1313 \hfil%
1314 \else%
1315 \hyper@thefoot%
1316 \fi\fi%
1317 }%
1318 }
1319 \def\hyper@modifyheadfoot@pagetop{%
1320 \let\hyper@thehead\@thehead%
1321 \ifx\hyper@thehead\hyper@oddhead\let\hyper@thehead\@oddhead\fi%
1322 \ifx\hyper@thehead\hyper@evenhead\let\hyper@thehead\@evenhead\fi%
1323 \let\hyper@thefoot\@thefoot%
1324 \ifx\hyper@thefoot\hyper@oddfoot\let\hyper@thefoot\@oddfoot\fi%
1325 \ifx\hyper@thefoot\hyper@evenfoot\let\hyper@thefoot\@evenfoot\fi%
1326 \def\@thehead{%
1327 \blindhyperanchor{page.\thepage}%
1328 \let\hyper@thepage\thepage%
1329 \let\thepage\hyper@referencepage%
1330 \ifx\hyper@thehead\@empty%
1331 \hfil%
1332 \else\ifx\hyper@thehead\hyper@empty%
1333 \hfil%
1334 \else%
1335 \hyper@thehead%
1336 \fi\fi%
1337 }%
1338 \def\@thefoot{%
1339 \let\hyper@thepage\thepage%
1340 \let\thepage\hyper@referencepage%
1341 \ifx\hyper@thefoot\@empty%
1342 \hfil%
1343 \else\ifx\hyper@thefoot\hyper@empty%
1344 \hfil%
1345 \else%
1346 \hyper@thefoot%
1347 \fi\fi%
1348 }%
1349 }
1350 \let\hyper@begindvi\@begindvi
1351 \def\@begindvi{%
1352 \hyper@begindvi%
1353 \hyper@modifyheadfoot%
1354 \global\let\@begindvi\hyper@modifyheadfoot%
1355 }
1356 % \end{macrocode}
1357 % Hopefully we do not use a page number twice in headers or footers if we want to jump to the pagenumber.\par
1358 % \noindent We use pagenumbers as the default position for page anchors.
1359 % \begin{macrocode}
1360 \let\hyper@modifyheadfoot\hyper@modifyheadfoot@pagenumber
1361 % \end{macrocode}
1362 % \subsection{Table of Contents}
1363 % In the subsection ``Handling of Pages'' we already have inserted
1364 % references from the page number to the corresponding page.
1365 % Now we want to add further references from the title of an entry
1366 % in the table of contents to the corresponding text within the
1367 % document.\par
1368 % \noindent To do that we have to modify the corresponding sectioning commands.
1369 % \begin{macrocode}
1370 \let\hyper@sect\@sect
1371 \def\@sect#1#2#3#4#5#6[#7]#8{%
1372 \ifnum #2>\c@secnumdepth%
1373 \hyper@setcurrent%
1374 \else%
1375 \refstepcounter{#1}%
1376 \ignore@next@refstepcounter%
1377 \fi%
1378 \hyper@settype{#1}%
1379 \global\let\@currenthyper\@currenthyper%
1380 \global\let\@currenthypertype\@currenthypertype%
1381 \callwithexpandedhyperref%
1382 {\hyper@sect{#1}{#2}{#3}{#4}{#5}{#6}}%
1383 {#7}%
1384 {\hyperanchor{\@currenthyper}{#8}}%
1385 }
1386 \let\hyper@ssect\@ssect
1387 \def\@ssect#1#2#3#4#5{%
1388 \hyper@setcurrent%
1389 \hyper@settype{#1}%
1390 \global\let\@currenthyper\@currenthyper%
1391 \global\let\@currenthypertype\@currenthypertype%
1392 \hyper@ssect{#1}{#2}{#3}{#4}{\hyperanchor{\@currenthyper}{#5}}%
1393 }
1394 %</hyper>
1395 % \end{macrocode}
1396 % The classes |book| and |report| additionally define a |\chapter| command.
1397 % Unfortunately they do it in a different way. But the differences are fairly
1398 % small. Thus we will use nearly the same definition.
1399 % \begin{macrocode}
1400 %<*book,report>
1401 \let\hyper@chapter\@chapter
1402 \let\hyper@schapter\@schapter
1403 \def\@chapter[#1]#2{%
1404 \ifnum\c@secnumdepth>\m@ne%
1405 %</book,report>
1406 %<*book>
1407 \if@mainmatter%
1408 %</book>
1409 %<*book,report>
1410 \refstepcounter{chapter}%
1411 \ignore@next@refstepcounter%
1412 %</book,report>
1413 %<*book>
1414 \else%
1415 \hyper@setcurrent%
1416 \fi%
1417 %</book>
1418 %<*book,report>
1419 \else%
1420 \hyper@setcurrent%
1421 \fi%
1422 \hyper@settype{chapter}%
1423 \global\let\@currenthyper\@currenthyper%
1424 \global\let\@currenthypertype\@currenthypertype%
1425 \callwithexpandedhyperref%
1426 {\hyper@chapter}%
1427 {#1}%
1428 {\hyperanchor{\@currenthyper}{#2}}%
1429 }
1430 \def\@schapter#1{%
1431 \hyper@setcurrent%
1432 \hyper@settype{chapter}%
1433 \global\let\@currenthyper\@currenthyper%
1434 \global\let\@currenthypertype\@currenthypertype%
1435 \hyper@schapter{\hyperanchor{\@currenthyper}{#1}}%
1436 }
1437 % \end{macrocode}
1438 % However, this is not sufficient. The classes |book| and |report| use a different mechanism
1439 % for the index heading not using the macro |\chapter*|. So we have to fix this.
1440 % \begin{macrocode}
1441 \let\hyper@theindex\theindex
1442 \def\theindex{%
1443 \bgroup%
1444 \let\hyper@makeschapterhead\@makeschapterhead%
1445 \def\@makeschapterhead##1{%
1446 \hyper@setcurrent%
1447 \hyper@settype{chapter}%
1448 \global\let\@currenthyper\@currenthyper%
1449 \global\let\@currenthypertype\@currenthypertype%
1450 \hyper@makeschapterhead{\hyperanchor{\@currenthyper}{##1}}%
1451 }
1452 \hyper@theindex%
1453 \egroup%
1454 \let\item\@idxitem%
1455 }
1456 %</book,report>
1457 % \end{macrocode}
1458 % There is also a |\part|--macro defined in the classes |article|, |book|,
1459 % |ltnews|, |ltxdoc|, |ltxguide|, |proc|, and |report|.
1460 % Unfortunately there are two different definitions we have to modify.
1461 % But they differ only in a constant in a conditional expression.
1462 % Thus we can use a nearly common definition.
1463 % \begin{macrocode}
1464 %<*article,book,ltnews,ltxdoc,ltxguide,proc,report>
1465 \let\hyper@part\@part
1466 \def\@part[#1]#2{%
1467 \ifnum\c@secnumdepth>%
1468 %</article,book,ltnews,ltxdoc,ltxguide,proc,report>
1469 %<*article,ltnews,ltxdoc,ltxguide,proc>
1470 -1\relax%
1471 %</article,ltnews,ltxdoc,ltxguide,proc>
1472 %<*book,report>
1473 -2\relax%
1474 %</book,report>
1475 %<*article,book,ltnews,ltxdoc,ltxguide,proc,report>
1476 \refstepcounter{part}%
1477 \ignore@next@refstepcounter%
1478 \else%
1479 \hyper@setcurrent%
1480 \fi%
1481 \hyper@settype{part}%
1482 \global\let\@currenthyper\@currenthyper%
1483 \global\let\@currenthypertype\@currenthypertype%
1484 \callwithexpandedhyperref%
1485 {\hyper@part}%
1486 {#1}%
1487 {\hyperanchor{\@currenthyper}{#2}}%
1488 }
1489 \let\hyper@spart\@spart
1490 \def\@spart#1{%
1491 \hyper@setcurrent%
1492 \hyper@settype{part}%
1493 \global\let\@currenthyper\@currenthyper%
1494 \global\let\@currenthypertype\@currenthypertype%
1495 \hyper@spart{\hyperanchor{\@currenthyper}{#1}}%
1496 }
1497 %</article,book,ltnews,ltxdoc,ltxguide,proc,report>
1498 % \end{macrocode}
1499 % Now we do not only get references from the table of contents to the
1500 % corresponding sections but also from the headers and footers to them.
1501 % There is only one exception these references are not inserted:
1502 % If we used the |*|--ed variants of the sectioning commands the marks
1503 % are not inserted in the headers.\par
1504 % \noindent For bibliography, glossary, index, and table of contents
1505 % this can be changed by modifying |\@mkboth|.
1506 % \begin{macrocode}
1507 %<*article,book,ltnews,ltxdoc,ltxguide,proc,report>
1508 \def\hyper@mkboth@do[#1][#2]{%
1509 \markboth{#1}{#2}%
1510 }
1511 \def\hyper@mkboth#1#2{%
1512 \callwithexpandedhyperref%
1513 {\callwithexpandedhyperref{\hyper@mkboth@do}{#1}}%
1514 {#2}%
1515 }
1516 % \end{macrocode}
1517 % As marks are only inserted when using the pagestyle ``headings'',
1518 % the corresponding macro has to be modified to get the desired result.
1519 % \begin{macrocode}
1520 \let\hyper@ps@headings\ps@headings
1521 \def\ps@headings{%
1522 \hyper@ps@headings%
1523 \let\@mkboth\hyper@mkboth%
1524 }
1525 %</article,book,ltnews,ltxdoc,ltxguide,proc,report>
1526 % \end{macrocode}
1527 % Last but not least set the new page style.
1528 % \begin{macrocode}
1529 %<*book,report>
1530 \pagestyle{headings}
1531 %</book,report>
1532 % \end{macrocode}
1533 % Unfortunately, the package |doc.sty| modifies the |theindex| environment
1534 % in a way that the above changes do not work correctly with it.
1535 % Hence, we have to modify this environment to resolve this.
1536 % \begin{macrocode}
1537 %<*doc>
1538 \g@addto@macro\index@prologue{%
1539 \def\markboth#1#2{%
1540 \@mkboth{\refcurrent{#1}}{\refcurrent{#2}}%
1541 }%
1542 }
1543 %</doc>
1544 % \end{macrocode}
1545 %
1546 % \subsection{Bibliography}
1547 % We want to reference from citation points within the text,
1548 % given by |\cite|, to the corresponding entry in the bibliography.
1549 % To realize this we only have to modify the |\bibitem|--macro.
1550 % \begin{macrocode}
1551 %<*hyper>
1552 \def\@lbibitem[#1]#2{%
1553 \hyper@setcurrent%
1554 \hyper@settype{citation}%
1555 \item[\@biblabel{\hyperanchor{\@currenthyper}{#1}}\hfill]%
1556 \if@filesw%
1557 {\let\protect\@unexpandable@protect%
1558 \immediate%
1559 \write\@auxout{%
1560 \string\bibcite{#2}{\hyperreference{\@currenthyper}{#1}}%
1561 }%
1562 }%
1563 \fi%
1564 \ignorespaces%
1565 }
1566 \def\@bibitem{%
1567 \stepcounter{\@listctr}%
1568 \hyper@settype{citation}%
1569 \@lbibitem[\the\value{\@listctr}]%
1570 }
1571 % \end{macrocode}
1572 % \subsection{Equations}
1573 % The goal is to reference to the equation number in equations and
1574 % arrays of equations. This is really simple to do.
1575 % \begin{macrocode}
1576 \def\@eqnnum{%
1577 \hyperanchor{\@currenthyper}{\normalfont\normalcolor(\theequation)}%
1578 }
1579 \let\hyper@eqnarray\eqnarray
1580 \def\eqnarray{%
1581 \hyper@setcurrent%
1582 \def\@currenthyper{\the\hypercount}%
1583 \hyper@settype{equation}%
1584 \hyper@eqnarray%
1585 }
1586 \let\hyper@xeqncr\@xeqncr
1587 \def\@xeqncr[#1]{%
1588 \hyper@xeqncr[#1]%
1589 \noalign{\hyper@setcurrent\hyper@settype{equation}}%
1590 }
1591 %</hyper>
1592 % \end{macrocode}
1593 % There is a document class option |leqno| that has to be redefined for us.
1594 % \begin{macrocode}
1595 %<*leqno>
1596 \def\@eqnnum{%
1597 \hbox to .01\p@{}%
1598 \rlap{\reset@font\rmfamily%
1599 \hskip -\displaywidth%
1600 \hyperanchor{\@currenthyper}{\reset@font\rmfamily (\theequation)}%
1601 }%
1602 }
1603 %</leqno>
1604 % \end{macrocode}
1605 %
1606 % \subsection{Float Captions}
1607 % What do you think we want to do here? Simply using |\caption| to define
1608 % an anchor that may be used to refer to the current float.
1609 % \begin{macrocode}
1610 %<*hyper>
1611 \long\def\@caption#1[#2]#3{\par%
1612 \addcontentsline%
1613 {\csname ext@#1\endcsname}%
1614 {#1}%
1615 {\protect\numberline{\csname the#1\endcsname}%
1616 {\ignorespaces \hyperreference{\@currenthyper}{#2}}%
1617 }%
1618 \begingroup%
1619 \@parboxrestore%
1620 \normalsize%
1621 \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par%
1622 \endgroup%
1623 }
1624 %</hyper>
1625 % \end{macrocode}
1626 % Obviously we need to modify |\@makecaption| to define the anchor.
1627 % As this macro is defined only for the classes |article|, |book|,
1628 % |ltnews|, |ltxdoc|, |ltxguide|, |proc|, and |report| we redefine
1629 % it only for them.
1630 % \begin{macrocode}
1631 %<*article,book,ltnews,ltxdoc,ltxguide,proc,report>
1632 \let\hyper@makecaption\@makecaption
1633 \long\def\@makecaption#1#2{%
1634 \hyper@makecaption{\hyperanchor{\@currenthyper}{#1}}{#2}%
1635 }
1636 %</article,book,ltnews,ltxdoc,ltxguide,proc,report>
1637 % \end{macrocode}
1638 %
1639 % \subsection{Footnotes}
1640 % Here we want to handle references from footnotemarks to footnotes
1641 % at the bottom of the page.\par
1642 % \noindent At first modify the standard definition of |\@makefnmark| to
1643 % refer to a footnote which is complicated by the fact that |\thepage| does not
1644 % necessarily refer to the actual page when used. So we have to write the page
1645 % to an auxiliary file and reread it afterwards. Let's not forget to check for
1646 % changes of these entries to warn the user about possible changes.
1647 % \begin{macrocode}
1648 %<*hyper>
1649 \newcount\hyper@fnmark@count
1650 \hyper@fnmark@count0
1651 \def\hyper@currentfnmark{%
1652 \global\advance\hyper@fnmark@count1\relax%
1653 \@bsphack%
1654 \protected@write\hyper@auxout%
1655 {}%
1656 {\string\hyperfnpage{\the\hyper@fnmark@count}{\thepage}}%
1657 \@esphack%
1658 \hb@xt@\z@{%
1659 \ifx\hyper@minipage@label\@empty%
1660 \global\edef\hyper@current@fnmark%
1661 {fn.\@arabic\c@footnote.%
1662 \expandafter%
1663 \ifx\csname hyper@fn@\the\hyper@fnmark@count\endcsname%
1664 \relax%
1665 ?%
1666 \else%
1667 \csname hyper@fn@\the\hyper@fnmark@count\endcsname%
1668 \fi%
1669 }%
1670 \else\ifnum\hyper@minipage@label=0\relax%
1671 \global\edef\hyper@current@fnmark%
1672 {fn.\hyper@minipage@label.\@arabic\c@footnote.%
1673 \expandafter%
1674 \ifx\csname hyper@fn@\the\hyper@fnmark@count\endcsname%
1675 \relax%
1676 ?%
1677 \else%
1678 \csname hyper@fn@\the\hyper@fnmark@count\endcsname%
1679 \fi%
1680 }%
1681 \else%
1682 \global\edef\hyper@current@fnmark%
1683 {fn.\hyper@minipage@label.\@arabic\c@mpfootnote.%
1684 \expandafter%
1685 \ifx\csname hyper@fn@\the\hyper@fnmark@count\endcsname%
1686 \relax%
1687 ?%
1688 \else%
1689 \csname hyper@fn@\the\hyper@fnmark@count\endcsname%
1690 \fi%
1691 }%
1692 \fi\fi%
1693 }%
1694 }
1695 \def\hyperfnpage#1#2{%
1696 \expandafter\global\expandafter\def\csname hyper@fn@#1\endcsname{#2}%
1697 }
1698 \def\hyperfnpage@check#1#2{%
1699 \def\reserved@a{#2}%
1700 \expandafter\ifx\csname hyper@fn@#1\endcsname\reserved@a\else%
1701 \hyper@change4\relax%
1702 \fi%
1703 }
1704 \let\hyper@fn@enddocument\enddocument
1705 \def\enddocument{%
1706 \let\hyperfnpage\hyperfnpage@check%
1707 \global\hyper@fnmark@count0\relax%
1708 \hyper@fn@enddocument%
1709 }
1710 \def\@makefnmark{%
1711 \hyper@currentfnmark%
1712 \hbox{\@textsuperscript{%
1713 \normalfont\hyperreference%
1714 {\hyper@current@fnmark}%
1715 {\@thefnmark}%
1716 }}%
1717 }
1718 \def\hyper@makefnmark@text{%
1719 \hyper@currentfnmark%
1720 \hbox{\@textsuperscript{%
1721 \normalfont\hyperanchor%
1722 {\hyper@current@fnmark}%
1723 {\@thefnmark}%
1724 }}%
1725 }
1726 %</hyper>
1727 % \end{macrocode}
1728 % Unfortunately, the definition of |\@makefntext| is dependend of the
1729 % document class we use.\par
1730 % \noindent For |article|, |book|, |letter|, |ltnews|, |ltxdoc|, |ltxguide|,
1731 % |proc|, |report|, and |slides| we have to use the following
1732 % hypertext--variant.
1733 % \begin{macrocode}
1734 %<*article,book,letter,ltnews,ltxdoc,ltxguide,proc,report,slides>
1735 \let\hyper@makefntext\@makefntext%
1736 \long\def\@makefntext#1{%
1737 \bgroup%
1738 \hyper@currentfnmark%
1739 \edef\@currenthyper{\hyper@current@fnmark}%
1740 \let\@makefnmark\hyper@makefnmark@text%
1741 \hyper@makefntext{#1}%
1742 \egroup%
1743 }
1744 %</article,book,letter,ltnews,ltxdoc,ltxguide,proc,report,slides>
1745 % \end{macrocode}
1746 % There are also footnotes within minipages. Therefore we should handle them.
1747 % \begin{macrocode}
1748 %<*hyper>
1749 \newcount\hyper@minipage@cnt
1750 \hyper@minipage@cnt=0
1751 \edef\hyper@minipage@label{}
1752 \let\hyper@minipage\minipage
1753 \let\hyper@endminipage\endminipage
1754 \def\minipage{%
1755 \bgroup%
1756 \global\advance\hyper@minipage@cnt1\relax%
1757 \edef\hyper@minipage@label{\the\hyper@minipage@cnt}%
1758 \hyper@minipage%
1759 }
1760 \def\endminipage{%
1761 \hyper@endminipage%
1762 \egroup%
1763 }
1764 %</hyper>
1765 % \end{macrocode}
1766 % Note, that there exists only one level of minipages the footnotes
1767 % are handled correctly by \LaTeXe. Thus we haven't to do more.\par
1768 % \noindent Unfortunately there is another problem. The footnote--macros
1769 % are redefined by the |\maketitle|--macro in some classes.\par
1770 % \noindent Thus we need the following changes for the classes
1771 % |article|, |book|, |ltxdoc|, |ltxguide|, and |report|.
1772 % \begin{macrocode}
1773 %<*article,book,ltxdoc,ltxguide,report>
1774 \if@titlepage\else
1775 \renewcommand\maketitle{\par
1776 \begingroup
1777 \renewcommand\thefootnote{\fnsymbol{footnote}}%
1778 \def\@makefnmark{%
1779 \hyper@currentfnmark%
1780 \rlap{\@textsuperscript{%
1781 \normalfont%
1782 \hyperreference{\hyper@current@fnmark}%
1783 {\@thefnmark}%
1784 }}%
1785 }%
1786 \long\def\@makefntext##1{%
1787 \hyper@currentfnmark%
1788 \bgroup%
1789 \edef\@currenthyper{\hyper@current@fnmark}%
1790 \parindent 1em\noindent
1791 \hb@[email protected]{%
1792 \hss\@textsuperscript{%
1793 \normalfont%
1794 \hyperanchor{\hyper@current@fnmark}{\@thefnmark}
1795 }%
1796 }%
1797 ##1%
1798 \egroup%
1799 }%
1800 \if@twocolumn
1801 \ifnum \col@number=\@ne
1802 \@maketitle
1803 \else
1804 \twocolumn[\@maketitle]%
1805 \fi
1806 \else
1807 \newpage
1808 \global\@topnum\z@
1809 \@maketitle
1810 \fi
1811 \thispagestyle{plain}\@thanks
1812 \endgroup
1813 \setcounter{footnote}{0}%
1814 \let\thanks\relax
1815 \let\maketitle\relax\let\@maketitle\relax
1816 \gdef\@thanks{}\gdef\@author{}\gdef\@title{}}
1817 \fi
1818 %</article,book,ltxdoc,ltxguide,report>
1819 % \end{macrocode}
1820 % For the class |proc| another redefinition is needed.
1821 % \begin{macrocode}
1822 %<*proc>
1823 \def\maketitle{\par
1824 \begingroup
1825 \renewcommand\thefootnote{\fnsymbol{footnote}}%
1826 \def\@makefnmark{%
1827 \hyper@currentfnmark%
1828 \hbox to\z@{%
1829 \@textsuperscript{%
1830 \normalfont%
1831 \hyperreference{\hyper@current@fnmark}%
1832 {\@thefnmark}%
1833 }%
1834 }}%
1835 \twocolumn[\@maketitle]%
1836 \@thanks
1837 \endgroup
1838 \setcounter{footnote}{0}%
1839 \let\maketitle\relax
1840 \let\@maketitle\relax
1841 \gdef\@thanks{}\gdef\@author{}\gdef\@title{}\let\thanks\relax}
1842 %</proc>
1843 % \end{macrocode}
1844 % The package |doc.sty| also modifies |\maketitle| that has a redefinition
1845 % of |\@makefnmark| and |\@makefntext|.
1846 % \begin{macrocode}
1847 %<*doc>
1848 \def\maketitle{\par
1849 \begingroup \def \thefootnote {\fnsymbol {footnote}}%
1850 \setcounter {footnote}\z@
1851 \def\@makefnmark{%
1852 \hyper@currentfnmark%
1853 \hbox to\z@{%
1854 $\m@th^{%
1855 \hyperreference%
1856 {\hyper@current@fnmark}%
1857 {\@thefnmark}%
1858 }$\hss%
1859 }}%
1860 \long\def\@makefntext##1{%
1861 \hyper@currentfnmark%
1862 \bgroup
1863 \edef\@currenthyper{\hyper@current@fnmark}
1864 \parindent 1em\noindent
1865 \hbox to1.8em{%
1866 \hss$\m@th^{%
1867 \hyperanchor{\hyper@current@fnmark}{\@thefnmark}%
1868 }$%
1869 }%
1870 ##1%
1871 \egroup%
1872 }%
1873 \if@twocolumn \twocolumn [\@maketitle ]%
1874 \else \newpage \global \@topnum \z@ \@maketitle \fi
1875 \thispagestyle{titlepage}\@thanks \endgroup
1876 \setcounter {footnote}\z@
1877 \gdef\@date{\today}\gdef\@thanks{}%
1878 \gdef\@author{}\gdef\@title{}}
1879 %</doc>
1880 % \end{macrocode}
1881 % Shit, now we can get the same name for hyper anchors, one via maketitle and one for the following text.
1882 % Let's pretend the titlepage being minipage 0. Note, that the definition of |\hyper@currentfnmark| given
1883 % above tests for this. (This is necessary!) Additionally we have to modify the macro |\thanks| to get
1884 % the correct anchors in the footnote texts.
1885 % \begin{macrocode}
1886 %<*hyper>
1887 \AtBeginDocument{%
1888 \let\hyper@maketitle\maketitle%
1889 \def\maketitle{%
1890 \edef\hyper@minipage@label{0}%
1891 \hyper@maketitle%
1892 \let\hyper@minipage@label\@empty%
1893 }%
1894 }
1895 \def\hyper@thanks@footnotetext#1[#2]#3{%
1896 \bgroup%
1897 \edef\hyper@current@fnmark{#1}%
1898 \let\hyper@currentfnmark\relax%
1899 \footnotetext[#2]{#3}%
1900 \egroup%
1901 }
1902 \def\thanks#1{\footnotemark%
1903 \expandafter\protected@xdef\expandafter\@thanks\expandafter{\expandafter\@thanks%
1904 \expandafter\protect%
1905 \expandafter\hyper@thanks@footnotetext%
1906 \expandafter{\hyper@current@fnmark}[\the\c@footnote]{#1}}%
1907 }
1908 %</hyper>
1909 % \end{macrocode}
1910 % \subsection{Lists}
1911 % Some lists have enumerated items which may be referenced to by the
1912 % label command. Hence we have to set the corresponding anchors.
1913 % \begin{macrocode}
1914 %<*hyper>
1915 \let\hyper@item\@item
1916 \def\@item[#1]{%
1917 \if@noitemarg%
1918 \if@nmbrlist%
1919 \hyper@item[\hyperanchor{\@currenthyper}{#1}]%
1920 \else%
1921 \hyper@item[{#1}]%
1922 \fi%
1923 \else%
1924 \hyper@item[{#1}]%
1925 \fi%
1926 }
1927 % \end{macrocode}
1928 %
1929 % \subsection{Index and Glossary}
1930 % As already has been said, we don't write the page number together with a
1931 % reference to |.idx|-- resp.\ |.glo|--files. |makeindex| wouldn't accept
1932 % such informations. But that means that we have to think of a way to get
1933 % back the references after |makeindex| has generated the index resp.\
1934 % glossary.\par
1935 % \noindent As this stuff needs an additional package we should include it only
1936 % if it is necessary. Thus, let us at first save it in a macro.
1937 % \begin{macrocode}
1938 \def\hyper@idxglo@cmds{
1939 % \end{macrocode}
1940 % \noindent For the following definition we need the |defpattern|-package.
1941 % \begin{macrocode}
1942 \RequirePackage{defpattern}
1943 % \end{macrocode}
1944 % Now we can define hypertext variants of the macros |\index| and
1945 % |\glossary|.\par
1946 % \noindent First of all we handle series of page numbers and ranges.
1947 % \begin{macrocode}
1948 \def\hyper@ref@page##1{\hyperpagereference{##1}{##1}}
1949 \defpattern\hyper@page@range[##2]{\hyper@ref@page{##2}}
1950 \defpattern\hyper@page@range[##2--##3]{%
1951 \hyper@ref@page{##2}--\hyper@ref@page{##3}%
1952 }
1953 \defpattern\hyper@page@range[##2, ##3]{%
1954 \hyper@page@range[##2], \hyper@page@range[##3]%
1955 }
1956 % \end{macrocode}
1957 % Based on this we can define a macro |\hyperpage| with an optional executable
1958 % macro as provided by the indexing system to surround a page number.
1959 % \begin{macrocode}
1960 \def\hyper@page@cmd[##1]##2{##1{\hyper@page@range[##2]}}
1961 \def\hyper@page@nocmd##1{\hyper@page@range[##1]}
1962 \def\hyperpage{\@ifnextchar[{\hyper@page@cmd}{\hyper@page@nocmd}}
1963 % \end{macrocode}
1964 % After saving the original meaning of |\index| and |\glossary|
1965 % \begin{macrocode}
1966 \let\hyper@index\index
1967 \let\hyper@glossary\glossary
1968 % \end{macrocode}
1969 % we can insert the page number surrounding command for |makeindex| by
1970 % \begin{macrocode}
1971 \defpattern\hyper@ig@pat[##2|##3]{##2{##3|hyperpage}}
1972 \defpattern\hyper@ig@pat[##2|##3|##4]{%
1973 ##2{##3|hyperpage[\hyper@backslash##4]}%
1974 }
1975 \defpattern\hyper@ig@pat[##2|##3|(##4]{%
1976 ##2{##3|(hyperpage[\hyper@backslash##4]}%
1977 }
1978 \defpattern\hyper@ig@pat[##2|##3|)##4]{%
1979 ##2{##3|)hyperpage[\hyper@backslash##4]}%
1980 }
1981 \defpattern\hyper@ig@pat[##2|##3|(]{##2{##3|(hyperpage}}
1982 \defpattern\hyper@ig@pat[##2|##3|)]{##2{##3|)hyperpage}}
1983 % \end{macrocode}
1984 % and define the new |\index|-- and |\glossary|--macros as follows.
1985 % \begin{macrocode}
1986 \def\hyper@ig{%
1987 \@bsphack\begingroup%
1988 \catcode`\@=12\catcode`\!=12\catcode`\|=12\catcode`\"=12\relax%
1989 \@sanitize\hyper@ig@%
1990 }
1991 \def\hyper@ig@##1##2{%
1992 \hyper@ig@pat[##1|##2]%
1993 \endgroup\@esphack%
1994 }
1995 \def\index{\hyper@ig\hyper@index}
1996 \def\glossary{\hyper@ig\hyper@glossary}
1997 % \end{macrocode}
1998 % We have reached the end of the macro. But as we do not call its contents
1999 % twice we just let the macro being a no-op before.
2000 % \begin{macrocode}
2001 \let\hyper@idxglo@cmds\relax
2002 }
2003 % \end{macrocode}
2004 % Now let's call the stuff whenever an index or glossary has to be generated.
2005 % \begin{macrocode}
2006 \ifnum%
2007 \ifx\@indexfile\@undefined0\else1\fi%
2008 \ifx\@glossaryfile\@undefined0\else1\fi%
2009 >0\relax
2010 \hyper@idxglo@cmds
2011 \fi
2012 \ifx\makeindex\@empty\else
2013 \let\hyper@makeindex\makeindex
2014 \def\makeindex{\hyper@makeindex\hyper@idxglo@cmds}
2015 \fi
2016 \ifx\makeglossary\@empty\else
2017 \let\hyper@makeglossary\makeglossary
2018 \def\makeglossary{\hyper@makeglossary\hyper@idxglo@cmds}
2019 \fi
2020 % \end{macrocode}
2021 %
2022 % \subsection{Theorems}
2023 % Theorems, Lemmatas, Corollaries, Examples, etc.\ are often refered to. Hence
2024 % they have to introduce an anchor for these references.
2025 % \begin{macrocode}
2026 \let\hyper@begintheorem\@begintheorem%
2027 \def\@begintheorem#1#2{\trivlist%
2028 \item[\hskip%
2029 \labelsep{\hyperanchor{\@currenthyper}{\bfseries #1\ #2}}%
2030 ]\itshape%
2031 }
2032 \def\@opargbegintheorem#1#2#3{\trivlist%
2033 \item[\hskip%
2034 \labelsep%
2035 {\hyperanchor{\@currenthyper}{\bfseries #1\ #2}\ (#3)}%
2036 ]\itshape%
2037 }
2038 %</hyper>
2039 % \end{macrocode}
2040 % These definitions are changed by the theorem--package. Hence, we have to
2041 % give hypertext definitions for them below.
2042 %
2043 % \subsection{Additional Patches}
2044 % The Hyper\TeX--previewer for NeXTSTEP can't handle multiple pages with the
2045 % same name correctly. It supposes that each link on a page number 1 is on
2046 % the first page with the number one. This is a problem for the title page
2047 % often having the same number as one of the following pages. Hence we patch
2048 % the page number of the title page from 1 to -1 (if the next page also has
2049 % number 1).
2050 % \begin{macrocode}
2051 %<*article,report>
2052 \let\hyper@titlepage\titlepage
2053 \def\titlepage{%
2054 \hyper@titlepage%
2055 \if@compatibility%
2056 \global\setcounter{page}{0}%
2057 \else%
2058 \global\setcounter{page}{-1}%
2059 \fi%
2060 }
2061 %</article,report>
2062 % \end{macrocode}
2063 % We have to ignore the stuff that is written to the |.aux|--file
2064 % by the extensional packages
2065 % \begin{macrocode}
2066 %<*hyper>
2067 \def\hyperbackcite#1#2#3#4{}
2068 %</hyper>
2069 % \end{macrocode}
2070 %
2071 % \subsection{Handling Options}
2072 % At first let us define some macros to collect and detect mutually
2073 % excluding options.
2074 % \begin{macrocode}
2075 %<*hyper>
2076 \def\hyper@set@option#1#2#3{%
2077 \ifx#1\@undefined%
2078 \def#1{#2}%
2079 \else%
2080 \PackageError{hyper}{#3}{}%
2081 \fi}
2082 \def\set@hyper@class#1{%
2083 \hyper@set@option\hyper@class{#1}%
2084 {Only one class is allowed in option list}%
2085 }
2086 \def\set@hyper@do#1{%
2087 \hyper@set@option\hyper@do{#1}%
2088 {Excluding options 'yes' and 'no' in option list found}%
2089 }
2090 \def\set@hyper@pageanchor#1{%
2091 \hyper@set@option\hyper@pageanchor{#1}%
2092 {Excluding options 'pagenumber' and 'pagetop' in option list found}%
2093 }
2094 \def\set@hyper@color#1{%
2095 \hyper@set@option\hyper@this@color{#1}%
2096 {Multiple color options in option list found}%
2097 }
2098 \def\set@hyper@idxglo{%
2099 \let\hyper@idxglo\hyper@idxglo@cmds%
2100 }
2101 % \end{macrocode}
2102 % We suppose each other option given being an additional package.
2103 % They are collected without regarding multiple occurrences.
2104 % \begin{macrocode}
2105 \def\hyper@packages{}
2106 \def\add@hyper@package#1{%
2107 \edef\hyper@packages{\hyper@packages(#1)}%
2108 }
2109 \def\hyper@extensions{}
2110 \def\add@hyper@extension#1{%
2111 \edef\hyper@extensions{\hyper@extensions(#1)}%
2112 }
2113 % \end{macrocode}
2114 % Now we define the options known to distribute them between the macros
2115 % given above.\par
2116 % \noindent The document classes known by the package are the following.
2117 % \begin{macrocode}
2118 \DeclareOption{article}{\set@hyper@class{article}}
2119 \DeclareOption{book}{\set@hyper@class{book}}
2120 \DeclareOption{letter}{\set@hyper@class{letter}}
2121 \DeclareOption{ltxdoc}{\set@hyper@class{ltxdoc}}
2122 \DeclareOption{ltxguide}{\set@hyper@class{ltxguide}}
2123 \DeclareOption{ltnews}{\set@hyper@class{ltnews}}
2124 \DeclareOption{proc}{\set@hyper@class{proc}}
2125 \DeclareOption{report}{\set@hyper@class{report}}
2126 \DeclareOption{slides}{\set@hyper@class{slides}}
2127 \DeclareOption{amsart}{\set@hyper@class{amsart}}
2128 \DeclareOption{amsproc}{\set@hyper@class{amsproc}}
2129 \DeclareOption{amsbook}{\set@hyper@class{amsbook}}
2130 \DeclareOption{amsdtx}{\set@hyper@class{amsdtx}}
2131 \DeclareOption{amsldoc}{\set@hyper@class{amsldoc}}
2132 \DeclareOption{cweb}{\set@hyper@class{cweb}}
2133 % \end{macrocode}
2134 % There are two options determining whether we want to insert the
2135 % hypertext--marks into the dvi--file.
2136 % \begin{macrocode}
2137 \DeclareOption{yes}{\set@hyper@do{\hyper}}
2138 \DeclareOption{no}{\set@hyper@do{\nohyper}}
2139 % \end{macrocode}
2140 % We should not forget that we have an optional behaviour for fixing the bounding box
2141 % of a hyper reference. So we have to introduce and handle an option for it.
2142 % \begin{macrocode}
2143 \DeclareOption{fixhyperbox}{%
2144 \AtBeginDocument{%
2145 \let\hyper@unnested@special@reference\hyper@unnested@special@reference@fix%
2146 \let\hyper@unnested@special@anchor\hyper@unnested@special@anchor@fix%
2147 }%
2148 }
2149 % In the subsection ``Colored Anchors/References'' we have introduced
2150 % three variants of colors the anchors resp.\ references may be printed in.
2151 % \begin{macrocode}
2152 \DeclareOption{color}{\set@hyper@color{\hyper@color}}
2153 \DeclareOption{gray}{\set@hyper@color{\hyper@gray}}
2154 \DeclareOption{black}{\set@hyper@color{\hyper@black}}
2155 % \end{macrocode}
2156 % We additionally have to choose whether a hyperlink to a page always
2157 % jumps to the page number or to the top of the page.
2158 % \begin{macrocode}
2159 \DeclareOption{pagenumber}{\set@hyper@pageanchor{\hyper@modifyheadfoot@pagebottom}}
2160 \DeclareOption{pagetop}{\set@hyper@pageanchor{\hyper@modifyheadfoot@pagetop}}
2161 % \end{macrocode}
2162 % If the user want to have the index and glossary commands,
2163 % e.g.\ when including an index or glossary
2164 % without using |\makeindex| respectively |\makeglossary| he may
2165 % give the option |indexcmds|.
2166 % \begin{macrocode}
2167 \DeclareOption{indexcmds}{\set@hyper@idxglo}
2168 % \end{macrocode}
2169 % Additionally we have to pass the options for the extensional packages
2170 % \begin{macrocode}
2171 \DeclareOption{backcitepages}{%
2172 \PassOptionsToPackage{pages}{hxt-bc}%
2173 \add@hyper@extension{hxt-bc}%
2174 }
2175 \DeclareOption{backcitesections}{%
2176 \PassOptionsToPackage{sections}{hxt-bc}%
2177 \add@hyper@extension{hxt-bc}%
2178 }
2179 % \end{macrocode}
2180 % All other options to be given are considered as packages.
2181 % \begin{macrocode}
2182 \DeclareOption*{\add@hyper@package{\CurrentOption}}
2183 % \end{macrocode}
2184 % Now let's collect the options given.
2185 % \begin{macrocode}
2186 \ProcessOptions
2187 % \end{macrocode}
2188 % So far now we know the options the user has send to us.\par
2189 % \noindent If no option determining a document class has been given we should
2190 % try to determine which class the document is of.
2191 % \begin{macrocode}
2192 \ifx\hyper@class\@undefined
2193 \@ifclassloaded{slides}{\def\hyper@class{slides}}{}
2194 \@ifclassloaded{report}{\def\hyper@class{report}}{}
2195 \@ifclassloaded{letter}{\def\hyper@class{letter}}{}
2196 \@ifclassloaded{book}{\def\hyper@class{book}}{}
2197 \@ifclassloaded{article}{\def\hyper@class{article}}{}
2198 \@ifclassloaded{proc}{\def\hyper@class{proc}}{}
2199 \@ifclassloaded{ltnews}{\def\hyper@class{ltnews}}{}
2200 \@ifclassloaded{ltxguide}{\def\hyper@class{ltxguide}}{}
2201 \@ifclassloaded{ltxdoc}{\def\hyper@class{ltxdoc}}{}
2202 \@ifclassloaded{amsart}{\def\hyper@class{amsart}}{}
2203 \@ifclassloaded{amsproc}{\def\hyper@class{amsproc}}{}
2204 \@ifclassloaded{amsbook}{\def\hyper@class{amsbook}}{}
2205 \@ifclassloaded{amsdtx}{\def\hyper@class{amsdtx}}{}
2206 \@ifclassloaded{amsldoc}{\def\hyper@class{amsldoc}}{}
2207 \@ifclassloaded{cweb}{\def\hyper@class{cweb}}{}
2208 \fi
2209 % \end{macrocode}
2210 % If there is a document class load the corresponding |.hyp|--file
2211 % otherwise give an error message.
2212 % \begin{macrocode}
2213 \ifx\hyper@class\@undefined
2214 \PackageError{hyper}{Document class can't be determined.\MessageBreak
2215 Please add one to the option list%
2216 }{}
2217 \else
2218 \InputIfFileExists{\[email protected]}{}%
2219 {\PackageError{hyper}{\[email protected] not found.\MessageBreak
2220 Please reinstall the complete package%
2221 }{}%
2222 }%
2223 \fi
2224 % \end{macrocode}
2225 % If we explicitely want to have the commands for index and glossary
2226 % we have to introduce them by calling the macro holding the stuff.
2227 % Note, that the macro is a nop when the stuff already has been added.
2228 % \begin{macrocode}
2229 \ifx\hyper@idxglo\@undefined\else
2230 \hyper@idxglo@cmds
2231 \fi
2232 % \end{macrocode}
2233 % If we want to print the anchors resp.\ references in colors we have to
2234 % load the |color|-package and defined the appropriate macros.
2235 % \begin{macrocode}
2236 \ifx\hyper@this@color\@undefined
2237 \else
2238 \expandafter\ifx\hyper@this@color\hyper@gray
2239 \RequirePackage{color}
2240 \else\expandafter\ifx\hyper@this@color\hyper@color
2241 \RequirePackage{color}
2242 \else\expandafter\ifx\hyper@this@color\hyper@black
2243 \else
2244 \PackageError{hyper}{Implementation error:\MessageBreak
2245 Case for reference/anchor color definition not defined}{}
2246 \fi\fi\fi
2247 \hyper@this@color
2248 \fi
2249 % \end{macrocode}
2250 % Afterwards we have to load modifications.\par
2251 % \noindent At first we just handle the document class option |leqno|
2252 % if it can be found in the option list.
2253 % \begin{macrocode}
2254 \@ifclasswith\hyper@class{leqno}%
2255 {\InputIfFileExists{leqno.hyp}{}%
2256 {\PackageError{hyper}{leqno.hyp not found.\MessageBreak
2257 Please reinstall the complete package}{}%
2258 }%
2259 }%
2260 {}
2261 % \end{macrocode}
2262 % We may have to handle some known packages, i.e.\ we need to load
2263 % some modifications for them.\par
2264 % \noindent As there is a common way to do this let us first define
2265 % a generic macro.
2266 % \begin{macrocode}
2267 \def\hyper@loadpackage#1{%
2268 \@ifpackageloaded{#1}%
2269 {\InputIfFileExists{#1.hyp}%
2270 {\expandafter\edef\csname hyper@loaded@#1\endcsname{#1.hyp}}%
2271 {\PackageError{hyper}{#1.hyp not found.\MessageBreak
2272 Please reinstall the complete package}{}%
2273 }%
2274 }%
2275 {}
2276 }
2277 % \end{macrocode}
2278 % Now we can call this macro for each package known.
2279 % \begin{macrocode}
2280 \hyper@loadpackage{amsmath}
2281 \hyper@loadpackage{amstex}
2282 \hyper@loadpackage{amsthm}
2283 \hyper@loadpackage{doc}
2284 \hyper@loadpackage{fancyheadings}
2285 \hyper@loadpackage{ftnright}
2286 \hyper@loadpackage{harvard}
2287 \hyper@loadpackage{longtable}
2288 \hyper@loadpackage{natbib}
2289 \hyper@loadpackage{subeqnarray}
2290 \hyper@loadpackage{theorem}
2291 \hyper@loadpackage{upref}
2292 \hyper@loadpackage{xr}
2293 % \end{macrocode}
2294 % Afterwards we add each package the user has told us to do.
2295 % \begin{macrocode}
2296 \def\@hyper@load@pkg(#1){%
2297 \expandafter\ifx\csname hyper@loaded@#1\endcsname\relax%
2298 \IfFileExists{#1.hyp}%
2299 {\IfFileExists{#1.sty}{\RequirePackage{#1}}{}%
2300 \input{#1.hyp}%
2301 \expandafter\edef\csname hyper@loaded@#1\endcsname{#1.hyp}%
2302 }%
2303 {\PackageError{hyper}{Modification file #1.hyp not found}{}}%
2304 \fi%
2305 \hyper@loadpackage%
2306 }
2307 \def\hyper@loadpackage{\@ifnextchar({\@hyper@load@pkg}{}}
2308 \expandafter\hyper@loadpackage\hyper@packages\relax
2309 % \end{macrocode}
2310 % Additionally, we have to load some extensions of the hyper package.
2311 % \begin{macrocode}
2312 \def\@hyper@load@ext(#1){%
2313 \expandafter\ifx\csname hyper@loaded@ext@#1\endcsname\relax%
2314 \IfFileExists{#1.sty}%
2315 {\RequirePackage{#1}%
2316 \expandafter\edef\csname hyper@loaded@ext@#1\endcsname{#1.sty}%
2317 }%
2318 {\PackageError{hyper}{Extension file #1.sty not found}{}}%
2319 \fi%
2320 \hyper@loadpackage%
2321 }
2322 \def\hyper@load@extension{\@ifnextchar({\@hyper@load@ext}{}}
2323 \expandafter\hyper@load@extension\hyper@extensions\relax
2324 % \end{macrocode}
2325 % Now we have to activate the (nondefault) decision for placing the anchors on pages (top of page or pagenumber)
2326 % \begin{macrocode}
2327 \ifx\hyper@pageanchor\@undefined
2328 \else
2329 \expandafter\let\expandafter\hyper@modifyheadfoot\hyper@pageanchor
2330 \fi
2331 % \end{macrocode}
2332 % Last but not least we have to decide whether we really want the
2333 % hypertext--marks being inserted into the dvi--file.
2334 % \begin{macrocode}
2335 \ifx\hyper@do\@undefined\else\hyper@do\fi
2336 %</hyper>
2337 % \end{macrocode}
2338 %
2339 % \subsection{Compatibility with Ordinary \LaTeX}
2340 % The package redefines the notion of a label. Thus, to be able to add the
2341 % package to an exising \LaTeX-file without having trouble with an existing
2342 % |.aux|-file we have to be able to handle the old as well as the new definition:
2343 % \begin{macrocode}
2344 %<*hyper>
2345 \def\hyper@end@newlabel{\relax}
2346 \let\hyper@orig@newlabel\newlabel
2347 \def\hyper@newlabel#1#2#3#4#5{%
2348 \ifx|#4|%
2349 \hyper@orig@newlabel{#1}{{}{}{#2}{#3}}%
2350 \else%
2351 \hyper@orig@newlabel{#1}{{#2}{#3}{#4}{#5}}%
2352 \fi%
2353 }
2354 \def\newlabel#1#2{\hyper@newlabel{#1}#2\hyper@end@newlabel\hyper@end@newlabel}
2355 % \end{macrocode}
2356 %
2357 % The package leaves traces for intermediate informations in several auxiliary files.
2358 % To be able to remove the package without deleting these auxiliary files, certain
2359 % definitions have to remain to exist. The following code ensures, that these definitions
2360 % are availlable, by adding them to the subsequently generated |.aux|-files.
2361 % \begin{macrocode}
2362 \begingroup
2363 \catcode`\<=\catcode`\{
2364 \catcode`\>=\catcode`\}
2365 \catcode`\{=12\catcode`\}=12
2366 \catcode`\%=12
2367 \gdef\hyper@open<{>
2368 \gdef\hyper@close<}>
2369 \gdef\hyper@comment<%>
2370 \endgroup
2371 \def\hyper@nl{^^J}%
2372 \long\def\hyper@protected@write#1{%
2373 \begingroup%
2374 \let\thepage\relax%
2375 \let\protect\@unexpandable@protect%
2376 \edef\reserved@a{\immediate\write\@auxout{#1}}%
2377 \reserved@a%
2378 \endgroup%
2379 \if@nobreak\ifvmode\nobreak\fi\fi%
2380 }
2381 \gdef\hyper@aux@write{
2382 \hyper@protected@write{\hyper@comment@potential%
2383 \string\ifx\string\newhyper\string\@undefined%
2384 }
2385 \hyper@protected@write{\hyper@comment@potential%
2386 \string\gdef\string\newhyper\hyper@hash1\hyper@hash2{}\hyper@nl
2387 \string\gdef\string\hyperfnpage\hyper@hash1\hyper@hash2{}\hyper@nl
2388 \string\global\string\let\string\@hyper@newlabel\string\newlabel\hyper@nl
2389 \string\gdef\string\hyper@end@newlabel{\string\relax}\hyper@nl
2390 \string\gdef\string\hyper@newlabel\hyper@hash1\hyper@hash2\hyper@hash3\hyper@hash4\hyper@hash5%
2391 {\hyper@comment@potential%
2392 \string\ifx\string|\hyper@hash4\string|\string\hyper@end@newlabel\hyper@comment@potential%
2393 \string\@hyper@newlabel{\hyper@hash1}{{\hyper@hash2}{\hyper@hash3}}%
2394 \hyper@comment@potential%
2395 \string\else\hyper@comment@potential%
2396 \string\@hyper@newlabel{\hyper@hash1}{{\hyper@hash4}{\hyper@hash5}}%
2397 \hyper@comment@potential%
2398 \string\fi\hyper@comment@potential%
2399 }\hyper@nl
2400 \string\gdef\string\newlabel\hyper@hash1\hyper@hash2%
2401 {\string\hyper@newlabel{\hyper@hash1}\hyper@hash2%
2402 \string\hyper@end@newlabel\string\hyper@end@newlabel}\hyper@nl
2403 \string\gdef\string\@@hyperpage[\hyper@hash1]{\hyper@hash1}\hyper@nl
2404 \string\gdef\string\@hyperpage\hyper@hash1{\hyper@hash1}\hyper@nl
2405 \string\gdef\string\hyperpage%
2406 {\string\@ifnextchar[\string\@@hyperpage\string\@hyperpage}\hyper@nl
2407 \string\global\string\let\string\fragilehyperreference\string\@gobble\hyper@nl
2408 \string\global\string\let\string\fragilehyperpagereference\string\@gobble\hyper@nl
2409 \string\global\string\let\string\fragilehyperanchor\string\@gobble\hyper@nl
2410 \string\global\string\let\string\fragileblindhyperanchor\string\@gobble\hyper@nl
2411 \string\global\string\let\string\fragilehyperURL\string\@gobble\hyper@nl
2412 \string\gdef\string\hyperbackcite\hyper@hash1\hyper@hash2\hyper@hash3\hyper@hash4%
2413 {}\hyper@nl
2414 \string\global\string\let\string\hyper@setref\string\@setref\hyper@nl
2415 \string\gdef\string\hyper@thirdoffour\hyper@hash1\hyper@hash2\hyper@hash3%
2416 {\hyper@hash2}\hyper@nl
2417 \string\gdef\string\hyper@forthoffour\hyper@hash1\hyper@hash2\hyper@hash3%
2418 {\hyper@hash3}\hyper@nl
2419 \string\gdef\string\hyper@end@forthoffour{\string\relax}\hyper@nl
2420 \string\gdef\string\@setref\hyper@hash1{\hyper@comment@real\hyper@nl
2421 \string\ifx\hyper@hash1\string\relax\hyper@comment@real\hyper@nl
2422 \string\def\string\hyper@next{\string\hyper@setref{\hyper@hash1}}%
2423 \hyper@comment@real\hyper@nl
2424 \string\else\hyper@comment@real\hyper@nl
2425 \string\edef\string\hyper@tmp%
2426 {\string\expandafter\string\hyper@forthoffour\hyper@hash1%
2427 \string\hyper@end@forthoffour}\hyper@comment@real\hyper@nl
2428 \string\ifx\string\hyper@tmp\string\hyper@end@forthoffour%
2429 \hyper@comment@real\hyper@nl
2430 \string\def\string\hyper@next{\string\hyper@setref{\hyper@hash1}}%
2431 \hyper@comment@real\hyper@nl
2432 \string\else\hyper@comment@real\hyper@nl
2433 \string\edef\string\hyper@tmp%
2434 {{\string\expandafter\string\hyper@thirdoffour\hyper@hash1}%
2435 {\string\expandafter\string\hyper@forthoffour\hyper@hash1}}%
2436 \hyper@comment@real\hyper@nl
2437 \string\def\string\hyper@next{\string\hyper@setref{\string\hyper@tmp}}%
2438 \hyper@comment@real\hyper@nl
2439 \string\fi\hyper@comment@real\hyper@nl
2440 \string\fi\hyper@comment@real\hyper@nl
2441 \string\hyper@next\hyper@comment@real\hyper@nl
2442 }
2443 }
2444 \hyper@protected@write{\hyper@comment@potential%
2445 \string\begingroup\hyper@nl
2446 \string\catcode\string`\string\<\string=\string\catcode\string`\string\{\hyper@nl
2447 \string\catcode\string`\string\>\string=\string\catcode\string`\string\}\hyper@nl
2448 \string\catcode\string`\string\{\string=12%
2449 \string\catcode\string`\string\}\string=12\hyper@nl
2450 \string\catcode\string`\string\%\string=12\hyper@nl
2451 \string\gdef\string\hyper@open<{>\hyper@nl
2452 \string\gdef\string\hyper@close<}>\hyper@nl
2453 \string\gdef\string\hyper@comment<\hyper@comment@real>\hyper@nl
2454 \string\endgroup
2455 }
2456 \hyper@protected@write{\hyper@comment@potential%
2457 \string\bgroup\hyper@nl
2458 \string\global\string\edef\string\hyper@hash{\string\string\hyper@hash}\hyper@nl
2459 \string\egroup
2460 }
2461 \hyper@protected@write{\hyper@comment@potential%
2462 \string\gdef\string\hyper@nl{\string^\string^J}
2463 }
2464 \hyper@protected@write{\hyper@comment@potential%
2465 \string\def\string\hyper@hash@four{\string\hyper@hash\string\hyper@hash%
2466 \string\hyper@hash\string\hyper@hash}
2467 }
2468 \hyper@protected@write{\hyper@comment@potential%
2469 \string\global\string\long\string\def\string\hyper@protected@write\hyper@hash1%
2470 {\hyper@nl
2471 \string\begingroup\hyper@nl
2472 \string\let\string\thepage\string\relax\hyper@nl
2473 \string\let\string\protect\string\@unexpandable@protect\hyper@nl
2474 \string\edef\string\reserved@a{\string\immediate\string\write\string\@auxout%
2475 {\hyper@hash1}}\hyper@nl
2476 \string\reserved@a\hyper@nl
2477 \string\endgroup\hyper@nl
2478 \string\if@nobreak\string\ifvmode\string\nobreak\string\fi\string\fi\hyper@nl
2479 }
2480 }
2481 \hyper@protected@write{\hyper@comment@potential%
2482 \string\gdef\string\hyper@aux@write\hyper@open
2483 }%
2484 \hyper@second@write{\hyper@comment@potential%
2485 \string\hyper@write\hyper@open\hyper@nl
2486 \string\begingroup\hyper@nl
2487 \string\let\string\@hyper@protected@write\string\hyper@protected@write\hyper@nl
2488 \string\def\string\hyper@protected@write@do\hyper@hash\hyper@hash1%
2489 \hyper@hash\hyper@hash2{\hyper@nl
2490 \string\begingroup\hyper@nl
2491 \string\let\string\hyper@string\string\string\hyper@nl
2492 \string\def\string\string%
2493 {\string\hyper@string\string\string\string\hyper@string}\hyper@nl
2494 \string\def\string\hyper@open%
2495 {\string\hyper@string\string\hyper@open}\hyper@nl
2496 \string\def\string\hyper@close%
2497 {\string\hyper@string\string\hyper@close}\hyper@nl
2498 \string\def\string\hyper@nl%
2499 {\string\hyper@string\string\hyper@nl\string^\string^J}\hyper@nl
2500 \string\def\string\hyper@comment@real%
2501 {\string\hyper@string\string\hyper@comment@real}\hyper@nl
2502 \string\def\string\hyper@comment@potential%
2503 {\string\hyper@string\string\hyper@comment@potential%
2504 \string\hyper@comment\string^\string^J}\hyper@nl
2505 \string\def\string\hyper@hash%
2506 {\string\hyper@string\string\hyper@hash}\hyper@nl
2507 \string\@hyper@protected@write%
2508 {\string\hyper@string\hyper@hash\hyper@hash1%
2509 {\hyper@hash\hyper@hash2\string^\string^J}}\hyper@nl
2510 \string\endgroup\hyper@nl
2511 }\hyper@nl
2512 \string\def\string\hyper@protected@write%
2513 {\string\hyper@protected@write@do\string\hyper@protected@write}%
2514 \hyper@nl
2515 \string\def\string\hyper@second@write\hyper@hash\hyper@hash1{\hyper@nl
2516 \string\hyper@protected@write@do\string\hyper@second@write%
2517 {\hyper@hash\hyper@hash1}\hyper@nl
2518 \string\@hyper@protected@write{\hyper@hash\hyper@hash1}\hyper@nl
2519 }\hyper@nl
2520 \string\def\string\hyper@write{\string\@gobble}\hyper@nl
2521 \string\hyper@aux@write\hyper@nl
2522 \string\endgroup\hyper@nl
2523 \hyper@close
2524 }
2525 \hyper@write{
2526 \begingroup
2527 \let\@hyper@protected@write\hyper@protected@write
2528 \def\hyper@protected@write@do##1##2{
2529 \begingroup
2530 \let\hyper@string\string
2531 \def\string{\hyper@string\string\hyper@string}
2532 \def\hyper@open{\hyper@string\hyper@open}
2533 \def\hyper@close{\hyper@string\hyper@close}
2534 \def\hyper@nl{\hyper@string\hyper@nl^^J}
2535 \def\hyper@comment@real{\hyper@string\hyper@comment@real}
2536 \def\hyper@comment@potential%
2537 {\hyper@string\hyper@comment@potential\hyper@comment^^J}
2538 \def\hyper@hash{\hyper@string\hyper@hash}
2539 \@hyper@protected@write{\hyper@string##1{##2^^J}}
2540 \endgroup
2541 }
2542 \def\hyper@protected@write{\hyper@protected@write@do\hyper@protected@write}
2543 \def\hyper@second@write##1{
2544 \hyper@protected@write@do\hyper@second@write{##1}
2545 \@hyper@protected@write{##1}
2546 }
2547 \def\hyper@write{\@gobble}
2548 \hyper@aux@write
2549 \endgroup
2550 }
2551 \hyper@protected@write{\hyper@comment@potential%
2552 \hyper@close
2553 }
2554 \hyper@protected@write{\hyper@comment@potential%
2555 \string\AtBeginDocument{\hyper@comment@real\hyper@nl%
2556 \string\let\string\hyper@write\string\relax%
2557 \hyper@comment@real\hyper@nl%
2558 \string\let\string\hyper@second@write\string\@gobble%
2559 \hyper@comment@real\hyper@nl%
2560 \string\let\string\hyper@comment@potential\string\@empty%
2561 \hyper@comment@real\hyper@nl%
2562 \string\let\string\hyper@comment@real\string\hyper@comment%
2563 \hyper@comment@real\hyper@nl%
2564 \string\hyper@aux@write\hyper@comment@real\hyper@nl%
2565 }
2566 }
2567 \hyper@protected@write{\hyper@comment@potential%
2568 \string\fi
2569 }
2570 \relax
2571 }
2572 \AtBeginDocument{%
2573 \let\hyper@write\relax%
2574 \let\hyper@second@write\@gobble%
2575 \let\hyper@comment@potential\@empty%
2576 \let\hyper@comment@real\hyper@comment%
2577 \hyper@aux@write%
2578 }
2579 %</hyper>
2580 % \end{macrocode}
2581 %
2582 % \clearpage
2583 %
2584 % \section{Supported Packages}
2585 %
2586 % \subsection{\amslatex}
2587 % \subsubsection{The Classes}
2588 % First of all let us modify the \amslatex--classes.\par
2589 % \noindent We change |amsart.cls|, |amsproc.cls|, and |amsbook.cls|
2590 % in the following way.
2591 % \begin{macrocode}
2592 %<*amsart,amsproc,amsbook>
2593 \let\hyper@makecaption\@makecaption
2594 \def\@makecaption#1#2{%
2595 \hyper@makecaption{\hyperanchor{\@currenthyper}{#1}}{#2}%
2596 }
2597 \def\@makefnmark{%
2598 \hyper@currentfnmark%
2599 \hbox{%
2600 \@textsuperscript{%
2601 \normalfont%
2602 \hyperreference{\hyper@current@fnmark}%
2603 {\@thefnmark}%
2604 }%
2605 }%
2606 }
2607 \long\def\@makefntext#1{\indent%
2608 \hyper@currentfnmark%
2609 \bgroup%
2610 \edef\@currenthyper{\hyper@current@fnmark}%
2611 \parindent 1em\noindent
2612 \hbox{%
2613 \hss\@textsuperscript{%
2614 \normalfont%
2615 \hyperanchor{\hyper@current@fnmark}{\@thefnmark}%
2616 }%
2617 }%
2618 #1
2619 \egroup%
2620 }
2621 \let\hyper@tocwriteb\@tocwriteb
2622 \def\hyper@tocwriteb@def[#1]{%
2623 \def\@tocwriteb##1##2##3{%
2624 \hyper@tocwriteb{##1}{##2}{#1}%
2625 \let\@tocwriteb\hyper@tocwriteb%
2626 }%
2627 }
2628 \def\@sect#1#2#3#4#5#6[#7]#8{%
2629 \ifnum#2>\c@secnumdepth%
2630 \hyper@setcurrent%
2631 \else%
2632 \refstepcounter{#1}%
2633 \ignore@next@refstepcounter%
2634 \fi%
2635 \hyper@settype{#1}%
2636 \global\let\@currenthyper\@currenthyper%
2637 \global\let\@currenthypertype\@currenthypertype%
2638 \ifnum#2>\@m\else%
2639 \callwithexpandedhyperref{\hyper@tocwriteb@def}{#8}%
2640 \fi%
2641 \callwithexpandedhyperref%
2642 {\hyper@sect{#1}{#2}{#3}{#4}{#5}{#6}}%
2643 {#7}%
2644 {\hyperanchor{\@currenthyper}{#8}}%
2645 }
2646 %</amsart,amsproc,amsbook>
2647 % \end{macrocode}
2648 % For |amsbook.cls| we need some additional modifications for parts and chapters.
2649 % \begin{macrocode}
2650 %<*amsbook>
2651 \let\hyper@chapter\@chapter
2652 \def\@chapter[#1]#2{%
2653 \refstepcounter{chapter}%
2654 \ignore@next@refstepcounter%
2655 \hyper@settype{chapter}%
2656 \global\let\@currenthyper\@currenthyper%
2657 \global\let\@currenthypertype\@currenthypertype%
2658 \callwithexpandedhyperref{\hyper@tocwriteb@def}{#2}%
2659 \hyper@chapter[#1]{\hyperanchor{\@currenthyper}{#2}}%
2660 }
2661 \let\hyper@chaptermark\chaptermark
2662 \def\hyper@chaptermark@def[#1]{%
2663 \def\chaptermark##1{%
2664 \hyper@chaptermark{#1}%
2665 \let\chaptermark\hyper@chaptermark%
2666 }%
2667 }
2668 \let\hyper@schapter\@schapter
2669 \def\@schapter#1{%
2670 \hyper@setcurrent%
2671 \hyper@settype{chapter}%
2672 \global\let\@currenthyper\@currenthyper%
2673 \global\let\@currenthypertype\@currenthypertype%
2674 \callwithexpandedhyperref{\hyper@tocwriteb@def}{#1}%
2675 \callwithexpandedhyperref{\hyper@chaptermark@def}{#1}%
2676 \hyper@schapter{\hyperanchor{\@currenthyper}{#1}}%
2677 }
2678 \let\hyper@part\@part
2679 \def\@part[#1]#2{%
2680 \ifnum\c@secnumdepth>-2\relax%
2681 \refstepcounter{part}%
2682 \ignore@next@refstepcounter%
2683 \else%
2684 \hyper@setcurrent%
2685 \fi%
2686 \hyper@settype{part}%
2687 \global\let\@currenthyper\@currenthyper%
2688 \global\let\@currenthypertype\@currenthypertype%
2689 \callwithexpandedhyperref%
2690 {\hyper@part}%
2691 {#1}%
2692 {\hyperanchor{\@currenthyper}{#2}}%
2693 }
2694 \def\hyper@add@part[#1]{%
2695 \addcontentsline{toc}{part}{\protect\noindent#1}%
2696 }
2697 \def\@spart#1{%
2698 \hyper@setcurrent%
2699 \hyper@settype{part}%
2700 \global\let\@currenthyper\@currenthyper%
2701 \global\let\@currenthypertype\@currenthypertype%
2702 \callwithexpandedhyperref{\hyper@add@part}{#1}%
2703 \begingroup\centering
2704 \fontsize{\@xxpt}{25}\bfseries
2705 \hyperanchor{\@currenthyper}{#1}%
2706 \vfil\vfil\endgroup \newpage\thispagestyle{empty}}
2707 %</amsbook>
2708 % \end{macrocode}
2709 % |amsdtx.cls| has to be modified as follows.
2710 % \begin{macrocode}
2711 %<*amsdtx>
2712 \input{book.hyp}
2713 \renewcommand\maketitle{\par
2714 \begingroup
2715 \renewcommand\thefootnote{\fnsymbol{footnote}}%
2716 \def\@makefnmark{%
2717 \hyper@currentfnmark%
2718 \hbox to\z@{%
2719 \@textsuperscript{%
2720 \normalfont%
2721 \hyperreference%
2722 {\hyper@current@fnmark}%
2723 {\@thefnmark}%
2724 }%
2725 }}%
2726 \long\def\@makefntext##1{%
2727 \hyper@currentfnmark%
2728 \bgroup%
2729 \edef\@currenthyper{\hyper@current@fnmark}%
2730 \parindent 1em%
2731 \noindent%
2732 \hbox to1.8em%
2733 {\hss$\m@th^{%
2734 \hyperanchor{\hyper@current@fnmark}{\@thefnmark}%
2735 }$}##1%
2736 \egroup%
2737 }%
2738 \if@twocolumn
2739 \ifnum \col@number=\@ne
2740 \@maketitle
2741 \else
2742 \twocolumn[\@maketitle]%
2743 \fi
2744 \else
2745 \newpage
2746 \global\@topnum\z@
2747 \@maketitle
2748 \fi
2749 \thispagestyle{plain}\@thanks
2750 \endgroup
2751 \setcounter{footnote}{0}%
2752 \let\thanks\relax
2753 \let\maketitle\relax\let\@maketitle\relax
2754 \gdef\@thanks{}\gdef\@author{}\gdef\@title{}}
2755 %</amsdtx>
2756 % \end{macrocode}
2757 % For |amsldoc.cls| we need the following changes.
2758 % \begin{macrocode}
2759 %<*amsldoc>
2760 \input{book.hyp}
2761 \let\hyper@theindex@ams\theindex%fetch modified index from book.hyp
2762 \def\theindex{%
2763 \hyper@theindex@ams%
2764 \let\autoindex\@gobble%
2765 }
2766 %</amsldoc>
2767 % \end{macrocode}
2768 % \subsubsection{The Packages}
2769 % To add the hypertext--capability to |amsmath| respectively |amstex|
2770 % some macros of them have to be modified.\par
2771 % \noindent As we have redefined |\@eqnnum| and we need another
2772 % definition for |amsmath| and |amstex| let us set the macro to its
2773 % default.
2774 % \begin{macrocode}
2775 %<*amsmath,amstex>
2776 \iftagsleft@
2777 \def\@eqnnum{\hbox to1sp{}\rlap{\normalfont\normalcolor
2778 \hskip -\displaywidth\tagform@\theequation}}
2779 \else
2780 \def\@eqnnum{{\normalfont\normalcolor \tagform@\theequation}}
2781 \fi
2782 %</amsmath,amstex>
2783 % \end{macrocode}
2784 % |amsmath| temporary redefines |\label| but needs the original definition
2785 % that is hold in |\ltx@label|.
2786 % \begin{macrocode}
2787 %<*amsmath>
2788 \let\ltx@label\label
2789 %</amsmath>
2790 % \end{macrocode}
2791 % Now let us define a blind anchor for referencing a couple of equations
2792 % bound together.
2793 % \begin{macrocode}
2794 %<*amsmath,amstex>
2795 \let\hyper@subequations\subequations
2796 \def\subequations{%
2797 \hyper@setcurrent%
2798 \hyper@settype{equation}%
2799 \blindhyperanchor{\@currenthyper}%
2800 \hyper@subequations%
2801 }
2802 % \end{macrocode}
2803 % To allow the references pointing to an equation number we have to define an
2804 % appropriate anchor.
2805 % \begin{macrocode}
2806 \let\hyper@tagform@\tagform@
2807 \def\tagform@#1{%
2808 \maketag@@@{\hyperanchor{\@currenthyper}{(\ignorespaces#1\unskip)}}%
2809 }
2810 %</amsmath,amstex>
2811 % \end{macrocode}
2812 % For user defined tags it is necessary to generate a new hypertext number
2813 % in |amsmath|.
2814 % \begin{macrocode}
2815 %<*amsmath>
2816 \let\hyper@make@display@tag\make@display@tag
2817 \def\make@display@tag{%
2818 \if@eqnsw\else\iftag@%
2819 \hyper@setcurrent%
2820 \hyper@settype{equation}%
2821 \fi\fi%
2822 \hyper@make@display@tag%
2823 }
2824 %</amsmath>
2825 % \end{macrocode}
2826 % For |amstex| a similar result cannot be provided with an as simple changing.
2827 % This is due to |\@seteqlabel| being called when introducing a new tag.
2828 % Supposing |\@seteqlabel| defining the correct |\@currenthyper| we therefore
2829 % have to modify |\make@df@tag| as follows.
2830 % \begin{macrocode}
2831 %<*amstex>
2832 \def\make@df@tag@@@#1{%
2833 \@seteqlabel{#1}%
2834 \global\let\ams@currenthyper\@currenthyper%
2835 \gdef\df@tag{\let\@currenthyper\ams@currenthyper\tagform@{#1}}%
2836 }
2837 % \end{macrocode}
2838 % Now we just have to ensure |\@seteqlabel| defining the correct
2839 % |\@currenthyper|.
2840 % \begin{macrocode}
2841 \def\@seteqlabel#1{%
2842 \toks@\@xp{\p@equation{#1}}%
2843 \hyper@setcurrent%
2844 \hyper@settype{equation}%
2845 \edef\@currenthyper{\@currenthyper.\the\toks@}%
2846 \edef\@currentlabel{\the\toks@}%
2847 }
2848 %</amstex>
2849 % \end{macrocode}
2850 % We should not use an anchor when using |\eqref|
2851 % \begin{macrocode}
2852 %<*amsmath,amstex>
2853 \def\eqref#1{\textup{\hyper@tagform@{\ref{#1}}}}
2854 %</amsmath,amstex>
2855 % \end{macrocode}
2856 % Damned |amstex| redefines the macro |\label|. We have to ensure that the
2857 % correct stuff is written into the |.aux|-file when this macro is called.
2858 % \begin{macrocode}
2859 %<*amstex>
2860 \def\hyperlabel#1{%
2861 \@bsphack%
2862 \iffirstchoice@\if@filesw%
2863 {\let\thepage\relax%
2864 \def\protect{\noexpand\noexpand\noexpand}%
2865 \xdef\@gtempa{%
2866 \write\@auxout{%
2867 \string\newlabel{#1}{{\@currenthypertype}{\@currenthyper}{\@currentlabel}{\thepage}}%
2868 }%
2869 }%
2870 }%
2871 \@gtempa%
2872 \if@nobreak\ifvmode\nobreak\fi\fi%
2873 \fi\fi%
2874 \@esphack%
2875 }
2876 \let\label\hyperlabel
2877 %</amstex>
2878 % \end{macrocode}
2879 % To get hypertext references to theorems, lemmas, etc.\ |amsthm| has to
2880 % be modified.
2881 % \begin{macrocode}
2882 %<*amsthm>
2883 \let\@begintheorem\hyper@begintheorem
2884 \def\thmhead@plain#1#2#3{%
2885 \hyperanchor{\@currenthyper}{\thmname{#1}\thmnumber{ #2}}%
2886 \thmnote{ {\the\thm@notefont(#3)}}%
2887 }
2888 \let\thmhead\thmhead@plain
2889 \def\swappedhead#1#2#3{%
2890 \hyperanchor{\@currenthyper}{\thmnumber{#2}\thmname{. #1}}%
2891 \thmnote{ {\the\thm@notefont(#3)}}%
2892 }
2893 %</amsthm>
2894 % \end{macrocode}
2895 % For |upref| working correct it is sufficient to modify |\hyper@setref|.
2896 % \begin{macrocode}
2897 %<*upref>
2898 \def\hyper@setref#1#2#3#4{%
2899 \ifx#1\relax%
2900 \protect\G@refundefinedtrue%
2901 #4\nfss@text{\reset@font\bfseries ??}%
2902 \@latex@warning{Reference `#3' on page \thepage \space undefined}%
2903 \else%
2904 \edef\hyper@tmp{\expandafter\hyper@secondoffour#1}%
2905 \ifx\hyper@tmp\@empty%
2906 \ifx#2\hyper@secondoffour%
2907 #4\null%
2908 \else\ifx#2\hyper@thirdoffour%
2909 #4\protect\textup{\expandafter#2#1\hbox{}}\null%
2910 \else%
2911 #4\protect\textup{\expandafter#2#1\hbox{}}\null%
2912 \fi\fi%
2913 \else%
2914 \ifx#2\hyper@secondoffour%
2915 \hyperreference{\expandafter\hyper@secondoffour#1}{#4}\null%
2916 \else\ifx#2\hyper@thirdoffour%
2917 \hyperreference%
2918 {\expandafter\hyper@secondoffour#1}%
2919 {#4\protect\textup{\expandafter#2#1\hbox{}}}\null%
2920 \else%
2921 \hyperpagereference%
2922 {\expandafter\hyper@forthoffour#1}%
2923 {#4\protect\textup{\expandafter#2#1\hbox{}}}\null%
2924 \fi\fi%
2925 \fi%
2926 \fi%
2927 }
2928 %</upref>
2929 % \end{macrocode}
2930 %
2931 % \subsection{Cross References between Documents}
2932 % The package |xr| adds the capability of generating cross--references
2933 % between different \LaTeXe--documents. It is a nice feature to support
2934 % this by hypertext links. Thus we have to modify |xr| appropriately.\par
2935 % \noindent At first let us provide an additional parameter to |\externaldocument|
2936 % giving the URL--address of the document we use references to. It has to
2937 % be given with surrounding |(||)|. The default value is given by
2938 % |documentname.dvi|.
2939 % \begin{macrocode}
2940 %<*xr>
2941 \def\externaldocument{%
2942 \@ifnextchar(%
2943 {\hyper@externaldocument}%
2944 {\hyper@externaldocument()}%
2945 }
2946 \def\hyper@externaldocument(#1){%
2947 \@ifnextchar[%
2948 {\hyper@@externaldocument(#1)}%
2949 {\hyper@@externaldocument(#1)[]}%
2950 }
2951 \def\hyper@@externaldocument(#1)[#2]#3{%
2952 \def\hyper@XR@docprefix{#1}%
2953 \ifx\hyper@XR@docprefix\@empty%
2954 \def\hyper@XR@docprefix{#3.dvi}%
2955 \fi%
2956 \XR@[#2]{#3}%
2957 }
2958 % \end{macrocode}
2959 % Now we have to modify the anchors we refer to from their local definition
2960 % in the documents |.aux|--file to its external URL--definitions.
2961 % \begin{macrocode}
2962 \def\hyper@xr@end@newlabel{\relax}
2963 \def\hyper@xr@newlabel#1#2#3#4#5{%
2964 \ifx#4\hyper@xr@end@newlabel%
2965 \newlabel%
2966 {\XR@prefix#1}%
2967 {{}%
2968 {}%
2969 {#2}%
2970 {[file:\hyper@XR@docprefix][#3]}%
2971 }%
2972 \else%
2973 \newlabel%
2974 {\XR@prefix#1}%
2975 {{#2}%
2976 {[file:\hyper@XR@docprefix][#3]}%
2977 {#4}%
2978 {[file:\hyper@XR@docprefix][#5]}%
2979 }%
2980 \fi
2981 }
2982 \long\def\XR@test#1#2#3#4\XR@{%
2983 \ifx#1\newlabel%
2984 \expandafter\hyper@xr@newlabel{#2}#3\hyper@xr@end@newlabel\hyper@xr@end@newlabel%
2985 \else\ifx#1\newhyper%
2986 \newhyper{\XR@prefix#2}{#3}%
2987 \else\ifx#1\@input%
2988 \edef\XR@list{\XR@list#2\relax}%
2989 \fi\fi\fi%
2990 \ifeof%
2991 \@inputcheck\expandafter\XR@aux%
2992 \else%
2993 \expandafter\XR@read%
2994 \fi%
2995 }
2996 %</xr>
2997 % \end{macrocode}
2998 %
2999 % \subsection{Fancy Headings}
3000 % The package |fancyheadings| uses a different way to express headings. This gives us trouble on
3001 % pages with an ``empty'' page style via the (default) settings for headers and footers using
3002 % the macro |\fancyplain|. To get the page number if all the parts for the heads and foots are empty
3003 % demands a fairly complicated mechanism to implement if we want to refer to the page number as we
3004 % do have to detect whether we really have a page number on the page. For sake of simplicity of
3005 % processing we assume that any time there is a non-empty text for the head or the foot there also
3006 % is a page number printed in either the head or the foot.
3007 % \begin{macrocode}
3008 %<*fancyheadings>
3009 \def\hyper@fancy@oddhead{\@fancyhead\@lodd\@olhead\@ochead\@orhead\@rodd}
3010 \def\hyper@fancy@oddfoot{\@fancyfoot\@lodd\@olfoot\@ocfoot\@orfoot\@rodd}
3011 \def\hyper@fancy@evenhead{\@fancyhead\@rodd\@elhead\@echead\@erhead\@lodd}
3012 \def\hyper@fancy@evenfoot{\@fancyfoot\@rodd\@elfoot\@ecfoot\@erfoot\@lodd}
3013 \def\hyper@fancy@empty{{\hyper@empty\hyper@empty}}
3014 \def\hyper@iffancyplain@empty#1#2#3#4#5\hyper@iffancyplain@empty{%
3015 \ifx#4\hyper@fancy@empty%
3016 \ifx#1\fancyplain%
3017 \if@fancyplain%
3018 \ifx\\#2\\1\else0\fi%
3019 \else%
3020 \ifx\\#3\\1\else0\fi%
3021 \fi%
3022 \else%
3023 0%
3024 \fi%
3025 \else%
3026 0%
3027 \fi%
3028 }
3029 \def\hyper@iffancy@empty#1{%
3030 \ifnum\ifx#1\@empty1\else0\fi%
3031 \ifx#1\hyper@empty1\else0\fi%
3032 \expandafter%
3033 \hyper@iffancyplain@empty%
3034 #1\hyper@fancy@empty%
3035 \hyper@fancy@empty\hyper@fancy@empty%
3036 \hyper@fancy@empty\hyper@fancy@empty%
3037 \hyper@iffancyplain@empty%
3038 >0 0\else1\fi%
3039 }
3040 \def\hyper@modifyheadfoot@pagenumber{%
3041 \let\hyper@thehead\@thehead%
3042 \ifx\hyper@thehead\hyper@oddhead\let\hyper@thehead\@oddhead\fi%
3043 \ifx\hyper@thehead\hyper@evenhead\let\hyper@thehead\@evenhead\fi%
3044 \let\hyper@thefoot\@thefoot%
3045 \ifx\hyper@thefoot\hyper@oddfoot\let\hyper@thefoot\@oddfoot\fi%
3046 \ifx\hyper@thefoot\hyper@evenfoot\let\hyper@thefoot\@evenfoot\fi%
3047 \def\@thehead{%
3048 \ifnum\ifnum\ifx\hyper@thehead\@empty1\else0\fi%
3049 \ifx\hyper@thehead\hyper@empty1\else0\fi%
3050 \ifx\hyper@thehead\relax1\else0\fi%
3051 >0 0\else1\fi%
3052 \ifnum\ifx\hyper@thefoot\@empty1\else0\fi%
3053 \ifx\hyper@thefoot\hyper@empty1\else0\fi%
3054 \ifx\hyper@thefoot\relax1\else0\fi%
3055 >0 0\else1\fi%
3056 >0\relax%
3057 \ifnum\ifnum\ifx\hyper@thehead\hyper@fancy@oddhead1\else0\fi%
3058 \ifx\hyper@thehead\hyper@fancy@evenhead1\else0\fi%
3059 >0 0\else1\fi%
3060 \ifnum\ifx\hyper@thefoot\hyper@fancy@oddfoot1\else0\fi%
3061 \ifx\hyper@thefoot\hyper@fancy@evenfoot1\else0\fi%
3062 >0 0\else1\fi%
3063 >0\relax%
3064 \else%
3065 \ifnum\ifnum\hyper@iffancy@empty\@olhead%
3066 \hyper@iffancy@empty\@ochead%
3067 \hyper@iffancy@empty\@orhead%
3068 >0 1\else0\fi%
3069 \ifnum\hyper@iffancy@empty\@olfoot%
3070 \hyper@iffancy@empty\@ocfoot%
3071 \hyper@iffancy@empty\@orfoot%
3072 >0 1\else0\fi%
3073 >0\relax%
3074 \else%
3075 \blindhyperanchor{page.\thepage}%
3076 \fi%
3077 \fi%
3078 \else%
3079 \blindhyperanchor{page.\thepage}%
3080 \fi%
3081 \let\hyper@thepage\thepage%
3082 \let\thepage\hyper@anchorpage%
3083 \ifx\hyper@thehead\@empty%
3084 \hfil%
3085 \else\ifx\hyper@thehead\hyper@empty%
3086 \hfil%
3087 \else%
3088 \hyper@thehead%
3089 \fi\fi%
3090 }%
3091 \def\@thefoot{%
3092 \let\hyper@thepage\thepage%
3093 \let\thepage\hyper@anchorpage%
3094 \ifx\hyper@thefoot\@empty%
3095 \hfil%
3096 \else\ifx\hyper@thefoot\hyper@empty%
3097 \hfil%
3098 \else%
3099 \hyper@thefoot%
3100 \fi\fi%
3101 }%
3102 }
3103 \let\hyper@modifyheadfoot\hyper@modifyheadfoot@pagenumber
3104 %</fancyheadings>
3105 % \end{macrocode}
3106 % \subsection{Long Tables}
3107 % The package |longtable| uses a definition of |\caption| for it's own.
3108 % Thus we have to modify this to reflect the hypertext needs.
3109 % \begin{macrocode}
3110 %<*longtable>
3111 \let\hyper@LT@array\LT@array
3112 \def\LT@array{%
3113 \refstepcounter{table}\ignore@next@refstepcounter%
3114 \def\@currenthyper{\the\hypercount}%
3115 \hyper@LT@array%
3116 }
3117 \def\LT@c@ption#1[#2]#3{%
3118 \LT@makecaption#1\fnum@table{#3}%
3119 \def\@tempa{#2}\ifx\@tempa\@empty\else
3120 {\let\\\space%
3121 \edef\@currenthyper{\the\hypercount}%
3122 \addcontentsline%
3123 {lot}%
3124 {table}%
3125 {\protect\numberline{\thetable}{\hyperreference{\@currenthyper}{#2}}}%
3126 }%
3127 \fi}
3128 \def\LT@makecaption#1#2#3{%
3129 \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
3130 \hyper@setcurrent%
3131 \hyper@settype{caption}%
3132 \sbox\@tempboxa{\hyperanchor{\@currenthyper}{#1{#2}}: #3}%
3133 \ifdim\wd\@tempboxa>\hsize
3134 \hyperanchor{\@currenthyper}{#1{#2}}: #3%
3135 \else
3136 \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
3137 \fi
3138 \endgraf\vskip\baselineskip}%
3139 \hss}}%
3140 }
3141 %</longtable>
3142 % \end{macrocode}
3143 %
3144 % \subsection{Right Column Footnotes in Double Column Documents}
3145 % |ftnright.sty| redefines the macro |\@makefntext|. Thus we have to
3146 % modify it's definition when needed.
3147 % \begin{macrocode}
3148 %<*ftnright>
3149 \long\def\@makefntext#1{%
3150 \hyper@currentfnmark%
3151 \bgroup%
3152 \edef\@currenthyper{\hyper@current@fnmark}%
3153 \parindent 1em%
3154 \noindent\hbox to 2em{}%
3155 \llap{${\hyperanchor{\hyper@current@fnmark}{\@thefnmark}}.\;\;$}#1%
3156 \egroup%
3157 }
3158 %</ftnright>
3159 % \end{macrocode}
3160 %
3161 % \subsection{The {\tt natbib}-Package}
3162 % Unfortunately, the bibliography stuff is changed by the |natbib|-package. So we have to provide
3163 % a special macrocode fragment for it which is complicated by the fact, that the package scans
3164 % parts of the |\bibitem| parameters from the |*.aux|-file.\par
3165 % \noindent Let's start with adding an anchor to the bibliographic entries.
3166 % \begin{macrocode}
3167 %<*natbib>
3168 \def\@lbibitem[#1]#2{%
3169 \hyper@setcurrent%
3170 \hyper@settype{citation}%
3171 \@ifundefined{b@#2\@extra@b@citeb}{\def\NAT@num{}}{\NAT@parse{#2}}%
3172 \item[\hfil\hyperanchor{\@currenthyper}{\@biblabel{\NAT@num}}]%
3173 \NAT@ifcmd#1()()\@nil{#2}%
3174 }
3175 % \end{macrocode}
3176 % To be able to associate the correct hyperlinks from citations to the respectively
3177 % bibliographic entries, we have to save the hyper-addresses into the |.aux|-file
3178 % and provide a macro to read them. Note, that we cannot use the same technique as
3179 % in standard \LaTeXe\ as the |natbib|-package scans parts of the arguments of
3180 % |\bibitem| and we have to ensure, that we do not introduce conflicts by surrounding
3181 % the entries with a hyperlink. To avoid that we store the hyperlink in another macro.
3182 % \begin{macrocode}
3183 \renewcommand\NAT@wrout[5]{%
3184 \if@filesw%
3185 {\let\protect\noexpand\let~\relax%
3186 \immediate%
3187 \write\@auxout%
3188 {\string\bibcite{#5}{{#1}{#2}{{#3}}{{#4}}}{\@currenthyper}}%
3189 }%
3190 \fi%
3191 \ignorespaces%
3192 }
3193 \renewcommand\bibcite[3]{%
3194 \@ifundefined{b@#1\@extra@binfo}\relax
3195 {\NAT@citemultiple%
3196 \PackageWarningNoLine{natbib}{Citation `#1' multiply defined}%
3197 }%
3198 \global\@namedef{b@#1\@extra@binfo}{#2}%
3199 \global\@namedef{hyper@b@#1\@extra@binfo}{#3}%
3200 }
3201 \AtEndDocument{\NAT@swatrue\renewcommand\bibcite[3]{\NAT@testdef{#1}{#2}}}%
3202 % \end{macrocode}
3203 % Now comes the crucial part. We have to invoke the hyperlinks at appropriate points in the
3204 % citation macros. Fortunately |natbib| supports |hyperref| by adding macros at appropriate places
3205 % that can be redefined for introducing the links.
3206 % \begin{macrocode}
3207 \def\hyper@natlinkstart#1#2\hyper@natlinkend{%
3208 \hyperreference{\csname hyper@b@#1\@extra@b@citeb\endcsname}{#2}%
3209 }
3210 \def\hyper@natlinkend{\relax}
3211 % \end{macrocode}
3212 % But we do not like their solution for citations with author name and year. We can do better
3213 % by not including the separators into the links.
3214 % \begin{macrocode}
3215 \def\NAT@citex%
3216 [#1][#2]#3{\let\@citea\@empty%
3217 \@cite{\let\NAT@nm\@empty\let\NAT@year\@empty%
3218 \@for\@citeb:=#3\do%
3219 {\edef\@citeb{\expandafter\@firstofone\@citeb}%
3220 \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi%
3221 \@ifundefined{b@\@citeb\@extra@b@citeb}{\@citea%
3222 {\reset@font\bfseries ?}\NAT@citeundefined%
3223 \PackageWarning{natbib}%
3224 {Citation `\@citeb' on page \thepage \space undefined}}%
3225 {\let\NAT@last@nm=\NAT@nm\let\NAT@last@yr=\NAT@year%
3226 \NAT@parse{\@citeb}\ifNAT@full\let\NAT@nm\NAT@all@names\else%
3227 \let\NAT@nm\NAT@name\fi%
3228 \ifNAT@swa%
3229 \ifx\NAT@last@nm\NAT@nm\NAT@yrsep%
3230 \ifx\NAT@last@yr\NAT@year%
3231 \hyper@natlinkstart{\@citeb}{\NAT@exlab}\hyper@natlinkend%
3232 \else%
3233 \unskip\ %
3234 \hyper@natlinkstart{\@citeb}{\NAT@date}\hyper@natlinkend%
3235 \fi%
3236 \else\@citea%
3237 \hyper@natlinkstart{\@citeb}{{\NAT@nm}}\hyper@natlinkend%
3238 \NAT@aysep\ %
3239 \hyper@natlinkstart{\@citeb}{\NAT@date}\hyper@natlinkend%
3240 \fi%
3241 \def\@citea{\NAT@sep\ }%
3242 \else%
3243 \ifx\NAT@last@nm\NAT@nm\NAT@yrsep%
3244 \ifx\NAT@last@yr\NAT@year%
3245 \hyper@natlinkstart{\@citeb}{\NAT@exlab}\hyper@natlinkend%
3246 \else%
3247 \unskip\ %
3248 \hyper@natlinkstart{\@citeb}{\NAT@date}\hyper@natlinkend%
3249 \fi%
3250 \else\@citea%
3251 \hyper@natlinkstart{\@citeb}{{\NAT@nm}}\hyper@natlinkend%
3252 \ \NAT@open%
3253 \hyper@natlinkstart{\@citeb}{\NAT@date}\hyper@natlinkend%
3254 \fi%
3255 \def\@citea{\NAT@close\NAT@sep\ }%
3256 \fi}}\ifNAT@swa\else\NAT@close\fi}{#1}{#2}}
3257 % \end{macrocode}
3258 % Damned, |natbib| accesses this macros through |\@citex| using a |\let|-assignment.
3259 % We have to recall this assignment to define it. Fortunately, the package provides
3260 % a macro to achieve this.
3261 % \begin{macrocode}
3262 \NAT@set@cites
3263 % \end{macrocode}
3264 % Bad news, |natbib| does not provide dummies for inserting hypertext-markups into ranges.
3265 % Thus we have to patch the sorting macros of the package.
3266 % \begin{macrocode}
3267 \ifnum\NAT@sort=1
3268 \begingroup \catcode`\_=8
3269 \gdef\@make@cite@list{%
3270 \edef\@citeb{\expandafter\@firstofone\@citeb}%
3271 \@ifundefined{b@\@citeb\@extra@b@citeb}{%
3272 \@citea{\reset@font\bfseries?}%
3273 \def\@citea{\NAT@sep\penalty\@m\NAT@space}%
3274 \NAT@citeundefined\PackageWarning{natcite}%
3275 {Citation `\@citeb' on page \thepage\space undefined}}%
3276 {\NAT@parse{\@citeb}%
3277 \ifcat_\ifnum\z@<0\NAT@num_\else A\fi%
3278 \@tempcnta\NAT@num\relax%
3279 \ifnum\@tempcnta>\@tempcntb%
3280 \edef\@cite@list{\@cite@list \@celt{{\NAT@num}{\@citeb}}}%
3281 \@tempcntb\@tempcnta%
3282 \else%
3283 \edef\@cite@list{\expandafter\@sort@celt\@cite@list\@gobble @}%
3284 \fi%
3285 \else%
3286 \@citea\hyper@natlinkstart{\@citeb}{\NAT@num}\hyper@natlinkend%
3287 \def\@citea{\NAT@sep\penalty\@m\NAT@space}%
3288 \fi}}
3289 \endgroup
3290 \def\@sort@celt#1#2{%
3291 \ifx \@celt #1%
3292 \hyper@sort@celt#2%
3293 \fi%
3294 }%
3295 \def\hyper@sort@celt#1#2{%
3296 \ifnum #1<\@tempcnta%
3297 \@celt{{#1}{#2}}%
3298 \expandafter\expandafter\expandafter\@sort@celt%
3299 \else%
3300 \@celt{{\NAT@num}{\@citeb}}\@celt{{#1}{#2}}%
3301 \fi%
3302 }
3303 \def\@compress@cite#1{\hyper@compress@cite#1}
3304 \def\hyper@compress@cite#1#2{%
3305 \advance\@tempcnta\@ne%
3306 \ifnum #1=\@tempcnta%
3307 \ifx\@h@ld\relax%
3308 \edef\@h@ld{%
3309 \@citea%
3310 \noexpand\hyper@natlinkstart{#2}{#1}\noexpand\hyper@natlinkend%
3311 }%
3312 \else%
3313 \def\@h@ld{%
3314 \hbox{--}%
3315 \hyper@natlinkstart{#2}{#1}\hyper@natlinkend%
3316 }%
3317 \fi%
3318 \else%
3319 \@h@ld\@citea%
3320 \hyper@natlinkstart{#2}{#1}\hyper@natlinkend%
3321 \let\@h@ld\relax%
3322 \fi%
3323 \@tempcnta#1\def\@citea{\NAT@sep\penalty\@m\NAT@space}%
3324 }
3325 \fi
3326 %</natbib>
3327 % \end{macrocode}
3328 %
3329 % \subsection{The Subequationarray Package}
3330 % First of all we have to set some anchors in the |subeqnarray|-environment
3331 % we can refer to.
3332 % \begin{macrocode}
3333 %<*subeqnarray>
3334 \def\hyper@subeqnnum@leqno{%
3335 \hbox to .01\p@{}%
3336 \rlap{%
3337 \reset@font\rmfamily%
3338 \hskip-\displaywidth\hyperanchor{\@currenthyper}{(\thesubequation)}%
3339 }%
3340 }
3341 \def\hyper@subeqnnum@reqno{%
3342 {\reset@font\rmfamily \hyperanchor{\@currenthyper}{(\thesubequation)}}%
3343 }
3344 \let\@subeqnnum\hyper@subeqnnum@reqno
3345 \@ifpackagewith{subeqnarray}{leqno}
3346 {\let\@subeqnnum\hyper@subeqnnum@leqno}
3347 {\let\@subeqnnum\hyper@subeqnnum@reqno}
3348 \let\hyper@subeqnarray\subeqnarray
3349 \def\subeqnarray{%
3350 \hyper@setcurrent%
3351 \hyper@settype{equation}%
3352 \let\label@currenthyper\@currenthyper%
3353 \let\label@currenthypertype\@currenthypertype%
3354 \def\label##1{%
3355 \let\@currenthyper\label@currenthyper%
3356 \let\@currenthypertype\label@currenthypertype%
3357 \hyperlabel{##1}%
3358 \blindhyperanchor{\label@currenthyper}%
3359 \def\@currenthyper{\the\hypercount}%
3360 }%
3361 \hyper@setcurrent%
3362 \hyper@settype{equation}%
3363 \def\@currenthyper{\the\hypercount}%
3364 \hyper@subeqnarray%
3365 }
3366 % \end{macrocode}
3367 % The subeqnarray package defines a new label command called |\slabel|.
3368 % Thus, we have to redefine it in order to ensure that the hyper reference is
3369 % added to the label when written into the |.aux|-file.
3370 % \begin{macrocode}
3371 \def\slabel#1{%
3372 \@bsphack
3373 \if@filesw
3374 {\let\thepage\relax
3375 \def\protect{\noexpand\noexpand\noexpand}%
3376 \edef\@tempa{\write\@auxout{\string
3377 \newlabel{#1}{{\@currenthypertype}{\@currenthyper}{\thesubequation}{\thepage}}}}%
3378 \expandafter}\@tempa
3379 \if@nobreak \ifvmode\nobreak\fi\fi
3380 \fi\@esphack}
3381 %</subeqnarray>
3382 % \end{macrocode}
3383 % \subsection{The Theorem Package}
3384 % Analoguous to the theorem environment of \LaTeXe{} we have to modify
3385 % the different theorem styles of the theorem package.
3386 % \begin{macrocode}
3387 %<*theorem>
3388 %plain
3389 \gdef\th@plain{\normalfont\itshape%
3390 \def\@begintheorem##1##2{%
3391 \item[\hskip\labelsep%
3392 \hyperanchor{\@currenthyper}{\theorem@headerfont ##1\ ##2}%
3393 ]%
3394 }%
3395 \def\@opargbegintheorem##1##2##3{%
3396 \item[\hskip\labelsep%
3397 \hyperanchor%
3398 {\@currenthyper}%
3399 {\theorem@headerfont ##1\ ##2}\ (##3)%
3400 ]%
3401 }%
3402 }
3403 %break
3404 \gdef\th@break{\normalfont\slshape%
3405 \def\@begintheorem##1##2{%
3406 \item[\rlap{\vbox{\hbox{\hskip \labelsep%
3407 \hyperanchor{\@currenthyper}{\theorem@headerfont ##1\ ##2}%
3408 }\hbox{\strut}}}%
3409 ]%
3410 }%
3411 \def\@opargbegintheorem##1##2##3{%
3412 \item[\rlap{\vbox{\hbox{\hskip \labelsep%
3413 \hyperanchor%
3414 {\@currenthyper}%
3415 {\theorem@headerfont ##1\ ##2}\ (##3)%
3416 }\hbox{\strut}}}%
3417 ]%
3418 }%
3419 }
3420 %marginbreak
3421 \gdef\th@marginbreak{\normalfont\slshape%
3422 \def\@begintheorem##1##2{%
3423 \item[\rlap{\vbox{\theorem@headerfont%
3424 \hbox{\llap{##2}\hskip\labelsep%
3425 \hyperanchor{\@currenthyper}{##1}%
3426 }%
3427 \hbox{\strut}}}%
3428 ]%
3429 }%
3430 \def\@opargbegintheorem##1##2##3{%
3431 \item[\rlap{\vbox{\theorem@headerfont%
3432 \hbox{\llap{##2}\hskip\labelsep%
3433 \hyperanchor{\@currenthyper}{##1}\ (##3)
3434 }%
3435 \hbox{\strut}}}%
3436 ]%
3437 }%
3438 }
3439 %changebreak
3440 \gdef\th@changebreak{\normalfont\slshape%
3441 \def\@begintheorem##1##2{%
3442 \item[\rlap{\vbox{\hbox{\hskip\labelsep%
3443 \hyperanchor{\@currenthyper}{\theorem@headerfont ##2\ ##1}%
3444 }\hbox{\strut}}}%
3445 ]%
3446 }%
3447 \def\@opargbegintheorem##1##2##3{%
3448 \item[\rlap{\vbox{\hbox{\hskip\labelsep%
3449 \hyperanchor%
3450 {\@currenthyper}%
3451 {\theorem@headerfont ##2\ ##1}\ (##3)%
3452 }\hbox{\strut}}}%
3453 ]%
3454 }%
3455 }
3456 %change
3457 \gdef\th@change{\normalfont\slshape%
3458 \def\@begintheorem##1##2{%
3459 \item[\hskip\labelsep%
3460 \hyperanchor{\@currenthyper}{\theorem@headerfont ##2\ ##1}%
3461 ]%
3462 }%
3463 \def\@opargbegintheorem##1##2##3{%
3464 \item[\hskip\labelsep%
3465 \hyperanchor%
3466 {\@currenthyper}%
3467 {\theorem@headerfont ##2\ ##1}\ (##3)%
3468 ]%
3469 }%
3470 }
3471 %margin
3472 \gdef\th@margin{\normalfont\slshape%
3473 \def\@begintheorem##1##2{%
3474 \item[\theorem@headerfont \llap{##2}\hskip\labelsep%
3475 \hyperanchor{\@currenthyper}{##1}%
3476 ]%
3477 }%
3478 \def\@opargbegintheorem##1##2##3{%
3479 \item[\theorem@headerfont \llap{##2}\hskip\labelsep%
3480 \hyperanchor{\@currenthyper}{##1}\ (##3)%
3481 ]%
3482 }%
3483 }
3484 %</theorem>
3485 % \end{macrocode}
3486 %
3487 % \subsection{The CWEB Document Class}
3488 % For \CWEB\ there exists a \LaTeXe\ document class that defined a reference
3489 % mechanism for literate programming using latex and \CWEB.\par
3490 % \noindent
3491 % First of all it is based on another document class. Thus we have to
3492 % load the modifications for this class, too.
3493 % \begin{macrocode}
3494 %<*cweb>
3495 \InputIfFileExists{\CwebBaseClass.hyp}{}%
3496 {\PackageError{hyper}{\CwebBaseClass.hyp not found.\MessageBreak
3497 Please choose another base document class for cweb\MessageBreak
3498 or redefine \string\CwebBaseClass to point to a\MessageBreak
3499 modification document class for the base document class
3500 }{}%
3501 }%
3502 % \end{macrocode}
3503 % As we use pattern--like definitions for some stuff following below
3504 % an additiional package has to be loaded.
3505 % \begin{macrocode}
3506 \RequirePackage{defpattern}
3507 % \end{macrocode}
3508 % |cweb.cls| uses the underscore character as a letter for some macro names
3509 % we have to redefine. Thus we set the category code of |_| correspondingley.
3510 % \begin{macrocode}
3511 \chardef\hyper@CatUsCode=\catcode`\_
3512 \catcode`\_=\CatLetter
3513 % \end{macrocode}
3514 % Why the hell must the class use a redefinition of |\refstepcounter| for
3515 % its own? This means that we have to redefine it another time.
3516 % \begin{macrocode}
3517 \let\hyper@cweb@refstepcounter=\hyper@refstepcounter
3518 \def\refstepcounter#1{%
3519 \def\@tempa{#1}%
3520 \ifx \@tempa\cweb@string@chunk%
3521 \protected@edef\@currenthyper{cweb.\cweb@refchunk}%
3522 \hyper@settype{chunk}%
3523 \protected@edef\@currentlabel{\cweb@refchunk}%
3524 \else%
3525 \hyper@setcurrent%
3526 \hyper@settype{chunk}%
3527 \hyper@cweb@refstepcounter{#1}%
3528 \fi%
3529 }
3530 % \end{macrocode}
3531 % Naturally, we want to use the chunk numbers as links to the corresponding
3532 % chunks. This means that we have to redefine |\CwebRefName|.
3533 % Don't ask why it's that complicated.
3534 % \begin{macrocode}
3535 \let\hyper@CwebRefName\CwebRefName
3536 \def\CwebRefName#1:#2\X{%
3537 \ifmmode \gdef\cwbb@toggle_text{\null$\null}%
3538 \else \let\cwbb@toggle_text\relax%
3539 \fi%
3540 \cwbb@toggle_text%
3541 \expandafter\ifx\csname hyper@cweb.#1\endcsname\relax%
3542 \expandafter\ifx\csname hyper@new@cweb.#1\endcsname\relax%
3543 \PackageWarning{hyper}%
3544 {Hyper reference for `cweb.#1' on page \hyper@thepage\space undefined}%
3545 \hyper@change1\relax%
3546 \hyper@undef@color{%
3547 $\langle\,${\cwbb@tex \cwbb@check_dot{#2}\CwebRefNumber{#1}}$\,\rangle$%
3548 }%
3549 \else%
3550 \hyperreference{cweb.#1}{%
3551 $\langle\,${\cwbb@tex \cwbb@check_dot{#2}\CwebRefNumber{#1}}$\,\rangle$%
3552 }%
3553 \fi%
3554 \else%
3555 \hyperreference{cweb.#1}{%
3556 $\langle\,${\cwbb@tex \cwbb@check_dot{#2}\CwebRefNumber{#1}}$\,\rangle$%
3557 }%
3558 \fi%
3559 \cwbb@toggle_text%
3560 }
3561 % \end{macrocode}
3562 % However, there has to exist anchors for these links to the chunks.\par
3563 % \noindent Well, for a hierarchical structure the chunk numbers are
3564 % written into the
3565 % margin whereas for a flat structure they are written at the beginning of
3566 % the chunk using the chunk begin macro |\M|. Therefore we need the following
3567 % modifications of the original code.
3568 % \begin{macrocode}
3569 \ifcase \cweb@structure
3570 %% hierarchic
3571 \let\hyper@cwbb@marginal_chunkno\cwbb@marginal_chunkno%
3572 \def\cwbb@marginal_chunkno{%
3573 \let\hyper@thechunk\thechunk%
3574 \def\thechunk{\hyperanchor{cweb.\arabic{chunk}}{\hyper@thechunk}}%
3575 \hyper@cwbb@marginal_chunkno%
3576 \let\thechunk\hyper@thechunk%
3577 }
3578 \or
3579 %% flat
3580 \let\hyper@M\M%
3581 \def\M#1{%
3582 \let\hyper@thechunk\thechunk%
3583 \def\thechunk{\hyperanchor{cweb.\arabic{chunk}}{\hyper@thechunk}}%
3584 \hyper@M{#1}%
3585 \let\thechunk\hyper@thechunk%
3586 }
3587 \fi
3588 % \end{macrocode}
3589 % Unfortunately, this is not sufficient. The class uses an additional
3590 % cross referencing mechanism.\par
3591 % \noindent Damned, it uses seperators for a list of cross references that
3592 % cannot be used for the pattern-like definition we need to seperate the
3593 % different references. Thus we have to redefinie the seperators and reinvoke
3594 % them after splitting.
3595 % \begin{macrocode}
3596 \let\hyper@CwebCREt\CwebCREt
3597 \let\hyper@CwebCRsEt\CwebCRsEt
3598 \def\CwebCREt{!}
3599 \def\CwebCRsEt{?}
3600 %
3601 \defpattern\hyper@split@CwebCrossRef[#2]{\hyperreference{cweb.#2}{#2}}
3602 \defpattern\hyper@split@CwebCrossRef[ #2]{\hyper@split@CwebCrossRef[#2]}
3603 \defpattern\hyper@split@CwebCrossRef[#2,#3]{%
3604 \hyper@split@CwebCrossRef[#2], %
3605 \hyper@split@CwebCrossRef[#3]%
3606 }
3607 \defpattern\hyper@split@CwebCrossRef[#2!#3]{%
3608 \hyper@split@CwebCrossRef[#2]\hyper@CwebCREt%
3609 \hyper@split@CwebCrossRef[#3]%
3610 }
3611 \defpattern\hyper@split@CwebCrossRef[#2?#3]{%
3612 \hyper@split@CwebCrossRef[#2]\hyper@CwebCRsEt%
3613 \hyper@split@CwebCrossRef[#3]%
3614 }
3615 \def\hypersplit@CwebCrossRef[#1]{%
3616 \edef\hyper@tmp{#1}%
3617 \expandafter\hyper@split@CwebCrossRef\expandafter[\hyper@tmp]%
3618 }
3619 %
3620 \let\hyper@CwebCrossRef\CwebCrossRef
3621 \def\CwebCrossRef#1#2.{%
3622 \hyper@CwebCrossRef{#1}{\hypersplit@CwebCrossRef[#2]}.%
3623 }
3624 % \end{macrocode}
3625 % As you might have expected, this even does not resolve all problems.
3626 % The list of references may contain multiple entries pointing to
3627 % different chunks containing code for the same literate.
3628 % Therefore we have to redefine the literates to allow links to different
3629 % occurrences.
3630 % \begin{macrocode}
3631 \let\hyper@CwebRefList\CwebRefList
3632 \def\hyper@CwebRefName@RefList#1:#2\X{%
3633 \hyper@CwebRefName\hypersplit@CwebCrossRef[#1]:#2\X%
3634 }
3635 \def\CwebRefList{%
3636 \let\hyper@CwebReadPPList\CwebReadPPList%
3637 \let\CwebReadPPList\relax%
3638 \hyper@CwebRefList%
3639 \let\X\hyper@CwebRefName@RefList
3640 \def\CwebCrossRef##1##2.{%
3641 \quad {\reset@font\footnotesize ##1~\hypersplit@CwebCrossRef[##2].}%
3642 }%
3643 \let\CwebReadPPList\hyper@CwebReadPPList%
3644 \CwebReadPPList%
3645 }
3646 % \end{macrocode}
3647 % Last but not least we have to handle the index referencing from variables
3648 % to the chunks they occur in. The modifications below are just a little bit
3649 % complicated as we have to split the list of occurrences to several parts
3650 % each of which has to be handled sepeartely without being allowed to use
3651 % the original list that may contain the character |]| that cannot be used
3652 % in pattern--like definitions we need here.
3653 % \begin{macrocode}
3654 \let\hyper@CwebIndexEntry\CwebIndexEntry
3655 \let\hyper@CwebIndexDeclared\CwebIndexDeclared
3656 \def\CwebIndexDeclared#1]{|#1|}
3657 \defpattern\hyper@cwebindex[#2]{\hyperreference{cweb.#2}{#2}}
3658 \defpattern\hyper@cwebindex[|#2|]{%
3659 \hyperreference{cweb.#2}{\hyper@CwebIndexDeclared#2]}%
3660 }
3661 \defpattern\hyper@cwebindex[#2, #3]{%
3662 \hyper@cwebindex[#2], \hyper@cwebindex[#3]%
3663 }
3664 \def\hyper@cweb@index#1{%
3665 \edef\hyper@tmp{#1}%
3666 \expandafter\hyper@cwebindex\expandafter[\hyper@tmp]%
3667 }
3668 \def\CwebIndexEntry#1, #2.{%
3669 \hyper@CwebIndexEntry#1, \hyper@cweb@index{#2}.%
3670 }
3671 % \end{macrocode}
3672 % Now it just remains to reset the category code for |_| to the one we had
3673 % before the modifications started.
3674 % \begin{macrocode}
3675 \catcode`\_=\hyper@CatUsCode
3676 %</cweb>
3677 % \end{macrocode}
3678 %
3679 % \clearpage
3680 %
3681 % \section{Needed Packages (Part of this Distribution)}
3682 %
3683 % \subsection{Pattern--Like Definition of Macros}
3684 % For the index and glossary definitions we have used the package |defpattern|
3685 % that is already part of the fp--package on |CTAN:macros/latex/contrib/other/fp|.
3686 % This is a very usefull macro allowing the definition of other macros by
3687 % pattern matching rules.\par
3688 % \noindent The package has been adapted from Alan Jeffrey's |\howto| that can be
3689 % found in ``\TeX and TUG NEWS 2(2)''.
3690 % \begin{macrocode}
3691 %<*defpattern>
3692 \ProvidesPackage{defpattern}
3693 \message{%
3694 `\string\defpattern-macro %
3695 (adapted from \string\howto\space%
3696 (Alan Jeffrey in TeX and TUG NEWS 2(2))%
3697 )%
3698 '%
3699 }
3700 \def\xcs#1#2{\expandafter#1\csname#2\endcsname}
3701 \newcount\actioncount
3702 \def\defpattern#1[#2]#3{%
3703 \xcs\ifx{\expandafter\gobble\string#1}\relax
3704 \def#1{\erroraction#1}\fi
3705 \advance\actioncount by 1\relax
3706 \expandafter\defaction\expandafter{#1}{#3}{#2}%
3707 \def\temp##1##2##3##4##5##6##7##8##9{\def\temp{[#2]}}%
3708 \temp\empty\empty\empty\empty\empty\empty\empty\empty\empty
3709 \edef#1{\noexpand\doaction\xcs\noexpand
3710 {action-\the\actioncount}\temp}}
3711 \def\defaction#1#2#3{%
3712 \xcs\def{action-\the\actioncount}##1[#3]{\applyto{#1}{#2}}}
3713 \def\gobble#1{}
3714 \def\applyto#1#2#3{#3{#1}{#2}}
3715 \def\doaction#1[#2][#3]{#1[#3]\success[#2]\failure[#3]}
3716 \def\success#1#2[#3]\failure[#4]{#2}
3717 \def\failure#1#2{#1}
3718 \def\erroraction#1[#2]{%
3719 \PackageError{defpattern}{I don't know how to \string#1[#2]}{}}
3720 %</defpattern>
3721 % \end{macrocode}
3722 %
3723 % \clearpage
3724 %
3725 % \section{Extensions}
3726 % Currently the following extensions exist for this package.
3727 % \begin{itemize}
3728 % \item Back references from the bibliography to the citations\newline
3729 % (described in |backcite.dtx|)
3730 % \end{itemize}
3731 %
3732 % \Finale