Q: Simplify index nested entries 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}


A: 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}


