the latex companion documents this section 11.1.8 says: When an \index command is used directly in the text, its argument is expanded
only when the index is typeset, not when the .idx file is written. However, when
the \index command is contained in the argument of another command, char-
acters with a special meaning to TEX, such as \, must be properly protected
against expansion. This problem is likely to arise when indexing items in a foot-
note, or when using commands that put their argument in the text and enter