减少图表列表和表格列表项目之间的空间

减少图表列表和表格列表项目之间的空间

我需要将表格列表和图表列表条目之间的间距减半。我希望无论条目属于哪个章节,间距都相等。我的部分代码如下:

\documentclass[a4paper,12pt,oneside]{report}
\usepackage[left=3.81cm,right=2.54cm,top=2.54cm,bottom=2.54cm]{geometry}

....
addcontentsline{toc}{chapter}{References}


..... (I added this patch to remove any extra space between entries from different chapters, and it worked for me but I am unable to reduce the spacing overall)

   \usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
% \patchcmd{<cmd>}{<search>}{<replace>}{<succes>}{<failure>}
\patchcmd{\@chapter}{\addtocontents{lof}{\protect\addvspace{10\p@}}}{}{}{}% LoF
\patchcmd{\@chapter}{\addtocontents{lot}{\protect\addvspace{10\p@}}}{}{}{}% LoT
\makeatother
%

答案1

在此处输入图片描述

加载tocloft包时,ToC 中条目之间的间距将存储在\cftsecafterpnum节和\cftsubsecafterpnum小节中。在 LoF 中,它存储在中\cftfigafterpnum。要设置间距,您可以使用如下代码

\newlength{\toclineskipl}
\setlength{\toclineskipl}{0.5\baselineskip}

\renewcommand{\cftfigafterpnum}{\vspace{\toclineskipl}} % for figures
\renewcommand{\cftsecafterpnum}{\vspace{\toclineskipl}} % for sections
\renewcommand{\cftsubsecafterpnum}{\vspace{\toclineskipl}} % for subsections

只需设置\toclineskipl为您想要的长度,这反过来会设置 ToC 和 LoF 条目之间的间距。

完整的示例代码

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage[showframe]{geometry}
\geometry{top=15mm,left=15mm}

\usepackage{tocloft}
\newcommand{\toctitlefont}{\LARGE \bfseries}
\renewcommand{\cfttoctitlefont}{\centering \toctitlefont}

% Spacing between lines
\newlength{\toclineskipl}
\setlength{\toclineskipl}{0.5\baselineskip}

\renewcommand{\cftfigafterpnum}{\vspace{\toclineskipl}}
\renewcommand{\cftsecafterpnum}{\vspace{\toclineskipl}}
\renewcommand{\cftsubsecafterpnum}{\vspace{\toclineskipl}}

\usepackage{blindtext}

\begin{document}

\listoffigures
\tableofcontents
\blinddocument



\begin{figure}[h t p]

    \centering

    \includegraphics[trim = 0mm 0mm 0mm 0mm, clip, width=0.48\textwidth]{example-image-a}

    \caption{Caption of Figure 1}

\end{figure}


\begin{figure}[h t p]

    \centering

    \includegraphics[trim = 0mm 0mm 0mm 0mm, clip, width=0.48\textwidth]{example-image-a}

    \caption{Caption of Figure 2} 

\end{figure}

\begin{figure}[h t p]

    \centering

    \includegraphics[trim = 0mm 0mm 0mm 0mm, clip, width=0.48\textwidth]{example-image-a}

    \caption{Caption of Figure 3}

\end{figure}

\begin{figure}[h t p]

    \centering

    \includegraphics[trim = 0mm 0mm 0mm 0mm, clip, width=0.48\textwidth]{example-image-a}

    \caption{Caption of Figure 4}

\end{figure}

\begin{figure}[h t p]

    \centering

    \includegraphics[trim = 0mm 0mm 0mm 0mm, clip, width=0.48\textwidth]{example-image-a}

    \caption{Caption of Figure 5}

\end{figure}

\end{document}

相关内容