Take the 2-minute tour ×

In document class book, and package caption, creating index with makeidx. Index entries for the main text and for footnotes collate properly; but those for captions create their own entries.

Example: for the tag \index{New York!Custom House!\textit{Cartouche}}, text and footnotes collate properly; but used in a caption, a new entry is created at the third level, and is also out-of-alphabetic-sequence. Note: the top level, and first sub are correct; only the second sub is duplicated.

How to get the caption index entries under the same entry?

share|improve this question

2 Answers 2

The problem is in the fact that a "normal text" appearance of


writes in the .idx file a line such as

\indexentry{New York!Custom House!\textit{Cartouche}}{1}

while the same in the argument of \caption will have

\indexentry{New York!Custom House!\textit  {Cartouche}}{3}

(the numbers will be different for your document). This is due to how LaTeX processes caption texts. You see that the two lines are different and they are actually very different to MakeIndex.

There's also a problem in how you write the index annotations: formatting instructions are bound to confuse the collating process by MakeIndex. So use

\index{New York!Custom House!Cartouche@\textit{Cartouche}}

in normal text and, for the caption, write something like

\caption{A caption telling about \textit{Cartouche}%
  \index{New York!Custom House!Cartouche@\string\textit{Cartouche}}}
share|improve this answer
Good - this works - thanks - lingering problem: this throws the sort ordering off for the third-level. The entries treated as above have their own sort-order. I'm experimenting, but it looks like it is descending alphabetical. –  calmbob Dec 28 '12 at 1:46
@calmbob Can you make an example? MakeIndex bases the sorting on what comes before the @ –  egreg Dec 28 '12 at 10:40
I think I found the flaw in my thinking - I rigorously harmonized use of \textit across all the entries, and all works magically - correctly, that is –  calmbob Dec 28 '12 at 14:04
@egreg -- two points: (1) makeindex bases the combining (if not the sorting) on the entire string within the argument of \index{...}, and (2) \protect will not work here -- it will leave a single space after \textit (unprotected command gets two spaces as seen in your example) -- so it is absolutely necessary to use \string. very un-latex-y, but that's the way it is. –  barbara beeton Dec 28 '12 at 16:35

As an alternative mechanism

An alternative to egreg's solution I was going to post


Then you can use


You could redefine \index to always do this, this just always prevents the verbatim nature of \index from activating, so you have to be a bit more careful about what you put in the argument, but it does then work consistently in all contexts.

share|improve this answer

Your Answer


