Code: Select all
\documentclass{book}
\usepackage{makeidx}
\makeindex
\newcommand{\cmd}[1]{\textsf{\textsl{#1}}}
\newcommand{\CmdEntry}[1]{#1@\cmd{#1}}
\newcommand{\IndexCmd}[1]{\index{\CmdEntry{#1}}}
\begin{document}
Hello.
\index{one@\cmd{one}}
\IndexCmd{two}
\index{\CmdEntry{three}}
\printindex
\end{document}
three@three, 1
one, 1
two, 1
"one", "two", and the "three" after the @ are in the correct font. Why isn't the index entry for "three" correct? It seems I can use CmdEntry when defining other commands, but I can't use it as the argument to index in the body of the document.