[tex-eplain] Hyperlinks in footnotes

geolsoft at mail.ru geolsoft at mail.ru
Sat Jul 23 22:50:42 CEST 2005


Please find attached a patch (patch5-foot) which provides
hyperlink support for \footnote and \numberedfootnote
macros, and a test file (hlfoot.tex).

Sorry, I have not yet got around to \enablehyperlinks, so
this still uses the old \hldriver.  I will attend to this
next (as well as to correcting a typo I discovered).

I did not provide separate parameters for controlling
hyperlinks/destinations for \footnote and \numberedfootnote,
they both use the same set (\foothldesttype,
\footbackhldesttype, \foothldestopts, \footbackhldestopts,
etc.).  I think this is appropriate (what do you think?).

I also did not provide a way for the user to specify their
own hyperlink label (as an optional parameter to \footnote /
\numberedfootnote), the labels are always generated by
\foothllabel and \footbackhllabel, because it seemed to me
that this will rarely be needed.  But even if user needs to
access the label, they can expand \foothllabel and/or
\footbackhllabel right after the \footnote (and save them
for later use).

The order of the patches, in case you are lost :)

  patch         (original patch I sent)
  patch3-cite
  patch4-btxmac
  patch5-foot

-- 
Best regards,
Oleg Katsitadze
-------------- next part --------------
--- eplain2.8.4.patched/xeplain.tex	2005-07-23 22:52:52.000000000 +0300
+++ eplain2.8.4/xeplain.tex	2005-07-23 22:58:16.000000000 +0300
@@ -2623,6 +2623,7 @@
 % the space after the rule is \belowfootnoterulespace.
 % 
 \newcount\footnotenumber
+\newcount\foothllabelnumber
 \newdimen\footnotemarkseparation \footnotemarkseparation = .5em
 \newskip\interfootnoteskip \interfootnoteskip = 0pt
 \newtoks\everyfootnote
@@ -2632,6 +2633,21 @@
 %
 \let\@plainfootnote = \footnote
 \let\@plainvfootnote = \vfootnote
+% Hyperlink labels for forward and back references.
+\def\foothllabel{FOOT\the\foothllabelnumber}%
+\def\footbackhllabel{FOOTB\the\foothllabelnumber}%
+%
+\def\@eplainfootnote#1{\let\@sf\empty % parameter #2 (the text) is read later
+  \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
+  \global\advance\foothllabelnumber by 1
+  \hlstart{\foothltype}{\foothlopts}{\foothllabel}%
+  \hldest{\footbackhldesttype}{\footbackhldestopts,raise=\footbackhldestraise}{\footbackhllabel}%
+  #1%
+  \hlend
+  \@sf\vfootnote{#1}%
+}%
+%
+\let\footnote\@eplainfootnote
 %
 \def\vfootnote#1{\insert\footins\bgroup
   \interlinepenalty\interfootnotelinepenalty
@@ -2648,7 +2664,14 @@
   \ifnum\@numcolumns > 1 \hsize = \@normalhsize \fi
   \the\everyfootnote
   \vskip\interfootnoteskip
-  \indent\llap{#1\kern\footnotemarkseparation}\footstrut\futurelet\next\fo at t
+  \indent\llap{%
+    \hlstart{\footbackhltype}{\footbackhlopts}{\footbackhllabel}%
+    \hldest{\foothldesttype}{\foothldestopts,raise=\foothldestraise}{\foothllabel}%
+    #1%
+    \hlend
+    \kern\footnotemarkseparation
+  }%
+  \footstrut\futurelet\next\fo at t
 }%
 %
 \def\footnoterule{\dimen@ = \footnoteruleheight
@@ -2661,7 +2684,7 @@
 %
 \def\numberedfootnote{%
   \global\advance\footnotenumber by 1
-  \@plainfootnote{$^{\number\footnotenumber}$}%
+  \@eplainfootnote{$^{\number\footnotenumber}$}%
 }%
 %
 %
@@ -3135,12 +3158,16 @@
 \let\lihldesttype\empty
 \let\eqhldesttype\empty % \eqdef and friends
 \let\bibhldesttype\empty % \biblabelprint (BibTeX)
+\let\foothldesttype\empty % \footnote / \numberedfootnote
+\let\footbackhldesttype\empty % back-reference for \footnote / \numberedfootnote
 % Options for destinations.
 \let\definexrefhldestopts\empty
 \let\xrdefhldestopts\empty
 \let\lihldestopts\empty
 \let\eqhldestopts\empty % \eqdef and friends
 \let\bibhldestopts\empty % \biblabelprint (BibTeX)
+\let\foothldestopts\empty % \footnote / \numberedfootnote
+\let\footbackhldestopts\empty % back-reference for \footnote / \numberedfootnote
 % We want to control the option `raise' separately because the other
 % options are usually set once and for all while `raise' may need
 % adjustment per instance (especially with equations).
@@ -3149,6 +3176,8 @@
 \def\lihldestraise{\normalbaselineskip}%
 \def\eqhldestraise{1.7\normalbaselineskip}% \eqdef and friends
 \def\bibhldestraise{\normalbaselineskip}% \biblabelprint (BibTeX)
+\def\foothldestraise{\normalbaselineskip}% \footnote / \numberedfootnote
+\def\footbackhldestraise{\normalbaselineskip}% back-reference for \footnote / \numberedfootnote
 %
 % Types of links.
 \let\xrefnhltype\empty % \refn and \xrefn
@@ -3156,12 +3185,16 @@
 \let\refhltype\empty % \ref and \refs
 \let\eqhltype\empty % \eqref and \eqrefn
 \let\citehltype\empty % \cite (BibTeX)
+\let\foothltype\empty % \footnote / \numberedfootnote
+\let\footbackhltype\empty % back-reference for \footnote / \numberedfootnote
 % Options for links.
 \let\xrefnhlopts\empty % \refn and \xrefn
 \let\xrefhlopts\empty
 \let\refhlopts\empty % \ref and \refs
 \let\eqhlopts\empty % \eqref and \eqrefn
 \let\citehlopts\empty % \cite (BibTeX)
+\let\foothlopts\empty % \footnote / \numberedfootnote
+\let\footbackhlopts\empty % back-reference for \footnote / \numberedfootnote
 %
 % Hyperlink destinations (driver-independent code).
 %
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hlfoot.tex
Type: text/x-tex
Size: 1151 bytes
Desc: not available
Url : http://tug.org/pipermail/tex-eplain/attachments/20050723/936f63ce/hlfoot.bin


More information about the tex-eplain mailing list