TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've used amsmidx to create a separate notational index.


I need to index symbols like $\int_{\mathcal{D}}$, $\int^{\underline{\mathcal{D}}}$ (resp an end, an enriched coend). But doing so breaks everything. If I type


and then run makeindex nidx, it will accept but then on the next pass I'm told there is a missing $. Indeed, when I look in the nidx.ind file I see

\item  ^{\mathcal  {C}}$, 6

I thought the issue might be that makeindex doesn't know how to alphabetize these entries but


causes makeindex nidx to reject the entry. (But then everything else compiles at least.)

Any idea what's going wrong?

share|improve this question

The \index macro tries hard not to expand its argument, but if you give it as an argument to another command this protection does not work any more; you should do


so that the call \nidx{int@$\int$} will be first transformed into


but without absorbing the main argument; now \index will apply correctly its protection mechanism.

The problem, of course, might present again in case \nidx{int@$\int$} is buried as argument to another command; in such cases, I hope rare, put \protect\int instead of \int.

What other commands need this protection if the index entry appear in the argument to a command? It's hard to make a list; surely \mathcal doesn't, but \int and \underline do. Just look at the produced idx files and it will be quite obvious which ones.

share|improve this answer
Brilliant, thank you! That sorted me out. I didn't need to protect any of this but I'll remember for the future. – Emily Riehl Feb 18 '13 at 18:08

Your Answer


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.