减少目录子部分条目行之间的垂直空间量

减少目录子部分条目行之间的垂直空间量

考虑一下代码

\documentclass[12pt]{book}
\usepackage[showframe,paperwidth=5.5in,paperheight=8.25in]{geometry}

\textwidth=4in
\textheight=6.40in
\voffset -7pt

\usepackage{tocloft}

\renewcommand{\cftchapfont}{\small\bfseries} 
\renewcommand{\cftsecfont}{\small\bfseries} \renewcommand{\cftsubsecfont}{\footnotesize}

\begin{document}
\tableofcontents

\newpage

\begin{center}
\begin{minipage}{4in}\leftskip\fill\rightskip-\leftskip\parfillskip\stretch{2}%
\textbf{\scshape{Section Title}}
\end{minipage}
\end{center}
\addcontentsline{toc}{section}{Section Title}

\begin{center}
\begin{minipage}{4in}\leftskip\fill\rightskip-\leftskip\parfillskip\stretch{2}%
\textbf{A subsection of the section. A subsection of the section. A subsection of the section. A subsection of the section. A subsection of the section.}
\end{minipage}
\end{center}
\addcontentsline{toc}{subsection}{\textit{A subsection of the section. A subsection of the section. A subsection of the section. A subsection of the section. A subsection of the section.}}
\end{document}

生成目录:

在此处输入图片描述

问题:如何减少目录子部分条目中行之间的垂直空间?为什么垂直空间这么大?

谢谢。

答案1

试试这个代码。它使用 setspace包来减少目录中入口子节之前的基线跳过,并在之后扩展它。

b

\documentclass[12pt]{book}
\usepackage[showframe,paperwidth=5.5in,paperheight=8.25in]{geometry}

\textwidth=4in
\textheight=6.40in
\voffset -7pt

\usepackage{tocloft}

\renewcommand{\cftchapfont}{\small\bfseries} 
\renewcommand{\cftsecfont}{\small\bfseries}
 \renewcommand{\cftsubsecfont}{\footnotesize\itshape}
 
%********************************************************** adedd <<<<<<<<<<
\usepackage{setspace} % change the space between lines of text
\usepackage{xpatch}
\renewcommand{\cftbeforesubsecskip}{1ex}
    
\makeatletter   
\pretocmd{\l@subsection}
{\setstretch{0.6}} % reduce  baseline skip before subsection entry
{}{}

\apptocmd{\l@subsection}
{\setstretch{1.1}} % expand baseline  skip after subsection entry
{}{}

\makeatother
%**********************************************************

\begin{document}
    \tableofcontents
    
    \newpage
    
    \begin{center}
        \begin{minipage}{4in}\leftskip\fill\rightskip-\leftskip\parfillskip\stretch{2}%
            \textbf{\scshape{Section Title I}}
        \end{minipage}
    \end{center}
    \addcontentsline{toc}{section}{Section Title I}
    
    \begin{center}
        \begin{minipage}{4in}\leftskip\fill\rightskip-\leftskip\parfillskip\stretch{2}%
            \textbf{A subsection of the section. A subsection of the section. A subsection of the section. A subsection of the section. A subsection of the section.}
        \end{minipage}
    \end{center}
    \addcontentsline{toc}{subsection}{A subsection of the section. A subsection of the section. A subsection of the section. A subsection of the section. A subsection of the section.}
    
        \begin{center}
        \begin{minipage}{4in}\leftskip\fill\rightskip-\leftskip\parfillskip\stretch{2}%
            \textbf{\scshape{Section Title II}}
        \end{minipage}
    \end{center}
    \addcontentsline{toc}{section}{Section Title II}
    
    \begin{center}
        \begin{minipage}{4in}\leftskip\fill\rightskip-\leftskip\parfillskip\stretch{2}%
            \textbf{Another subsection of the section. A subsection of the section. A subsection of the section. A subsection of the section. A subsection of the section.}
        \end{minipage}
    \end{center}
    \addcontentsline{toc}{subsection}{Another subsection of the section. A subsection of the section. A subsection of the section. A subsection of the section. A subsection of the section.}
\end{document}

不相关:\scshape没有参数。

要使用, \scshape\bfseries Section Title I您需要一种同时支持这两种字体。例如添加 \usepackage{libertine}

相关内容