I have a problem when I use \index to index a term with an accent in a footnote. The index key created is not the same as if I use \index to index the same term outside of the footnote. This causes the entries not to be combined in the resulting index.
Here is a MWE:
\documentclass{article}
\usepackage{imakeidx}
\makeindex
\begin{document}
\index{K\H{o}nig}
\footnote{\index{K\H{o}nig}}
\printindex
\end{document}
If I latex that and then inspect the idx file, I see
\indexentry{K\H{o}nig}{1}
\indexentry{K\H {o}nig}{1}
Is there any way to prevent this behavior? (Preferably other than moving the \index outside of the footnote.)
\footnote{\index{K\string\H{o}nig}}to turn the control sequence\Hinto a list of character tokens, so it doesn't expand until later. – rbrignall Feb 07 '22 at 21:29