Next: , Previous: Exact destinations for index terms, Up: Index hyperlinks


5.3.8.2 Page destinations for index terms

In the second approach, Eplain does not write out any destination labels for the index terms. Instead, Eplain writes out a wrapper for page number encapsulator which can parse the page number and generate a link pointing to the page on which the term appeared. On top of each page containing an index term, Eplain defines a destination with label produced by \hlidxpagelabel. The \hlidxpagelabel command takes a single argument (page number number) and by default produces the label in the format ‘IDXPGnumber’.

With this approach, the \indexentry line which Eplain writes to the .idx file looks like this:

     \indexentry{entry|hlidxpage{cs}}{pageno}

where \hlidxpage is the command that is defined by Eplain to take two arguments: a name of page number encapsulator (cs) and a page number (pageno). In the .ind file that MakeIndex will generate, the page number will appear as

     \hlidxpage{cs}{pageno}

The advantage of this approach is that all features of MakeIndex are intact. The drawback is that links in the index do not point to exact locations of indexed terms on a page, but to the top of a page on which the term appears.

Another disadvantage is that this approach depends on the page range and page list separators which MakeIndex was configured to output. \hlidxpage must be able to parse the first page number in a page range like ‘1--4’. In addition, page list parsing is needed because MakeIndex combines two consecutive page numbers in one call to the page number encapsulator, so \hlidxpage can be passed, e.g., ‘1, 2’ for the pageno. In this last case, \hlidxpage splits the two page numbers, applies \cs to each of them, and makes each of the page numbers a link to the appropriate page. Note that this will alter typesetting slightly, because now the page list separator (a comma followed by a space, by default) is not typeset using the page number encapsulator (\cs).

Eplain's defaults for the page list and page number delimiters are the same as those in MakeIndex, a comma followed by a space (‘, ’) and two dashes (‘--’), respectively. If you customize MakeIndex to use different delimiters, you must not forget to let Eplain know about them with the commands

     \setidxpagelistdelimiter{list-delim}
     \setidxpagerangedelimiter{page-delim}

(see Page list and page range parsers).