summaryrefslogtreecommitdiff
path: root/support/hypertex/tanmoy/hyperlatex.tex
blob: d2189980d5298b387cfc9d762cae0567b40f6ce3 (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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
\input hyperbasics

\expandafter\edef\csname hypers@fe\endcsname{\catcode
                                             `\noexpand @=\the\catcode`\@}%
\catcode`\@=11
{\setbox0=\hbox{
\errhelp{lhyper needs a higher revision of hyperbasics.}
\ifx\hyperv@rsion\hyper@ndefined
  \errmessage{Need at least version 1 of hyperbasics. You have %
              version 0}%
  \egroup\egroup\expandafter\stop
\else
  \ifnum2>\hyperv@rsion
  \errmessage{Need at least version 1 of hyperbasics. You have %
              version \hyperv@rsion}%
  \egroup\egroup\expandafter\expandafter\expandafter\stop
  \fi
\fi}}

\let\hypernoname=\relax
% Change all places where \@currentlabel is being set. 
% Tempoarily, put a \hyperdef at precisely those points.
\def\refstepcounter#1{\stepcounter{#1}\let\@tempa\protect
\def\protect{\noexpand\protect\noexpand}%
\hyperdef\hypernoname{#1}{\csname the#1\endcsname}{}%
\edef\@currentlabel{\hyper@\hyperpr@ref\hypernoname%
                  {\csname p@#1\endcsname\csname the#1\endcsname}}%
\let\protect\@tempa}%

% Equations are special too
\def\equation{$$% $$ BRACE MATCHING HACK
\let\hyper@n@=\hyperdef
\let\hyperdef=\hyper@nique\refstepcounter{equation}%
\let\hyperdef=\hyper@n@\let\hyper@qn@=\theequation
\def\theequation{\hyperdef\hypernoname{equation}{\hyper@qn@}{\hyper@qn@}}%
}


\def\eqnarray{\stepcounter{equation}%
\global\@eqnswtrue\m@th
\global\@eqcnt\z@\tabskip\@centering\let\\\@eqncr
\let\hyper@qn@=\theequation
\hyper@nique\hypernoname{equation}{\hyper@qn@}{}%
\edef\@currentlabel{%
\hyper@\hyperpr@ref\hypernoname{\theequation}}%
$$%
\def\theequation{\hyperdef\hypernoname{equation}{\hyper@qn@}{\hyper@qn@}}%
\edef\@currentlabel{%
\hyper@\hyperpr@ref\noexpand\hypernoname{\noexpand\hyper@qn@}}%
\halign to\displaywidth\bgroup\@eqnsel\hskip\@centering
  $\displaystyle\tabskip\z@{##}$&\global\@eqcnt\@ne
  \hskip 2\arraycolsep \hfil${##}$\hfil
  &\global\@eqcnt\tw@ \hskip 2\arraycolsep $\displaystyle\tabskip\z@{##}$\hfil
   \tabskip\@centering&\llap{##}\tabskip\z@\cr}

% footnotes are special. We simply redefine all occurances of \@thefnmark.

\def\footnote{\@ifnextchar[{\@xfootnote}{\stepcounter{\@mpfn}%
     \hyper@nique\hypernoname{footnote}{\thempfn}{}%
     \begingroup\let\protect\noexpand
       \xdef\@thefnmark{{\hyper@\hyperpr@ref\hypernoname
                        {\thempfn}}}\endgroup
     \@footnotemark\@footnotetext}}
 
\def\@xfootnote[#1]{
   \hyper@nique\hypernoname{footnote}{\thempfn}{}%
   \begingroup \csname c@\@mpfn\endcsname #1\relax
   \let\protect\noexpand
   \xdef\@thefnmark{{\hyper@\hyperpr@ref\hypernoname
                    {\thempfn}}}\endgroup
   \@footnotemark\@footnotetext}

\def\footnotemark{\@ifnextchar[{\@xfootnotemark}{\stepcounter{footnote}%
     \hyper@nique\hypernoname{footnote}{\thefootnote}{}%
     \begingroup\let\protect\noexpand
       \xdef\@thefnmark{{\hyper@\hyperpr@ref\hypernoname
                        {\thefootnote}}}\endgroup
     \@footnotemark}}
 
\def\@xfootnotemark[#1]{\begingroup \c@footnote #1\relax
     \hyper@nique\hypernoname{footnote}{\thefootnote}{}%
   \let\protect\noexpand
   \xdef\@thefnmark{{\hyper@\hyperpr@ref\hypernoname
                    {\thefootnote}}}\endgroup \@footnotemark}
 
\def\footnotetext{\@ifnextchar [{\@xfootnotenext}%
   {\begingroup\let\protect\noexpand
     \hyper@nique\hypernoname{footnote}{\thempfn}{}%
      \xdef\@thefnmark{{\hyper@\hyperpr@ref\hypernoname
                       {\thempfn}}}\endgroup
    \@footnotetext}}
 
\def\@xfootnotenext[#1]{\begingroup \csname c@\@mpfn\endcsname #1\relax
   \let\protect\noexpand
     \hyper@nique\hypernoname{footnote}{\thempfn}{}%
   \xdef\@thefnmark{{\hyper@\hyperpr@ref\hypernoname
                    {\thempfn}}}\endgroup \@footnotetext}
 

% The footnote has to be defined when insertion being generated.
\def\hyper@eat#1\hyperpr@ref#2#3#4#5{#5}%
\def\hyperstr@pcurly#1{#1}%
\long\def\@footnotetext#1{\insert\footins{\reset@font\footnotesize
    \interlinepenalty\interfootnotelinepenalty
    \splittopskip\footnotesep
    \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
    \hsize\columnwidth \@parboxrestore
   \edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}%
    {\edef\@thefnmark{\expandafter\expandafter\expandafter
                      \hyper@eat\expandafter\hyperstr@pcurly\@thefnmark}%
     \edef\@thefnmark{\noexpand\hyperdef\noexpand\hypernoname{footnote}%
     {\@thefnmark}{\@thefnmark}}%
     \@makefntext
     {\rule{\z@}{\footnotesep}\ignorespaces
      #1\strut}}}}

% Similarly references are special
\def\@lbibitem[#1]#2{\item[{\def\protect{}\xdef\hypert@mp{#1}}%
                            \edef\hypert@mp{\hypert@mp}%
                            \edef\hypert@mp{\hypert@mp}%
                           \hyperdef\hypernoname{reference}{\hypert@mp}%
                           {\@biblabel{#1}}\global\let\hypert@mp=\relax\hfill]\if@filesw
      {\def\protect##1{\string ##1\space}\immediate
       \write\@auxout{\string\bibcite{#2}{#1}}}\fi\ignorespaces}

\def\@bibitem#1{\@noitemargtrue\@item
                [\hyperdef\hypernoname{reference}{\the\value{\@listctr}}%
                {\the\value{\@listctr}}]\if@filesw \immediate\write\@auxout
       {\string\bibcite{#1}{\the\value{\@listctr}}}\fi\ignorespaces}
 
\def\bibcite#1#2{\expandafter\xdef\csname b@#1\endcsname{\hyper@\hyperpr@ref
                 {}{reference}{#2}{#2}}%
                 \expandafter\gdef\csname hyperb@#1\endcsname{#2}}
 

%
% Sectioning macros
%
\def\@sect#1#2#3#4#5#6[#7]#8{\ifnum #2>\c@secnumdepth
     \let\@svsec\@empty\else
     \let\hyper@n@=\hyperdef
     \let\hyperdef=\hyper@nique
     \refstepcounter{#1}%
     \let\hyperdef=\relax\let\hypernoname=\relax
     \edef\@svsec{\hyperdef\hypernoname{#1}%
       {\csname the#1\endcsname}{\csname the#1\endcsname\hskip 1em}}%
     \let\hyperdef=\hyper@n@\fi
     \@tempskipa #5\relax
      \ifdim \@tempskipa>\z@
        \begingroup #6\relax
          \@hangfrom{\hskip #3\relax\@svsec}{\interlinepenalty \@M #8\par}%
        \endgroup
       \csname #1mark\endcsname{#7}\addcontentsline
         {toc}{#1}{\ifnum #2>\c@secnumdepth \else
                      \protect\numberline{\hyper@\hyperpr@ref\hypernoname
                      {\hbox{\hskip1pt\relax\csname the#1\endcsname}%
                       }\hskip-1pt\relax}\fi
                    #7}\else
        \def\@svsechd{#6\hskip #3\relax  %% \relax added 2 May 90
                   \@svsec #8\csname #1mark\endcsname
                      {#7}\addcontentsline
                           {toc}{#1}{\ifnum #2>\c@secnumdepth \else
                             \protect\numberline{\hyper@\hyperpr@ref\hypernoname
                           {\hbox{\hskip1pt\relax\csname the#1\endcsname}%
                            }\hskip-1pt\relax}\fi
                       #7}}\fi
     \@xsect{#5}}

%
% Captions
%
\def\caption{\let\hyper@n@=\hyperdef
             \let\hyperdef=\hyper@nique
             \refstepcounter\@captype
             \let\hyperdef=\hyper@n@
             \@dblarg{\@caption\@captype}}
\long\def\@caption#1[#2]#3{\par\begingroup
    \@parboxrestore
    \normalsize
    \@makecaption{\hyperdef\hypernoname{#1}{\csname the#1\endcsname}%
                  {\csname fnum@#1\endcsname}}{\ignorespaces #3}\par
    \addcontentsline{\csname
    ext@#1\endcsname}{#1}{\protect\numberline{\csname
    the#1\endcsname}{\ignorespaces #2}}%
  \endgroup}

%
% toc 
%
\def\@outputpage{\begingroup\catcode`\ =10
     \let\-\@dischyph \let\'\@acci \let\`\@accii \let\=\@acciii
    \if@specialpage
     \global\@specialpagefalse\@nameuse{ps@\@specialstyle}\fi
     \if@twoside
       \ifodd\count\z@ \let\@thehead\@oddhead \let\@thefoot\@oddfoot
            \let\@themargin\oddsidemargin
          \else \let\@thehead\@evenhead
          \let\@thefoot\@evenfoot \let\@themargin\evensidemargin
     \fi\fi
     \shipout
     \vbox{\reset@font %% RmS 91/08/15
           \normalsize \baselineskip\z@ \lineskip\z@
           \let\par\@@par %% 15 Sep 87
           \vskip \topmargin \moveright\@themargin
           \vbox{\setbox\@tempboxa
                   \vbox to\headheight{\vfil \hbox to\textwidth
                                       {\let\label\@gobble \let\index\@gobble
                                        \let\glossary\@gobble %% 21 Jun 91
                                        {\edef\thepage{\noexpand\hyperdef
                                         \noexpand\hyperj@nk
                                         {page}{\thepage}{\thepage}}%
                                         \@thehead}}}% %% 22 Feb 87
                 \dp\@tempboxa\z@
                 \box\@tempboxa
                 \vskip \headsep
                 \box\@outputbox
                 \baselineskip\footskip
                 \hbox to\textwidth{\let\label\@gobble
                           \let\index\@gobble  %% 22 Feb 87
                           \let\glossary\@gobble %% 21 Jun 91
                           {\edef\thepage{\noexpand\hyperdef
                            \noexpand\hyperj@nk{page}{\thepage}{\thepage}}%
                            \@thefoot}%
                           }}}\global\@colht\textheight
           \endgroup\stepcounter{page}\let\firstmark\botmark}


