索引、寡妇和孤儿

索引、寡妇和孤儿

我无法处理索引中的孤行。想象一下由信件的发件人和收件人创建的索引。 \item 是收件人,\subitem 是发件人,\subsubitem 是信件发送的日期。我该如何更新命令,以便 \item 成为分页符的最佳位置,\subitem 仅当后面至少有一个子子项时才可以,并且子子项之前不应有分页符?

平均能量损失

\documentclass[a5paper]{scrbook}
\usepackage[english]{babel}
\usepackage{makeidx}\makeindex
\widowpenalty=10000         % avoid widows
\clubpenalty=10000          % avoid orphans
\raggedbottom
\begin{document}
text
\index{Adam, Ant!letters from Bernie Bert!1.1.1900}
\index{Adam, Ant!letters from Bernie Bert!2.1.1900}
\index{Adam, Ant!letters from Bernie Bert!3.1.1900}
\index{Adam, Ant!letters from Bernie Bert!4.1.1900}
\index{Adam, Ant!letters from Bernie Bert!5.1.1900}
\index{Adam, Ant!letters from Bernie Bert!6.1.1900}
\index{Adam, Ant!letters from Bernie Bert!7.1.1900}
\index{Adam, Ant!letters from Bernie Bert!8.1.1900}
\index{Adam, Ant!letters from Bernie Bert!9.1.1900}
\index{Adam, Ant!letters from Bernie Bert!2.2.1900}
\index{Adam, Ant!letters from Bernie Bert!2.2.1900}
\index{Adam, Ant!letters from Bernie Bert!3.2.1900}
\index{Adam, Ant!letters from Bernie Bert!4.2.1900}
\index{Adam, Ant!letters from Bernie Bert!5.2.1900}
\index{Adam, Ant!letters from Bernie Bert!6.2.1900}
\index{Adam, Ant!letters from Bernie Bert!7.2.1900}
\index{Adam, Ant!letters from Bernie Bert!8.2.1900}
\index{Adam, Ant!letters from Bernie Bert!9.2.1900}
\index{Adam, Ant!letters from Bernie Bert!10.2.1900}
\index{Adam, Ant!letters from Bernie Bert!11.2.1900}
\index{Adam, Ant!letters from Bernie Bert!12.2.1900}
\index{Adam, Ant!letters from Bernie Bert!13.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!1.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!2.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!3.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!4.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!5.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!6.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!7.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!8.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!9.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!2.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!2.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!3.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!4.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!5.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!6.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!7.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!8.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!9.2.1900}
\index{Bert, Bernie!letters from Adam Ant!1.1.1900}
\index{Bert, Bernie!letters from Adam Ant!2.1.1900}
\index{Bert, Bernie!letters from Adam Ant!3.1.1900}
\index{Bert, Bernie!letters from Adam Ant!4.1.1900}
\index{Bert, Bernie!letters from Adam Ant!5.1.1900}
\index{Bert, Bernie!letters from Adam Ant!6.1.1900}
\index{Bert, Bernie!letters from Adam Ant!7.1.1900}
\index{Bert, Bernie!letters from Adam Ant!8.1.1900}
\index{Bert, Bernie!letters from Adam Ant!9.1.1900}
\index{Bert, Bernie!letters from Adam Ant!2.2.1900}
\index{Bert, Bernie!letters from Adam Ant!2.2.1900}
\index{Bert, Bernie!letters from Adam Ant!3.2.1900}
\index{Bert, Bernie!letters from Adam Ant!4.2.1900}
\index{Bert, Bernie!letters from Adam Ant!5.2.1900}
\index{Bert, Bernie!letters from Adam Ant!6.2.1900}
\index{Bert, Bernie!letters from Adam Ant!7.2.1900}
\index{Bert, Bernie!letters from Adam Ant!8.2.1900}
\index{Bert, Bernie!letters from Adam Ant!9.2.1900}

\printindex

\end{document} 

这不应该发生在分页符处: 在此处输入图片描述

答案1

如果你重新定义\subitem\subsubitem而不结束一个段落,那么\widowpenalty\clubpenalty可以完成它们的工作:

\renewcommand\subitem{\unskip\nobreak\hfill\break\hspace*{-30pt}}
\renewcommand\subsubitem{\unskip\nobreak\hfill\break\hspace*{-20pt}}

在此处输入图片描述

使用负空间是为了抵消(实际上)\hangindent 40pt发出的命令。\item\@idxitem

答案2

这不是一个理想的解决方案,但它确实允许人们手动指定索引中的列/分页符。当然,这应该只适用于 其余一切都是最终决定。

确定所需中断的位置,并构造一个排序字符串,该字符串将落在之间出现在“第一”页上的最后一项和要移动到下一页的项。在提供的示例中,此字符串就足够了:

