如何控制不同部分的目錄間距?

如何控制不同部分的目錄間距?

我需要一個目錄,章節標題之間有雙倍空格,但章節和小節之間有單倍空格。我知道關於這個問題有幾個相關的問題,但不同之處在於,當使用一些建議的解決方案時,例如\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}

在此輸入影像描述

相關內容