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.

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?

share|improve this question
1  
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 –  Andrew Swann Aug 15 '12 at 8:36

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer
1  
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 –  David Carlisle Aug 15 '12 at 9:52
1  
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. –  David Carlisle Aug 15 '12 at 9:54
1  
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. –  Heiko Oberdiek Aug 15 '12 at 12:03
2  
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.... –  David Carlisle Aug 15 '12 at 12:34
1  
@DavidCarlisle Then I would consider something like \newcommand*{\Index}[1]{\index{\detokenize{#1}}} to avoid trouble with macro expansion. –  Heiko Oberdiek Aug 15 '12 at 14:23

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.