[tex-eplain] Contents hyperlinks

Rodolfo Medina rodolfo.medina at gmail.com
Wed Aug 3 15:42:56 CEST 2016


Rodolfo Medina <rodolfo.medina at gmail.com> writes:

> In eplain.pdf, I read:
>
>  There is currently no special support for hyperlinks in the table of
>  contents, but implementing them with the \hldest and \hlstart ... \hlend
>  commands should be possible.
>
> Could anyone please suggest a way to do that?


I haven't tested it, but the following stuff:

%%
\def\target#1{\hldest{xyz}{}{#1}}
\def\hyperlink#1#2{\hbox{\hlstart{name}{}{#1} #2\hlend}}
%%
% #1 the subchapter number, #2 the subchapter title and #3 the <LABEL> for
% \hyperlink (the same inside \target):
%%
\def\subchapterentry#1#2#3{%
  \leftskip=10pt
  \parindent=-10pt
  \rightskip=30pt plus 1fil
  \parfillskip=-\rightskip
  \par
  \indent\hbox to15pt{#1\hss}%
  \ignorespaces #2\unskip % the title #2 may have spurious spaces
  \nobreak \tocleaders 
  \noexpand\hyperlink{#3}{\folio}\par\nobreak
}
%%
% write entry into TOC table:
%%
\def\writesubchapterentry#1{%
  \begingroup
    \let\folio\relax % prevent expansion of `\folio` during `\edef`
    \edef\next{%
      \write\cont{%
              \noexpand\subchapterentry{\the\subchapternumber}{#1}{<LABEL>}}%
                  }%
    \next
  \endgroup
}
%%
% (\target{<LABEL>} somewhere is needed of course, and \newwrite\cont)
%%

should create a hyperlinked TOC entry working with both pdfTeX and Knuth's
plain TeX and dvips -> ps2pdf.  From Heiko Oberdiek's macro, see:

 http://tex.stackexchange.com/questions/261263/how-to-expand-a-register-value-in-a-write-argument-plain-tex

, in turn from TeXbook exerc.21.10.

Bye,

Rodolfo



More information about the tex-eplain mailing list