为 Idxlayout 规定一定的垂直间距

为 Idxlayout 规定一定的垂直间距

考虑 MWE

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

\begin{document}
\large

A sentence.\index{VON GOETHE@\textbf{VON GOETHE'S \textit{FAUST}}!1@\textbf{\color{red}{Wagner}}!{Alack"! when a poor wight is so confined Amid his books, shut up from all mankind, And sees the world scarce on a holiday, As through a telescope and far away---}}
\index{VON GOETHE@\textbf{VON GOETHE'S \textit{FAUST}}!1@\textbf{\color{red}{Wagner}}!{How may he hope, with nicely tempered skill, To bend the hearts he knows not to his will?}}

Another sentence.\index{VON GOETHE@\textbf{VON GOETHE'S \textit{FAUST}}!2@\textbf{\color{red}{Faust}}!{Be thine to seek the honest gain, No shallow-tinkling fool"! Sound sense finds utterance for itself, Without the critic's rule.}}
\index{VON GOETHE@\textbf{VON GOETHE'S \textit{FAUST}}!2@\textbf{\color{red}{Faust}}!{If clear your thought, and your intention true, What need to hunt for words with much ado? The trim orations your fine speaker weaves, Crisping light shreds of thought for shallow minds, Are unrefreshing as the foggy winds That whistle through the sapless autumn leaves.}}

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

生成索引

在此处输入图片描述

如您所见,(1) 标题 (VON GOETHE'S FAUST) 和第一个副标题 (Wagner) 之间没有太多默认空格;(2) 副标题 {Wagner} 和该副标题下索引条目的开头之间也没有太多垂直空格;(3) 两个副标题下的两个条目之间也没有明显的空格。

问题:我如何自动指定索引在 (i) 标题和副标题之间;(ii) 副标题和副标题条目开头之间;(iii) 副标题条目之间显示的垂直空间?(我知道我可以vspace在每一个索引条目中使用多个命令来做到这一点——但对于整个索引来说这将是一项艰巨的任务。)

谢谢。

答案1

试试这个代码。使用\beforeheadspace\beforesubheadspace控制在标题(如 Wagner)和副标题前插入的垂直空格:问题的 (ii) 和 (iii) 项具有相同的值。

n

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

\newcommand{\beforeheadspace}{3ex}% <<<<<<<<<<<<<<<<<
\newcommand{\beforesubheadspace}{1ex}% <<<<<<<<<<<<<<<<<

\renewcommand\subitem{\vspace*{\beforeheadspace}\par\hangindent 40pt \hspace*{20pt}} % added <<<<<
\renewcommand\subsubitem{\vspace*{\beforesubheadspace}\par\hangindent 40pt \hspace*{30pt}} % added <<<<<

\begin{document}
    \large
    
    A sentence.\index{VON GOETHE@\textbf{VON GOETHE'S \textit{FAUST}}!1@\textbf{\color{red}{Wagner}}!{Alack"! when a poor wight is so confined Amid his books, shut up from all mankind, And sees the world scarce on a holiday, As through a telescope and far away---}}
    \index{VON GOETHE@\textbf{VON GOETHE'S \textit{FAUST}}!1@\textbf{\color{red}{Wagner}}!{How may he hope, with nicely tempered skill, To bend the hearts he knows not to his will?}}
    
    Another sentence.\index{VON GOETHE@\textbf{VON GOETHE'S \textit{FAUST}}!2@\textbf{\color{red}{Faust}}!{Be thine to seek the honest gain, No shallow-tinkling fool"! Sound sense finds utterance for itself, Without the critic's rule.}}
    \index{VON GOETHE@\textbf{VON GOETHE'S \textit{FAUST}}!2@\textbf{\color{red}{Faust}}!{If clear your thought, and your intention true, What need to hunt for words with much ado? The trim orations your fine speaker weaves, Crisping light shreds of thought for shallow minds, Are unrefreshing as the foggy winds That whistle through the sapless autumn leaves.}}
    
    \idxlayout{columns=1}
    \printindex
\end{document}

相关内容