Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

By default, MakeIndex will format page references which are composed of two or three consecutive pages as (e.g.) "1, 2"/"1-3". With a suitable index style file, the formatting can be changed to "1 sq."/"1 sqq." (with "sq." standing for "sequens", "sqq." for "sequentes"). However, with the hyperref package loaded, "sq." and "sqq." will be part of the respective page reference hyperlinks. How can I limit those hyperlinks to the actual page numbers?

\documentclass{article}

\usepackage{makeidx}
\makeindex

\usepackage{hyperref}

\usepackage{filecontents}

\begin{filecontents}{\jobname.mst}
suffix_2p "~sq."
suffix_3p "~sqq."
\end{filecontents}

\begin{document}

Some text about foo\index{foo}.

\clearpage

Another text about foo\index{foo}.

\printindex

\end{document}

enter image description here

share|improve this question
    
+1 for explaining what sq and sqq stand for. :-) –  Mico Jun 2 '12 at 11:42
add comment

2 Answers

up vote 4 down vote accepted

The answer to my question can be found in hyperref's README (not in the manual):

For hyperlink support in the index, hyperref inserts \hyperpage into the index macros. After processing with Makeindex, \hyperpage analyzes its argument to detect page ranges and page comma lists. However, only the standard settings are supported directly:

delim_r "--"
delim_n ", "

(See manual page/documentation of Makeindex that explains the keys that can be used in style files for Makeindex.) Customized versions of

delim_r, delim_n, suffix_2p, suffix_3p, suffix_mp

needs markup that \hyperpage can detect and knows that this stuff does not belong to a page number. Makro \nohyperpage serves as this markup. Put the customized code for these keys inside \nohyperpage, e.g.:

suffix_2p "\\nohyperpage{f.}"
suffix_3p "\\nohyperpage{ff.}"

(Depending on the typesetting tradition some space "\\," or "~" should be put before the first f inside \nohyperpage.)

In my case, the index style file must be modifield as follows:

suffix_2p "\\nohyperpage{~sq.}"
suffix_3p "\\nohyperpage{~sqq.}"

enter image description here

share|improve this answer
add comment

Using hyperref you can also manipulate the grouping mechanism.

Using makeindex means that the complete page number is formated with \command{...}

So you can simple add a }{ to your suffix declaration:

suffix_2p "}{~sq."

Here the complete code (I used imakeidx to simplify the compilation)

\documentclass{article}

\usepackage{imakeidx}
\makeindex

\usepackage{hyperref}

\usepackage{filecontents}

\begin{filecontents}{\jobname.mst}
suffix_2p "}{~sq."
suffix_3p "~sqq."
\end{filecontents}

\begin{document}

Some text about foo\index{foo}.

\clearpage

Another text about foo\index{foo}.

\printindex

\end{document}
share|improve this answer
    
Nice trick! Could there be any adverse effects? –  lockstep Jun 2 '12 at 12:41
    
@lockstep: As long as you using makeindex no. The trick is the same. To format the page of a special index entry you can use \index{foo|textbf}. That shows you can use every command with one mandatory argument. So the opening and closing is one way. –  Marco Daniel Jun 2 '12 at 12:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.