如何指定索引条目之间的间隙

如何指定索引条目之间的间隙

代码

\documentclass{book}
\usepackage{imakeidx}
\let\cleardoublepage\clearpage
\makeindex
\usepackage[itemlayout=singlepar]{idxlayout}

\begin{document}
\LARGE

This is the first paragraph.\index{AA! first}\index{AA! second}\index{AA! third}

This is the second paragraph.\index{AAB! an entry}

This is the third paragraph.\index{AAC! another entry}

\idxlayout{columns=1}
\printindex
\end{document}

生成索引:

在此处输入图片描述

我如何提前指定 AA 和 AAB 之间、AAB 和 AAC 之间的间隙(例如,5pt、10pt、12pt 等)?

答案1

重新定义\@idxitem以添加一些垂直空间。

\documentclass{book}
\usepackage{imakeidx}
\usepackage[itemlayout=singlepar]{idxlayout}

\makeindex

\makeatletter
\renewcommand{\@idxitem}{\par\addvspace{\medskipamount}\hangindent40\p@}
\makeatother

\begin{document}

This is the first paragraph.\index{AA! first}\index{AA! second}\index{AA! third}

This is the second paragraph.\index{AAB! an entry}

This is the third paragraph.\index{AAC! another entry}

\idxlayout{columns=1}

\printindex

\end{document}

在此处输入图片描述

相关内容