4

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

\usepackage{amsmidx}
\makeindex{idx}
\makeindex{nidx}
\newcommand{\idx}[1]{\index{idx}{#1}}
\newcommand{\nidx}[1]{\index{nidx}{#1}}

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

\nidx{$\int^{\mathcal{C}}$}

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

\nidx{int@$\int^{\mathcal{C}}$}

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

Any idea what's going wrong?

1 Answer 1

2

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

\newcommand{\idx}{\index{idx}}
\newcommand{\nidx}{\index{nidx}}

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

\index{nidx}{int@$\int$}

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.

1
  • Brilliant, thank you! That sorted me out. I didn't need to protect any of this but I'll remember for the future. Feb 18, 2013 at 18:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .