8

All my entries in the symbol index involving $\|\cdot\|$ get rejected. For instance {\index{symbol}{normx@{$\|\cdot\|_X$}}}.

How can I fix this?

lockstep
  • 250,273
Irina
  • 81

2 Answers2

8

The symbol | is special within the \index command as it deals with special page ranges. You need to hide this from TeX using something like

\newcommand{\norm}{\|}

Also note that \index takes only one argument which is the index entry. If you want to also print this entry in text, you need to use the following format:

...blah blah symbol\index{symbol} blah blah...

virtually duplicating the typeset component and index entry. Here's your MWE with a the above modifications:

enter image description here

\documentclass{article}
\usepackage{makeidx}% http://ctan.org/pkg/makeidx
\newcommand{\norm}{\|}
\makeindex
\begin{document}
See $\|\cdot\|_X$\index{normx@$\norm\cdot\norm_X$} and the norm\index{norm}.

\printindex
\end{document}

Consider reading through Leslie Lamport's MakeIndex : An Index Processor For LaTeX.

Werner
  • 603,163
7

Special characters for MakeIndex should be quoted: so to index |x| you have to write

\index{"|x"|}

The " character before a special character makes it lose its meaning. However \" is not treated in a particular way (it's an accent command), so your entry should be

\index{"\"|x"\"|}

or \index{normx@"\"|x"\"|} if you want a string for specifying the alphabetic order.

If you use more entries with | than entries such as \index{abc|see def} you can create a personal MakeIndex style containing just one line

encap '*'

Call this file mystyle.ist and call MakeIndex as

makeindex -s mystyle.ist filename

This will disable the special feature of | (whose role is taken by *) and so you can type \index{normx@$\|x\|$} without other precautions.

egreg
  • 1,121,712