# How do I combine formatted page numbers in an index

If I format page numbers in an index, they show up in addition to non-formatted numbers. This minimal example:

\documentclass{article}
\usepackage{makeidx} \makeindex \begin{document} page 1
\index{foo}        % normal page number
\index{foo|textbf} % bold page number
\index{bar}        % normal page number
\pagebreak page 2
\index{bar|textbf} % bold page number
\printindex \end{document}


Creates the following index

bar, 1, 2
foo, 1, 1

But I would prefer to combine a normal page number and a formatted page number as bold page number and also allow formatted page number in page sequences:

bar, 1-2
foo, 1

Maybe page sequences are too complicate, for instance if page 1 and 3 are normal, but page 2 is formatted. But at least the duplicated single page number (in this example "1, 1") should not be there.

More precise I do not use textbf but a custom bfhref for hyperlinked page numbers, but this should not be the issue

\newcommand{\bfhref}[1]{\textbf{\hyperpage{#1}}}

-

The process from idx file to ind is controlled by the command makeindex. I can not find any options about your demand. An alternative way to remove those duplicated pages is to deal with *.ind file yourself. For example, you can replace the pattern num, \textbf{num} with \textbf{num}. It's easy to accomplish with any editor supporting regular expression replacement.
Thank. As there is no TeX solution, I'll hack a script to clean up the idx file. I use splitindex which itself calls makeindex. Maybe I do not have to manually change the idx file with xindy, which looks better than makeindex but has its own drawbacks (biblatex replaces bibtex for good reason, but makeindex is still most used despite its problems). –  Jakob Nov 25 '10 at 21:11