扩大目录中特定页面的长度以容纳附加条目

扩大目录中特定页面的长度以容纳附加条目

我想有选择地扩大目录中特定页面的垂直长度以容纳“寡妇”条目。

考虑一下代码

\documentclass[openany]{book}

\newcommand*{\redefinesectiontotoc}[1]{%
  \addtocontents{toc}{\protect\contentsline{section}{{}#1}{}{}}%
}

\usepackage{tocloft}
\renewcommand\cftchapafterpnum{\vskip 12pt} %set space after each Chapter in the Table of Contents
\renewcommand\cftsecafterpnum{\vskip 8pt}  %set space after each Section in the Table of Contents

% To extend the dots in the Table of Contents over to the Page number
\renewcommand{\cftchapleader}{\bfseries \dotfill}

% To take away the dots from a section display in the Table of Contents
\renewcommand{\cftsecleader}{\hfill}

\begin{document}
Some words.\addcontentsline{toc}{chapter} {\textbf{First Chapter.}}
\redefinesectiontotoc{A Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter}

\addcontentsline{toc}{chapter} {\textbf{Second Chapter.}}
\redefinesectiontotoc{A Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter}

\addcontentsline{toc}{chapter} {\textbf{Third Chapter.}}
\redefinesectiontotoc{A Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter}

\addcontentsline{toc}{chapter} {\textbf{Fourth Chapter.}}
\redefinesectiontotoc{A Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter}

\addcontentsline{toc}{chapter} {\textbf{First Chapter.}}
\redefinesectiontotoc{\textbf{I would like to be able to enlarge the previous page in the TOC so as to include this entry on it.}}

\newpage
\tableofcontents
\end{document}

生成目录:

在此处输入图片描述

在此处输入图片描述

问题:如何选择性地调整特定页面(本例中为第一页)的垂直长度以容纳附加条目?是否有类似于目录的命令\enlargethispage{1.0\baselineskip}

谢谢。

答案1

您可以使用\enlargethispage,但是页脚前没有空间,因此我还使用`\thispagestyle{empty} 来丢失页码。

在此处输入图片描述

\documentclass[openany]{book}

\newcommand*{\redefinesectiontotoc}[1]{%
  \addtocontents{toc}{\protect\contentsline{section}{{}#1}{}{}}%
}

\usepackage{tocloft}
\renewcommand\cftchapafterpnum{\vskip 12pt} %set space after each Chapter in the Table of Contents
\renewcommand\cftsecafterpnum{\vskip 8pt}  %set space after each Section in the Table of Contents

% To extend the dots in the Table of Contents over to the Page number
\renewcommand{\cftchapleader}{\bfseries \dotfill}

% To take away the dots from a section display in the Table of Contents
\renewcommand{\cftsecleader}{\hfill}

\begin{document}
Some words.\addcontentsline{toc}{chapter} {\textbf{First Chapter.}}
\redefinesectiontotoc{A Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter}

\addcontentsline{toc}{chapter} {\textbf{Second Chapter.}}
\redefinesectiontotoc{A Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter}

\addcontentsline{toc}{chapter} {\textbf{Third Chapter.}}
\redefinesectiontotoc{A Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter}

\addcontentsline{toc}{chapter} {\textbf{Fourth Chapter.}}
\redefinesectiontotoc{A Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter---Another Topic from the Chapter}

\addcontentsline{toc}{chapter} {\textbf{First Chapter.}}
\redefinesectiontotoc{\textbf{I would like to be able to enlarge the previous page in the TOC so as to include this entry on it.}}

\newpage
\addtocontents{toc}{\protect\thispagestyle{empty}}
\enlargethispage{4\baselineskip}
\tableofcontents
\end{document}

实际上,我认为我应该避免扩展页面,而是稍微缩小垂直空间(或两者兼而有之)。

相关内容