blob: 874cda185059ca5cc331b699a49c8d7173958352 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% This file is written by Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov> and %
% is in the public domain for what it is worth. It inserts \specials that %
% are interpreted by (a) the xhdvi hypertex dvi previewer, (b) nextstep %
% HyperTeXview.app dvi previewer, and (c) the dvipdf driver %
% For more info, see http://xxx.lanl.gov/hypertex/ %
% or ftp://xxx.lanl.gov/pub/hypertex/index.html %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Only \hyperdef, \hyperref , \href , and \hname are user callable. %
% Usage: \hyperdef\TeXcs{category}{name}{text} %
% Usage: \href{url}{text} %
% Usage: \hyperref{filename}{category}{name}{text} %
% or \hyperref\TeXcs{text} %
% where \TeXcs has been defined by a hyperdef. %
% %
% Note: The token following \hyperref is expanded completely first.%
% Really perverse forms like %
% \csname perverse\endcsname %
% will give an error %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The following might be useful to other macros interfacing in. %
% Usage: \hyper@nchor{name="#myname" href="#refer"}{text} %
% Usage: \hyperlink{target_name}{text} %
% Usage: \hypertarget{myname}{text} %
% In cases where there is a possibility of premature expansion use %
% \hyper@\hyperpr@ref instead of \hyperref %
% and \hyper@\hyperpr@def instead of \hyperdef %
% These macros increase enormously in size when expanded, but the expanded%
% token sequence always ends in \hyperpr@ref and \hyperpr@def respectively%
% Macro writers might want to make use of the macro \hyperv@rsion %
% which is undefined in version 0 and is the version number otherwise %
% \hyper@nique is exactly like \hyperdef except no special are written %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Save the current catcode of @ and redefine @ to be a letter
%
\expandafter\edef\csname hypers@fe\endcsname{\catcode
`\noexpand @=\the\catcode`\@}%
\catcode`\@=11
%
% Check if the file is already included
%
% hack to allow \allowoncemore
\ifx\hyper@utoprocess\hyper@ndefined
\else
\expandafter\hyper@utoprocess\fi
\ifx\hyperd@ne\hyper@ndefined
\global\let\hyperd@ne=\relax
\else
\hypers@fe
\errhelp{hyperbasics.tex needs to be included only once outside
of any {...} or \begingroup...\endgroup. You have tried to
include it more than once. If the previous include was indeed
outside any groupings, continue and all will be well.}%
\errmessage{Input this file only once!}%
\expandafter\endinput\fi
%
% Version number
%
\def\hyperv@rsion{9}%
%
% Check and input a previous .hrf file if it exists
%
\newread\hyperf@le
\def\hyperf@lename{\jobname.hrf}%
\immediate\openin\hyperf@le\hyperf@lename\relax
\ifeof\hyperf@le\relax
\immediate\closein\hyperf@le\relax
\else
\immediate\closein\hyperf@le\relax
\input \hyperf@lename
\fi
%
% Open a new .hrf file
%
\newwrite\hyperf@le
\immediate\openout\hyperf@le\hyperf@lename
%%%%
% MAIN SECTION
%%%%
%
% define a token register
%
\newtoks\hypert@ks
%
% Define a convenient macro to hold the character #
%
\edef\hypert@mp{\catcode`\noexpand\%=\the\catcode`\%}
\catcode`\%=12
\def\hyperp@rcent{%}
\hypert@mp
\edef\hypert@mp{\catcode`\noexpand\#=\the\catcode`\#}%
\catcode`\#=12
\def\hyperh@sh{#}%
\hypert@mp
\let\hypert@mp=\relax
\let\hyper@nd=\relax
\def\hyperbl@nk{ }
\def\hyperstr@pquote#1"#2\hyper@nd{% Call \hyperstr@pquote..."\hyper@nd
#1% #1 can not contain "
\ifx\hyper@nd#2\hyper@nd% #2 cannot contain \hyper@nd and
% must end in " if non-empty
\else\hyperp@rcent22\hyperstr@pquote#2\hyper@nd\fi}%
\def\hyperstr@pblank#1 #2\hyper@nd{% Call \hyperstr@pblank... \hyper@nd
#1% #1 cannot contain a space
\ifx\hyper@nd#2\hyper@nd% #2 canot contain \hyper@nd and
% and must end in blank if nonempty
\else\hyperp@rcent20\hyperstr@pblank#2\hyper@nd\fi}
%
\long\def\hyper@nchor#1#2{\edef\hyperm@cro{html:<A #1>}%
\special\expandafter{\hyperm@cro}%
{#2}\special{html:</A>}}%
%
\def\hyper@atm@ning#1->#2\hyper@nd{#2}
\def\hyperlink{\protect\hyperlink@}
\def\hyperlink@{{\catcode`\#=12 \catcode`\%=12 \catcode`\~=12
\expandafter}\hyperlink@@}
\def\hyperlink@@#1{\protect\hyperlink@@@{#1}}
\def\hyperlink@@@#1{\edef\hypert@mp{#1}%
\edef\hypert@mp{\expandafter\hyper@atm@ning\meaning\hypert@mp
\hyper@nd}%
\edef\hypert@mp{\expandafter\hyperstr@pquote%
\hypert@mp"\hyper@nd}%
\edef\hypert@mp{\expandafter\expandafter\expandafter
\hyperstr@pblank\expandafter%
\hypert@mp\hyperbl@nk\hyper@nd}%
\hyper@nchor{href=\expandafter"\hypert@mp"}}%
%
\def\hypertarget#1{\edef\hypert@mp{#1}%
\edef\hypert@mp{\expandafter\hyper@atm@ning\meaning\hypert@mp
\hyper@nd}%
\edef\hypert@mp{\expandafter\hyperstr@pquote%
\hypert@mp"\hyper@nd}%
\edef\hypert@mp{\expandafter\expandafter\expandafter
\hyperstr@pblank\expandafter%
\hypert@mp\hyperbl@nk\hyper@nd}%
\hyper@nchor{name=\expandafter"\hypert@mp"}}%
%
\def\hyperref{\afterassignment\hyperr@f\let\hyperp@ram}
\def\hyperr@f{\ifx\hyperp@ram{\iffalse}\fi
\expandafter\expandafter\expandafter\hyperr@@
\expandafter{%
\else
\iffalse}\fi
\ifx\hyperp@ram\hyper@ndefined
\message{Undefined reference}%
\def\hyperp@r@m{{}{undefined}{}}%
\else
\edef\hyperp@r@m{\hyperp@ram}%
\fi
\expandafter\expandafter\expandafter\hyperr@@
\expandafter\hyperp@r@m
\fi}%
% refer to #1, \hyperh@sh#2.#3 or #1\hyperh@sh#2.#3
% depending on what is blank/nonblank
\def\hyperr@@#1#2#3{\ifx\hyper@ndefined#1\hyper@ndefined
\hypert@ks\expandafter{\hyperh@sh#2.#3}%
\else
\ifx\hyper@ndefined#2#3\hyper@ndefined
\hypert@ks{#1}%
\else
\def\hypert@mp{#1}%
\hypert@ks\expandafter\expandafter\expandafter
{\expandafter\hypert@mp\hyperh@sh#2.#3}%
\fi
\fi
\expandafter\hyperlink\expandafter{\the\hypert@ks}}%
%
% \def\hyperREF#1{\hyperlink{#1}}% % Disabled as per pg's suggestion
%
\def\hyperdef#1#2#3{{\escapechar=`\\\relax
\edef\hypert@mp{\hyperstr@pquote#2.#3"\hyper@nd}%
\expandafter\ifx\csname hyperd@\meaning\hypert@mp
\endcsname
\relax
\expandafter\gdef\csname hyperd@\meaning\hypert@mp
\endcsname{}%
\gdef#1{{}{\hyperstr@pquote#2"\hyper@nd}%
{\hyperstr@pquote#3"\hyper@nd}}%
\immediate\write\hyperf@le{\def\noexpand#1{{}%
{\noexpand\hyperstr@pquote#2"\noexpand\hyper@nd}%
{\noexpand\hyperstr@pquote#3"\noexpand\hyper@nd}}}%
\xdef\hypert@mp{\global\let\noexpand\hypert@mp=\relax
\noexpand\hypertarget{\hypert@mp}}%
\global\hypert@ks={\hypert@mp}%
\else
\message\expandafter{'\hypert@mp' duplicate}%
\global\let\hypert@mp=\relax
\global\hypert@ks={\hyperdef{#1}{#2}{#3@}}%
\fi}\the\hypert@ks}%
\def\hyper@nique#1#2#3#4{{\escapechar=`\\\relax
\edef\hypert@mp{\hyperstr@pquote#2.#3"\hyper@nd}%
\expandafter\ifx\csname hyperd@\meaning\hypert@mp
\endcsname
\relax
\gdef#1{{}{\hyperstr@pquote#2"\hyper@nd}%
{\hyperstr@pquote#3"\hyper@nd}}%
\global\let\hypert@mp=\relax
#4%
\else
\global\let\hypert@mp=\relax
\hyper@nique{#1}{#2}{#3@}{#4}%
\fi}}%
%%%
% protection macros
%%%
\ifx\protect\hyper@ndefined\let\protect=\relax\fi
\let\hyper@@@@=\relax
\def\hyper@@{\let\hyper@@@=\relax}%
\hyper@@
\def\hyper@{\relax\let\hyper@@@\noexpand\hyper@\noexpand}%
\def\hyperpr@ref{\hyper@@\hyperref}
\def\hyperpr@def{\hyper@@\hyperdef}
% As per pg's suggestion
\let\href\hyperlink
\let\hname\hypertarget
% Hack to allow auto-processing
\def\allowoncemore{\def\hyper@utopr@cess{\let\hyper@utoprocess=\hyper@ndefined
\hypers@fe\endinput}}%
%
% Restore the catcode of @
%
\hypers@fe
\endinput
% A line after endinput to avoid both msdos gremlins and an incomplete
% last line
|