[tex-eplain] Indexing and numberedlist

Oleg Katsitadze olegkat at gmail.com
Wed Aug 1 16:41:57 CEST 2007

On Wed, Aug 01, 2007 at 01:37:18PM +0000, Adam Fenn wrote:
> I would like to add one final refinement to your macro and that is a 
> hyperlink. Is that possible?

Sure, it's quite easy, assuming your index won't have ranges (they
only make sense for page numbers, not list item numbers, I think).
You need to add "page number encapsulator" to the index entry,
separated with `|' (ldxref), and pass the autogenerated hyperlink
label to it, and then define \ldxref to typeset the number as a
hyperlink.  (Look at the .ldx and .lnd files to see how this works.)
Here's the code:

\input eplain

% Load the color package to make hyperlinks colored.

\immediate\openout\listidxfile = \jobname.ldx

 {#1, }%                      surname
 {#2: }%                      forename
 {#3}%                        stuff
   % \li has advanced the numbers, so restore this item's number.
   \advance\itemnumber by -1
   \advance\itemletter by -1
   \advance\itemromannumeral by -1
   % Pass arguments through a \toks register, to avoid unneeded
   % expansion during \write.
   \toks0={#1, #2}%
   % Write immediately, as opposed to writing during page shipout,
   % otherwise item numbers and \the\toks0 will be all wrong.
 \global\advance\ldxrefcount by1

% Typeset list item number in the index as a hyperlink.  #1 is the
% hyperlink label, #2 is the list marker.

\MyMacro{Another Surname}{Another Forename}{Another Stuff}




You can add various options to \hldest and \hlstart to suit your
purposes (see "Explicit hyperlinks" section of the manual).  I've
added options to remove the box around hyperlinks (I hate them!) and
included the color package so that hyperlinks are colored.

Process the file with something like:

  $ pdftex test && makeindex test.ldx -o test.lnd && pdftex test


More information about the tex-eplain mailing list