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.

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}}}
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

And by default only three or more successive pages will be abbreviated as a range.

e.g.

bar, 1, 2, 3--6 .

I think this is what you want.

share|improve this answer
    
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
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.