默认情况下,latex的TOC是由一级和二级标题构成,TOC的行距和字体调整比较麻烦,得熟悉latex.ltx命令,所以稍微研究了一下实现方法。
\def\numberline#1{\fontsize{6}{12}\selectfont\hb@xt@\@tempdima{#1\hfil}} % change fontsize for toc item
\renewcommand*\l@section[2]{%
\ifnum \c@tocdepth >\z@
\addpenalty\@secpenalty
\addvspace{-1em \@plus\p@}% 关键:report or article: change section item vertical space
\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%
\kern-\p@\kern\p@}\par
\endgroup
\fi}
\def\@dottedtocline#1#2#3#4#5{%
\ifnum #1>\c@tocdepth \else
\vskip \z@ \@plus.2\p@
\vskip -1em % 关键:report or article: change subsection item vertical space
{\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
\parindent #2\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima #3\relax
\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
{#4}\nobreak
\leaders\hbox{$\m@th
\mkern \@dotsep mu\hbox{.}\mkern \@dotsep
mu$}\hfill
\nobreak
\hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5%
\kern-\p@\kern\p@}%
\par}%
\fi}
image.png
网友评论