![在“目录”和目录之间的空白处添加对目录的注释](https://linux22.com/image/356930/%E5%9C%A8%E2%80%9C%E7%9B%AE%E5%BD%95%E2%80%9D%E5%92%8C%E7%9B%AE%E5%BD%95%E4%B9%8B%E9%97%B4%E7%9A%84%E7%A9%BA%E7%99%BD%E5%A4%84%E6%B7%BB%E5%8A%A0%E5%AF%B9%E7%9B%AE%E5%BD%95%E7%9A%84%E6%B3%A8%E9%87%8A.png)
我想在目录中添加一两行注释,位于标题“目录”和目录本身之间的空白处,并且我希望有一定的自由度来调整此文本与标题和/或列表之间的距离。有什么提示吗?我正在处理文档类“书籍”。
答案1
您可以使用\addtocontents
宏:
\documentclass[]{book}
\addtocontents{toc}{\vspace{5cm}This is a note\vspace{4cm}\par}
\begin{document}
\tableofcontents
\chapter{foo}
\chapter{bar}
\end{document}
答案2
另一种可能性:将文本添加到目录的定义中
(原始定义取自book.cls
l. 588ff)
\documentclass{book}
\usepackage{lipsum}
\makeatletter
\renewcommand\tableofcontents{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\contentsname
\@mkboth{%
\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
\lipsum[2]% <- Add your text here
\@starttoc{toc}%
\if@restonecol\twocolumn\fi
}
\makeatother
\begin{document}
\tableofcontents
\chapter{bla}
\end{document}
答案3
另一种可能性是使用该tocloft
包,该包具有一个\cftaftertoctitle
命令,可以稍微扩展其预期用途,以提供所需的附加功能:
\documentclass[a4paper]{book}
\usepackage[T1]{fontenc} % unrelated to the problem, but I always load it
\usepackage{tocloft}
\usepackage{lipsum} % only for this example, generates "Lorem ipsum" text
\renewcommand*{\cftaftertoctitle}{%
\par % necessary
\nobreak\bigskip % for example
\itshape % font changes are confined to the note
This is a note after the title.
\lipsum*[2]\par
% \nobreak\vspace{18pt} % uncomment and modify as needed
}
\begin{document}
\tableofcontents
\chapter{Fake chapter title}
\lipsum[1]
\section{Fake section title}
\lipsum[2-8]
\section{Another fake title}
\lipsum[9-16]
\end{document}
此解决方案的优点是不需要传递文件.toc
......