如何从“文章”文档类中删除目录中每个部分之前的垂直间距?
答案1
您可以重新定义\l@section
为实现article.cls
并隐藏(或注释掉)\addvspace{1.0em \@plus\p@}%
负责额外空间的行。只需将这些行添加到文档的序言中:
\makeatletter
\renewcommand*\l@section[2]{%
\ifnum \c@tocdepth >\z@
\addpenalty\@secpenalty
\setlength\@tempdima{1.5em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode \bfseries
\advance\leftskip\@tempdima
\hskip -\leftskip
#1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
\endgroup
\fi}
\makeatother
答案2
答案3
要减少间距,无需复制/粘贴神秘的源代码,只需在原始命令\l@section
前添加负间距\l@section
\makeatletter
\let\old@l@section\l@section
\renewcommand*\l@section[2]{\vspace*{-5pt}\old@l@section{#1}{#2}}
\makeatother
或者,对于report
课堂:
\makeatletter
\let\old@l@chapter\l@chapter
\renewcommand*\l@chapter[2]{\vspace*{-5pt}\old@l@chapter{#1}{#2}}
\makeatother