\edef\contentsline#1#2#3{\noexpand\hyper@nique\noexpand\hypernoname
                         {page}{#3}{}%                         
                         \noexpand\csname l@#1\noexpand\endcsname{#2}%
                         {\hyper@\hyperpr@ref\noexpand\hypernoname{#3}}}

% Some style files change this setup. After loading a style file check if
% the corresponding .hty file exists. Load it in that case.
\newread\hyper@inputcheck
\def\hyper@nput #1.sty{\input #1.sty\relax
                       \immediate\openin\hyper@inputcheck #1.hty\relax
                       \ifeof\hyper@inputcheck\relax
                         \immediate\closein\hyper@inputcheck\relax
                       \else\immediate\closein\hyper@inputcheck\relax
                         \input #1.hty\relax
                       \fi}%
\def\@documentstyle[#1]#2{\makeatletter
   \def\@optionlist{#1}\gdef\@optionfiles{}\hyper@nput #2.sty\relax
   \let\@elt\hyper@nput \@optionfiles \let\@elt\relax \makeatother}
 
\def\hyper@pen#1{\immediate\openin\hyper@inputcheck #1.hty\relax
                 \ifeof\hyper@inputcheck\relax
                   \immediate\closein\hyper@inputcheck\relax
                 \else\immediate\closein\hyper@inputcheck\relax
                   \input #1.hty\relax
                 \fi}

\def\enddocument{\@checkend{document}\clearpage\begingroup
\if@filesw \immediate\closeout\@mainaux
\def\global\@namedef##1##2{}\def\newlabel{\@testdef r}%
\def\bibcite{\@testdef {hyperb}}\@tempswafalse \makeatletter\input \jobname.aux
\if@tempswa \@@warning{Label(s) may have changed.  Rerun to get
cross-references right}\fi\fi\endgroup\deadcycles\z@\@@end}

\hypers@fe
\endinput
% Leave this line in the file