0

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}

Repeated entries

1 Answer 1

1

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}
1
  • 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
    Commented May 30, 2017 at 16:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .