I am using the imakeidx package to create an index. I want my index to be completely in abecedarian sequence, so I use the @-command for terms that are in math-mode or italic.
However, if I now want to group some items of the index (with the !-command) under an item in italic, something goes wrong. The first level item appears twince in the index, once normal and once in italic. And the second level items are group under the non-italic item.
The desired output of the index file for Term2 (see MWE below) is:
\item \textit{Term2}, 1
\subitem -A, 1
\subitem -B, 1
Does anyone have an idea how to fix that (without doing it manually)? Thank you in advance!
MWE:
\documentclass{scrreprt}
\usepackage{imakeidx}
\makeindex[columns=1]
\begin{document}
% Works as desired without \textit
Term1 \index{Term1}
Term1-A \index{Term1!-A}
Term1-B \index{Term1!-B}
% Does not work as desired with \textit
\textit{Term2} \index{Term2@\textit{Term2}}
\textit{Term2}-A \index{Term2!-A@\textit{Term2}-A}
\textit{Term2}-B \index{Term2!-B@\textit{Term2}-B}
% Does also not work
\textit{Term3} \index{Term3@\textit{Term3}}
\textit{Term3}-A \index{Term3-A@\textit{Term3}!-A}
\textit{Term3}-B \index{Term3-B@\textit{Term3}!-B}
\printindex
\end{document}
Created index file:
\begin{theindex}
\item Term1, 1
\subitem -A, 1
\subitem -B, 1
\item Term2
\subitem \textit{Term2}-A, 1
\subitem \textit{Term2}-B, 1
\item \textit{Term2}, 1
\item \textit{Term3}, 1
\item \textit{Term3}
\subitem -A, 1
\item \textit{Term3}
\subitem -B, 1
\end{theindex}
