如何控制目录中不同部分的间距?

如何控制目录中不同部分的间距?

我需要一个目录,在章节标题之间有双倍行距,但在节和小节之间有单倍行距。我知道关于这个问题有几个相关问题,但不同之处在于,当使用一些建议的解决方案(如\setlength{\cftbeforesecskip}{-2pt}\renewcommand\cftchapafterpnum{\vspace{}})时,会更改节或小节之前或之后的间距,如果所讨论的标题只有一行,那么就可以了,但如果它是一个长的三行节标题,那么它会产生非常不规则的间距,在节标题上方有所需的间距,然后看起来像是半行间距,在页码后再次是单行间距。
我尝试过的另一种解决方案是在实际文本中使用类似\section[\singlespacing{\noindent Long title}]{Long title}但尽管我在目录中得到了单行间距,但在节号和节标题开头之间也得到了一些不必要的垂直空间。有没有办法通过分层节统一更改目录中的间距,或者避免第二种方法中的额外垂直空间?另外,值得一提的是,我正在加载包setspace\onehalfspacing在文档的序言中使用,因为它的主体应该是半行间距。非常感谢,这就是我所拥有的样子:

\documentclass[12pt,reqno]{report}
\usepackage[titles]{tocloft}
\setlength{\cftbeforesecskip}{-2.5pt}
\setlength{\cftbeforesubsecskip}{-2.5pt}
\usepackage{setspace}
\onehalfspacing
\usepackage{blindtext}
\begin{document}
\tableofcontents
\newpage
\chapter{this is a really really long title that someone else wrote for all the penguins in the world}
\section{this is a really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long title having more than three lines of text to appear on the toc.}
\subsection{this is a really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long title having more than three lines of text to appear on the toc.}
\blinddocument
\blinddocument
\blinddocument
\blinddocument
\end{document}

在此 MWE 中,我展示了我尝试过的一个选项。我希望有人可以对此发表评论。谢谢。

答案1

您可以连接到\cftchapafterpnum在目录中的章节标题后添加一些垂直空间。

\documentclass[12pt,reqno]{report}
\usepackage[titles]{tocloft}
\usepackage{blindtext}

\renewcommand{\cftchapafterpnum}{\vspace{\cftbeforechapskip}}

\begin{document}
\tableofcontents
\newpage
\chapter{this is a really really long title that someone else wrote for all the penguins in the world}
\section{this is a really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long title having more than three lines of text to appear on the toc.}
\subsection{this is a really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long title having more than three lines of text to appear on the toc.}
\blinddocument
\blinddocument
\blinddocument
\blinddocument
\end{document}

在此处输入图片描述

但是,长标题与问题无关;您似乎正在加载setspace\onehalfspacing可能是为了遵守您所在机构的愚蠢要求(如果不是,只需使用标准间距,您会更高兴)。

\singlespacing做目录的时候才发的。

\documentclass[12pt,reqno]{report}
\usepackage[titles]{tocloft}
\usepackage{setspace}
\usepackage{blindtext}

\renewcommand{\cftchapafterpnum}{\vspace{\cftbeforechapskip}}

\onehalfspacing

\begin{document}

\begingroup\singlespacing
\tableofcontents
\endgroup

\chapter{this is a really really long title that someone else wrote 
for all the penguins in the world}
\section{this is a really really really really really really really
really really long title having more than three lines of text to appear on the toc.}
\subsection{this is a really really really really really really really
really really really long title having more than three lines of text to appear on the toc.}

\blinddocument

\end{document}

在此处输入图片描述

相关内容