11

I want create index nested entries and typeset the indexed word with the same command.

For simple entries like \index{foo} I can solve this with some macro or \index*{foo} or \Index{foo} with the packages index and hvindexrespectively, but the problem is with nested entries like foo!bar where I want type only "bar" in the text and obtain a correct nested entry in the index, that is:

foo
  bar, 1 

According to manual of hvindex, this package do just that, but I am unable to obtain any nested entry with this package in an updated TeXLive 2013. This MWE type correctly "bar" in main text but only "bar, 1" as index entry in my computer:

\documentclass{article}
\usepackage[makeidx]{hvindex}
\begin{document}
\Index{foo!bar}
\printindex
\end{document}

Instead, index make the correct nested entry but write "foo!bar" as is in the body text:

\documentclass{article}
\usepackage{index}
\makeindex
\begin{document}
\index*{foo}
\index*{foo!bar}
\printindex
\end{document}
lockstep
  • 250,273
Fran
  • 80,769
  • 1
    Since TeX Live 2013 has not yet been released, it's best to stick with the 2012 version, when reporting problems. However the problem seems present also in the 2012 release. – egreg May 25 '13 at 21:17
  • ehh...right, right, ... but you know, warm-blooded users cannot live too long on a frozen release. :) – Fran May 25 '13 at 21:53

1 Answers1

6

It seems to be a bug in hvindex; a missing #1 in one of the calls to \index made by the internal macros.

\documentclass{article}
\usepackage[makeidx]{hvindex}

%%% fix \IndexXXii
\def\IndexXXii#1!#2@#3@#4\IndexNIL{%
  \ifx\relax#3\relax            %               no @ in last arg
    \def\hvTemp{#2}%
    \ifx\hvTemp\hvEncap\index{#1!{#2}}#2\else
      \ifx\hvIDXfont\hvIDXfontDefault\index{#1!#2}#2% <--- Here a % and #1 were missing
      \else\index{#1!#2@\hvIDXfont{#2}}\hvIDXfont{#2}\fi\fi%
  \else\index{#1!\protect#2@#3}#3\fi}

\begin{document}
\Index{foo}

\Index{foo!bar}
\printindex
\end{document}

enter image description here

egreg
  • 1,121,712