<..cross ref..>+
\let\:label=\label
\def\label{\relax
\expandafter\ifx \csname cur:th\endcsname\relax \expandafter\:label
\else \expandafter\l:bel \fi}
\let\lb:l=\label
\def\l:bel#1{\@bsphack\if@filesw {\let\thepage=\relax
<.control @.>%
\let\protect=\@unexpandable@protect \cur:lbl{}%
\ifx \EndPicture\:UnDef
\ifx \cur:th\skip:anchor
<.if-label anchors.>%
\else \ifx \:currentlabel\empty
<.pre section anchor.>%
\fi \fi
\else
<.anchors for pictures.>%
\fi
\a:@newlabel
\edef\@tempa{\write\@auxout{\string
\newlabel{#1}{{<.logical label.>}%
{<.page label.>}<.hyperref label.>}}}%
\expandafter}\@tempa
\if@nobreak \ifvmode\nobreak\fi\fi\fi
<.cancel if-label anchors.>%
\@esphack}
<.sub/sup in labels/refs.>
-_-_-
<..configure @newlabel..>
\Configure{@newlabel}{\def\%{\string\%}}
-_-_-
We had before ‘\ifx \EndPicture\:UnDef...\else...\fi’ embeded within ‘\ifx \cur:th\skip:anchor’ but that eliminated the anchors for eqnarray of pictures.
To save memory, we try to get anchors only when refered by labels. For instance, this is the case for \@thm.
<..if-label anchors..>
\bgroup \a:@newlabel
\Make:Label{\label:addr}{}\egroup
-_-_-
<..cancel if-label anchors..>
\let\skip:anchor=\:UnDef
-_-_-
The following deals with labels \label provided before sectioning commands.
<..pre section anchor..>
\def\:currentlabel{doc}%
<.if-label anchors.>%
-_-_-
<..replace AutoRefstepAnchor..>
\def\AutoRefstepAnchor{\SkipRefstepAnchor}
-_-_-
The following is to ensure anchors for labels in pictures.
<..anchors for pictures..>
\begingroup
\a:@newlabel
\edef\:temp{\noexpand\AfterPicture{%
\noexpand\Make:Label{\label:addr}{}%
\noexpand\uno:lbl{\label:addr}}%
}\:temp
\endgroup
-_-_-
The following is to avoid eliminated anchors as is the case in, for instance, ‘\[xx\label{a}\label{b}\] ’.
<..cross ref..>+
\def\uno:lbl#1{\def\:temp{#1}\futurelet\:tempa\I:lbl}
\def\I:lbl{\ifx \:tempa\Make:Label \expandafter\no:mklbl \fi}
\def\no:mklbl#1#2#3{\def\:tempa{#2}\ifx \:temp\:tempa \else
\Make:Label{#2}{#3}\fi}
-_-_-
<..logical label..>
\a:newlabel\@currentlabel
-_-_-
The anchor for the page is approximated to the anchor of the logical unit. This is so to solve the possible problem of having a ‘label’ in a position where ‘<A>’ links are not allowed.
<..page label..>
\a:newlabel\thepage
-_-_-
<..cross ref..>+
\let\:currentlabel=\empty
-_-_-
In pure latex, \Configure{newlabel}{##1}.
The following is treated in a similar manner to cite. It provides the means to disable nested links in entries of tocs. The \Link doesn’t seem to need the [] option there, so a \:gobbleII can do the job.
A better def is given to \l:bel in AmsLaTeX .
<..sub/sup in labels/refs..>
\let\l:bel:=\l:bel
\def\l::bel#1{{\:SUBOff\:SUPOff\xdef\:temp{\noexpand\l:bel:{#1}}}\:temp}
\def\l:bel{\Protect\l::bel}
\let\o:ref=\:ref
\def\::ref#1{{\:SUBOff\:SUPOff\xdef\RefArg{#1}}\expandafter\o:ref
\expandafter{\RefArg}}
\def\:ref{\Protect\::ref}
\let\ref=\:ref
-_-_-
Without the ’ we may get \RefArg passed as the first argument to \T@arg, resulting in \def\RefArg{\RefArg}.
<..sub/sup in labels/refs..>+
\let\:newl@bel=\@newl@bel
\let\n:wlbl=\@newl@bel
\def\@newl@bel#1#2{{\:SUBOff\:SUPOff
\xdef\:temp{\noexpand\n:wlbl{#1}{#2}}}\:temp}
-_-_-
<..sub/sup in labels/refs..>+
\let\:testdef=\@testdef
\def\@testdef #1#2{{\:SUBOff\:SUPOff
\xdef\:temp{\noexpand\:testdef{#1}{#2}}}\:temp}
-_-_-