# Formatted index entries within footnotes

I am using formatted subindex entries like this:

\index{foo!bar@\emph{bar}}


However, subentries appear repeated in the Index whenever I refer one within a footnote environment.

\footnote{foo bar\index{foo!bar@\emph{bar}}}


The output will be:

foo
*bar*, 1
*bar*, 3


But it should be

foo
*bar*, 1, 3


At least there is one previous attempt to deal with this situation: this question was solved using a new command \indexp. However, I would prefer to use the same \index command, because, on the one hand, it is easier to use the default command; and, on the other, I have a bunch of subfiles.

Is it possible somehow to \renewcommand (or something alike) the \index, so that it produces the desired output?

MWE

\documentclass{article}
\usepackage{makeidx}
\makeindex
\begin{document}
Kant, KrV\index{Kant!\emph{KrV}}
\footnote{Kant, KrV\index{Kant!\emph{KrV}}}
\printindex
\end{document}


Use letltxmacro. For \index[p] to work you need the imakeidx package.

\documentclass{article}
\usepackage{imakeidx}
\makeindex

\usepackage{letltxmacro}
\LetLtxMacro\indexp\index
\renewcommand\index[1]{\indexp[p]{#1}}

\begin{document}
Kant, KrV\index{Kant!\emph{KrV}}
\footnote{Kant, KrV\index{Kant!\emph{KrV}}}
\printindex
\end{document}

• Your original MWE wasn't producing the index. So I edited it and deleted the [p], for I only use one index. This way it works as intended – Ludenticus May 30 '17 at 16:45