hvindex 与 lualatex 行为不当

hvindex 与 lualatex 行为不当

在尝试在 luatex 编译的文档中实现“hvindex”时,我发现 hvindex 提供的嵌套功能不起作用。这里有一个代码示例,其中包含我在实际文档中使用的精确序言;我无法理解问题是什么——也许是 hvindex 和 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}

打印出来是这样的:

民主党州的人均无家可归率似乎高于共和党州,这有什么可能的解释吗?在这里,只是为了确保我没有需要一个状态启动索引的条目(共和党和民主党),我将强制他们使用两个“索引”条目:和;这两个条目都不会出现在打印输出中

这是索引

指数

民主党,1

共和党,1

州,1

州,1


当然,索引的目的是应该包括嵌套条目,例如:

状态,

___民主党,1

___共和党,1

州,1

答案1

这是一个错误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}

在这种情况下\Index{states!Democratic},只是

\index{Democratic}

而不是预期的

\index{states!Democratic}

确实,如果我修复这个错误,结果就是预期的。

\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}

在此处输入图片描述

答案2

在此处输入图片描述

您正在使用,\index所以显然没有使用hvindex或列出的大多数其他软件包。

\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}

答案3

软件包用户指南,hvindex,v. 0.04简化索引...Herbert Voß (2017/12/12) 表示“使用选项 makeidx,还会加载也称为包并执行宏 \makeindex。”我明确将 \usepackage{makeidx} 添加到序言中,因为 1) 索引工作方式与宣传的并不一样,2) 短语“也称为包”没有明确说明用户是否必须将其添加到序言中(就像我做的那样),或者对“makeidx”的调用是否是从包“hvindex”内部进行的。我对“母包”的调用已在此处解释,我还找到了这个关于 hvindex 内错误代码的旧答案;在此处输入链接描述 其中详细说明了代码中的错误。事实上,我曾尝试更正该代码,但我的示例中仍然出现错误的嵌套。因此,昨天发布了这篇文章。此外,我还包含了所有前言,假设那里可能存在一些冲突,有人可能会发现。事实上,今天,我有条不紊地删除了每行前言,发现嵌套没有受到影响(它仍然是错误的)。现在:感谢 Egreg,他发现了代码中的一个错误,该错误在上述 URL 的答案(本身“不太正确”!)之后仍然存在 9 年,该答案也早于最新的 hvindex 用户指南。所以显然 Herbert Voß 不知道这个错误。我已经在我的计算机上更正了 hvindex.sty。而且,它起作用了:

\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}

在此处输入图片描述

相关内容