I have nearly the same problem as this guy but the solution doesn't work for me, I think because the string I am indexing is in a macro argument.
From the other question:
The characters
!
,@
, and|
need to be escaped in an indexing context. For makeindex to understand you mean to mention them rather than use them, you must 'quote' them with a"
. The following should do the trick:
\index{"!} % or, in this case: \fun{"!}
Applying this to my code I get
\newcommand{\coper}[1]%
{%
\texttt{#1}%
\ifthenelse%
{\equal{#1}{!} \OR \equal{#1}{@}}%
{%
\index{"#1@\texttt{"#1} (C operator)}%
\index{operators!\texttt{"#1} (C)}%
}%
{%
\index{#1@\texttt{#1} (C operator)}%
\index{operators!\texttt{#1} (C)}%
}%
}
Invoking \coper{!}
adds an entry to the index, but the exclamation point does not appear in the index (it's just blank, but the surrounding text is there).
How do I add the exclamation point to the index when it is given through a macro argument?