Bert, Bernie!letters from BBB

该示例(问题中示例的副本,除了添加的内容外)应该是不言自明的。

\documentclass[a5paper]{scrbook}
\usepackage[english]{babel}
\usepackage{makeidx}\makeindex
\widowpenalty=10000         % avoid widows
\clubpenalty=10000          % avoid orphans
\raggedbottom

%%% provide a mechanism for inserting a dummy index entry in the main source
%%% file to break an index column at the bottom of a column when a lone
%%% higher-level entry is separated from secondary entries in the next column.
%%% first, a command to "disappear" the page number.
\newcommand{\idxnopage}[1]{{}}
%%% a command to gobble the comma before the page number
\providecommand{\gobble}[1]{{}}
%%% the user command to insert the break
\makeatletter
\newcommand{\moveindexentry}[1]{%
  \index{#1@\string\pagebreak\string\gobble \string|idxnopage}}
\makeatother 
%%% end of commands to break column

\begin{document}
text
\index{Adam, Ant!letters from Bernie Bert!1.1.1900}
\index{Adam, Ant!letters from Bernie Bert!2.1.1900}
\index{Adam, Ant!letters from Bernie Bert!3.1.1900}
\index{Adam, Ant!letters from Bernie Bert!4.1.1900}
\index{Adam, Ant!letters from Bernie Bert!5.1.1900}
\index{Adam, Ant!letters from Bernie Bert!6.1.1900}
\index{Adam, Ant!letters from Bernie Bert!7.1.1900}
\index{Adam, Ant!letters from Bernie Bert!8.1.1900}
\index{Adam, Ant!letters from Bernie Bert!9.1.1900}
\index{Adam, Ant!letters from Bernie Bert!2.2.1900}
\index{Adam, Ant!letters from Bernie Bert!2.2.1900}
\index{Adam, Ant!letters from Bernie Bert!3.2.1900}
\index{Adam, Ant!letters from Bernie Bert!4.2.1900}
\index{Adam, Ant!letters from Bernie Bert!5.2.1900}
\index{Adam, Ant!letters from Bernie Bert!6.2.1900}
\index{Adam, Ant!letters from Bernie Bert!7.2.1900}
\index{Adam, Ant!letters from Bernie Bert!8.2.1900}
\index{Adam, Ant!letters from Bernie Bert!9.2.1900}
\index{Adam, Ant!letters from Bernie Bert!10.2.1900}
\index{Adam, Ant!letters from Bernie Bert!11.2.1900}
\index{Adam, Ant!letters from Bernie Bert!12.2.1900}
\index{Adam, Ant!letters from Bernie Bert!13.2.1900}
\moveindexentry{Bert, Bernie!letters from BBB}
\index{Bert, Bernie!letters from Caius Caligula!1.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!2.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!3.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!4.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!5.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!6.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!7.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!8.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!9.1.1900}
\index{Bert, Bernie!letters from Caius Caligula!2.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!2.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!3.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!4.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!5.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!6.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!7.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!8.2.1900}
\index{Bert, Bernie!letters from Caius Caligula!9.2.1900}
\index{Bert, Bernie!letters from Adam Ant!1.1.1900}
\index{Bert, Bernie!letters from Adam Ant!2.1.1900}
\index{Bert, Bernie!letters from Adam Ant!3.1.1900}
\index{Bert, Bernie!letters from Adam Ant!4.1.1900}
\index{Bert, Bernie!letters from Adam Ant!5.1.1900}
\index{Bert, Bernie!letters from Adam Ant!6.1.1900}
\index{Bert, Bernie!letters from Adam Ant!7.1.1900}
\index{Bert, Bernie!letters from Adam Ant!8.1.1900}
\index{Bert, Bernie!letters from Adam Ant!9.1.1900}
\index{Bert, Bernie!letters from Adam Ant!2.2.1900}
\index{Bert, Bernie!letters from Adam Ant!2.2.1900}
\index{Bert, Bernie!letters from Adam Ant!3.2.1900}
\index{Bert, Bernie!letters from Adam Ant!4.2.1900}
\index{Bert, Bernie!letters from Adam Ant!5.2.1900}
\index{Bert, Bernie!letters from Adam Ant!6.2.1900}
\index{Bert, Bernie!letters from Adam Ant!7.2.1900}
\index{Bert, Bernie!letters from Adam Ant!8.2.1900}
\index{Bert, Bernie!letters from Adam Ant!9.2.1900}

\printindex

\end{document}

像示例中的虚拟条目可以放置在源文件中的任何位置。最好将它们全部放在一个地方,以便在需要更改时可以轻松找到它们。

相关内容