# Problem with \index in align environment

Please compile the following MWE. As you will then see, the typesetting of $\mu^{\otimes\downarrow n}$ in the index is strange!

\documentclass{article}
\usepackage{amsmath}
\usepackage{imakeidx}
\makeindex
\begin{document}
\begin{align}\index{$\mu^{\otimes\downarrow n}$}
x
\end{align}
\printindex
\end{document}


NB: No problem for equation instead of align or if $\index{$\mu^{\otimes\downarrow n}$}$ is placed before \begin{align}.

What's wrong here?

• I can confirm this. The idx file contains \delimiter "3223379, which prints as a large bracket, instead of \downarrow. This occurs for other AMS environments including gather and multline, but as @lpdbw says it is fine for equation Aug 15 '12 at 8:36

Normally the argument of \index is read verbatim, but ams alignments act like command arguments and defeat verbatim so the argument is read as command tokens and the entry expands to

 \indexentry{$\mu ^{\otimes \delimiter "3223379 n}$}{1}


which messes up the index. You could use

\index{$\mu^{\otimes\protect\downarrow n}$}


which would work, but produces different index entry to the command when used in equation or other normal environments. Probably the simplest way to ensure that all uses of this produce the same index entry is to use

\mbox{\index{$\mu^{\otimes\protect\downarrow n}$}}


where the \mbox is just there to force the argument into a macro argument so that the verbatim processing is turned off consistently.

• That's its definition:-) plain tex defines \def\downarrow{\delimiter"3223379 } The hex number tells TeX which font(s) to extract the symbol from at normal and large sizes Aug 15 '12 at 9:52
• latex defines it as \DeclareMathDelimiter{\downarrow} {\mathrel}{symbols}{"23}{largesymbols}{"79} which is easier to read but it makes the same definition in the end. Aug 15 '12 at 9:54
• To get the same index entry \indexentry{$\mu^{\otimes\downarrow n}$}{...} is written by \index{$\mu^{\otimes\downarrow n}$}, if \index can read its argument in verbatim manner (outside of align), or by \index{$\string\mu^{\string\otimes\protect\downarrow n}$}, if \index and its argument is already read before \index is executed (inside align or \mbox). \string does not append a space after a control sequence name, but \protect or \detokenize do. Aug 15 '12 at 12:03
• See egreg's great answer in the link from his comment. basically the " means hex-number in Tex but (by default) it is a quote character for makeindex, so it quotes the next thing, which is a digit, which just produces itself, so makeindex carries on but produces something without the " which then gets interpreted by TeX as a decimal number and anything that happens after that is purely accidental.... Aug 15 '12 at 12:34
• @DavidCarlisle Then I would consider something like \newcommand*{\Index}[1]{\index{\detokenize{#1}}} to avoid trouble with macro expansion. Aug 15 '12 at 14:23