关于 Makeindex、Subentries 和 Stackengine(以及没有 Xindy)

关于 Makeindex、Subentries 和 Stackengine(以及没有 Xindy)

\makeindex索引条目的级别数上限为三级似乎是一个众所周知的缺陷。

例如,如果我运行代码

\documentclass{book}
\usepackage{imakeidx}
\let\cleardoublepage\clearpage
\usepackage{imakeidx}
\makeindex
\usepackage{idxlayout}

\begin{document}
\LARGE

``I love my subject.''\index{\textbf{James Joseph Sylvester}! After Woolwich and Charlottesville! Arrives at Baltimore}
%\index{\textbf{James Joseph Sylvester}! After Woolwich and Charlottesville! Arrives at Baltimore! Is paid in gold at Johns Hopkins}
\idxlayout{columns=1}
\printindex
\end{document}

一切都很好;索引如下

在此处输入图片描述

但是,如果我\index{\textbf{James Joseph Sylvester}! After Woolwich and Charlottesville! Arrives at Baltimore}

\index{\textbf{James Joseph Sylvester}! After Woolwich and Charlottesville! Arrives at Baltimore! Is paid in gold at Johns Hopkins}

然后索引就会消失。

在阅读 Steven B. Segeletes 对如何自动将姓名的首字母与下方头衔的首字母对齐,我决定发布这个问题:

问题:\makeindex仅使用 (而非 xindy),是否可以stackengine巧妙地调用包以容纳索引条目的第四级;如果可以,如何通过修改上述代码来实现这一点?如果不使用stackengine,有没有其他不使用 的方法xindy

谢谢。

答案1

假设在(一个或多个)假的 4 级入口之前总有一个 3 级入口

在此处输入图片描述

\documentclass{book}
\usepackage{imakeidx}
\let\cleardoublepage\clearpage %why
\usepackage{imakeidx}
\makeindex
\usepackage{idxlayout}

\begin{document}
\LARGE

``I love my subject.''\index{\textbf{James Joseph Sylvester}! After Woolwich and Charlottesville! Arrives at Baltimore}
x\index{\textbf{James Joseph Sylvester}! After Woolwich and Charlottesville! Arrives at Baltimore,  Is paid in gold at Johns Hopkins@{\hspace*{15pt}Is paid in gold at Johns Hopkins}}
\idxlayout{columns=1}
\printindex
\end{document}

或不带逗号表示第三级条目

在此处输入图片描述

\begin{filecontents}{\jobname.ist}
delim_2 "\\nonumcheck "
\end{filecontents}
\documentclass{book}
\usepackage{imakeidx}
\let\cleardoublepage\clearpage %why
\usepackage{imakeidx}
\makeindex[options= -s \jobname.ist]
\usepackage{idxlayout}

\newcommand\nonum[1]{}
\makeatletter
\newcommand\nonumcheck{\@ifnextchar\nonum{}{, }}
\makeatletter

\begin{document}
\LARGE

``I love my subject.''%
\index{\textbf{James Joseph Sylvester}! After Woolwich and Charlottesville! Arrives at Baltimore|nonum}
x%
\index{\textbf{James Joseph Sylvester}! After Woolwich and Charlottesville! Arrives at Baltimore,  Is paid in gold at Johns Hopkins@{\hspace*{15pt}Is paid in gold at Johns Hopkins}}
\idxlayout{columns=1}
\printindex
\end{document}

相关内容