# Formatting index page references as “1 sq.” without “sq.” being part of a hyperlink

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}

\clearpage

\printindex

\end{document}


-
+1 for explaining what sq and sqq stand for. :-) – Mico Jun 2 '12 at 11:42

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.}"


-

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}


@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