1

While attempting to implement 'hvindex' in a luatex-compiled document, I discovered that the nesting feature provided by hvindex doesn't work. Here a code sample, with the precise preamble that I am using in the actual document; I cannot grasp what the problem is---perhaps some disconnect between hvindex and lualatex ?

\documentclass[10pt, letterpaper,fleqn,leqno]{article}
\usepackage{fontspec}
\usepackage[math]{iwona}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{xfrac}
\usepackage{expl3}
\usepackage{fontawesome5}
\usepackage{fontmfizz}
\usepackage{marvosym}
\usepackage{textcomp}
\usepackage{polyglossia}
\usepackage{todo}
\usepackage{marginnote}
\usepackage{multicol}
\usepackage{hycolor}
\usepackage[colorlinks,backref]{hyperref}
\usepackage[includehead=false,bottom=1in,top=1in,inner=.8in,outer=1.5in, heightrounded, marginparsep=4mm, marginparwidth=3cm]{geometry}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{lipsum}
\usepackage{makeidx}
\usepackage[makeidx]{hvindex} % one must also load 'makeidx'
\PassOptionsToPackage{protrusion=true,final}{microtype}
\newfontfeature{Microtype}{protrusion=default;expansion=default;}
\setmainfont[Microtype,Ligatures=TeX]{iwona}
\hypersetup{pdfpagemode=FullScreen, bookmarks=true, bookmarksopen=true,linkcolor=ForestGreen, pdfhighlight =/I urlcolor=BlueViolet, anchorcolor=Maroon}

\makeindex

\begin{document}
    
    What are possible explanations for why \Index{states!Democratic} states appear to have higher homeless rates per capita than \Index{states!Republican} states\\
    
    Here, just to make sure that I don't need a ``states`` indexing entry to kick-off the sub-indexing of (republican and democratic), I will force them with two ``index`` entries: \index{states} \ \ \ \ \ \ and \index{States} \ \ \ \ \ ; neither of which will appear in the printout
    
\printindex
    
\end{document}

The printout is like this:

What are possible explanations for why Democratic states appear to have higher homeless rates per capita than Republican states. Here, just to make sure that I didn't / don’t need a states entry to kick off the indexing of (republican and democratic), I will force them with two “index“ entries: and ; neither of which will appear in the printout

here is the Index

Index

Democratic, 1

Republican, 1

States, 1

states, 1


The intent of course is that the Index should include nested entries such as:

states,

___Democratic, 1

___Republican, 1

States, 1

1
  • you should supply a more minimal example you could presumably remove almost all the packages here, unless you mean the problem only occurs ifmarvosym is loaded for example? texdoc hvindex documents many index commands such as \Index but not \index that you used. What features of hvindex are you intending to use here? Jan 19, 2023 at 22:19

3 Answers 3

2

It's a bug in hvindex.sty:

\def\IndexXXii#1!#2@#3@#4\IndexNIL{%
  \ifx\relax#3\relax            %               no @ in last arg
    \ifx\hvIDXfont\hvIDXfontDefault\index{#2}#2%
    \else\index{#1!#2@\hvIDXfont{#2}}\hvIDXfont{#2}\fi%
  \else\index{#1!\protect#2@#3}#3\fi}

In the case of \Index{states!Democratic}, just

\index{Democratic}

is passed instead of the intended

\index{states!Democratic}

Indeed, if I fix the bug, the result is as expected.

\documentclass{article}
\usepackage[makeidx]{hvindex} % one must also load 'makeidx'

\def\IndexXXii#1!#2@#3@#4\IndexNIL{%
  \ifx\relax#3\relax            %               no @ in last arg
    \ifx\hvIDXfont\hvIDXfontDefault\index{#1!#2}#2% <----- added #1!
    \else\index{#1!#2@\hvIDXfont{#2}}\hvIDXfont{#2}\fi%
  \else\index{#1!\protect#2@#3}#3\fi}


\begin{document}
    
What are possible explanations for why \Index{states!Democratic} states 
appear to have higher homeless rates per capita than \Index{states!Republican} states
    
Here, just to make sure that I don't need a ``states`` indexing entry to kick-off 
the sub-indexing of (republican and democratic), I will force them with two ``index`` 
entries: \Index{states} and \Index{states}; neither of which will appear in the printout
    
\printindex
    
\end{document}

enter image description here

1

enter image description here

You are using \index so apparently not using hvindex or most of the other packages listed.

\documentclass[10pt, letterpaper,fleqn,leqno]{article}
\usepackage{makeidx}
\makeindex

\begin{document}
    
What are possible explanations for why \index{states!Democratic}
states appear to have higher homeless rates per capita than
\index{states!Republican} states
    
    Here, just to make sure that I don't need a ``states`` indexing
    entry to kick-off the sub-indexing of (republican and democratic),

%    I will force them with two ``index`` entries: \index{states} and
%    \index{States}; neither of which will appear in the printout
    
\printindex
    
\end{document}
0

The package user-guide, hvindex , v. 0.04 simplifying indexing ...by Herbert Voß(2017/12/12) indicates that "With the option makeidx the also called package is loaded and the macro \makeindex is executed." I had explicitly added \usepackage{makeidx} to the preamble because 1) the indexing was NOT working as-advertised, and 2), the phrase "the also-called package" was not explicit about whether the user had to add this to the preamble (as I did), or whether the call to 'makeidx' is made from within the package 'hvindex'. My call to the "mother package" having been explained here, I also found this older answer about erroneous code within hvindex; enter link description here wherein an error in the code is detailed. I had, in fact, tried to correct that code, but I still got erroneous nesting in my example. Hence, the posting, yesterday. Also, I had included all the preamble, on the assumption that there may be some conflicts there that someone might spot. In fact, today, I methodically removed each preamble line and discovered that the nesting was not affected (it was still erroneous). Now: Thanks be to Egreg, who identified an error in the code which still exists 9 years after the aforementioned URL's answer (which in itself was "not quite right" !), which answer also pre-dates the latest hvindex user-guide. So apparently Herbert Voß wasn't aware of the bug. I have since corrected hvindex.sty on my computer. And, it works:

\documentclass[10pt]{article}
\usepackage[makeidx]{hvindex}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{hycolor}
\usepackage[colorlinks,backref]{hyperref}
\hypersetup{pdfpagemode=FullScreen, bookmarks=true, bookmarksopen=true,linkcolor=ForestGreen, 
    pdfhighlight =/I urlcolor=BlueViolet, anchorcolor=Maroon}
\makeindex
\begin{document}
    What are possible explanations for why \Index{states!Democratic} states 
    appear to have higher homeless rates per capita than \Index{states!Republican} states

    \Index{foo} bar1 baz1\\
    \Index{foo!bar2} baz2\\
    \Index{foo!bar3!baz3}\\
    \Index{foo@\textsc{foo}} bar4 baz4\\
    \Index{foo!bar@\texttt{baz5}}\\
    \Index{foo! bar! baz@\texttt{baz6}}\\
    foo bar4 baz7 \\
    
    \Index{cakes!chocolate} \Index{cakes} made by student bakers\\
    %cakes \Index{cakes! made by} student bakers\\
    %cakes made by student \Index{cakes!made by!made by@\texttt{bakers}}\\
    chocolate cakes made by  \Index{cakes!made by!made by@\texttt{student}} bakers \\
    chocolate cakes made by student \Index{cakes!made by!made by@\texttt{bakers}}
\printindex
\end{document}

enter image description here

You must log in to answer this question.

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