我目前正在用 Latex 撰写论文,论文应该是双倍行距,所以我\doublespacing
在我的 Latex 文件中使用了该命令。
问题:
章节或节标题、图片说明和表格说明较长,往往会在目录、图片列表和表格列表中分成多行。目前,目录、图片列表和表格列表中所有行之间的间距都是双倍行距。但是,单个条目的多行应该是单倍行距,不同条目之间的间距应该是双倍行距。
其他地方也有类似的问题和解决方案,但到目前为止,似乎没有一个能让我满意。此外,其他解决方案似乎无法与 配合使用\documentclass{report}
。
我在下面提供了一个 MWE 来描述该问题。
\documentclass[a4paper,12pt]{report}
\usepackage{setspace}
\usepackage{mwe} % just for dummy images
\doublespacing
\begin{document}
\addcontentsline{toc}{chapter}{Contents}
\tableofcontents
\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures
\listoftables
\addcontentsline{toc}{chapter}{List of Tables}
\chapter{Test Chapter with a very very very very long name which splits over multiple lines}
Lorem ipsum dolor sit amet, consectetuer Lorem ipsum dolor sit amet, consectetuer Lorem ipsum dolor sit amet, consectetuer Lorem ipsum dolor sit amet, consectetuer
\section{This is a long section title which splits across multiple lines. Dummy Text Dummy Text Dummy Text Dummy Text}
Lorem ipsum dolor sit amet, consectetuer Lorem ipsum dolor sit amet, consectetuer Lorem ipsum dolor sit amet, consectetuer Lorem ipsum dolor sit amet, consectetuer
\subsection{Another section title}
\begin{figure}[!htb]
\centering
\includegraphics[width=3cm]{example-image}
\caption{This is a long figure caption which splits across multiple lines. Dummy Text Dummy Text Dummy Text Dummy Text}
\end{figure}
\begin{figure}[!htb]
\centering
\includegraphics[width=3cm]{example-image}
\caption{This is a short caption}
\end{figure}
\begin{table}[!htb]
\caption{This is a long table caption which splits across multiple lines. Dummy Text Dummy Text Dummy Text Dummy Text}
\centering
\begin{tabular}{ l | r }
\hline
1 & 2 \\
7 & 8 \\
\hline
\end{tabular}
\end{table}
\begin{table}[!htb]
\caption{This is a short caption.}
\centering
\begin{tabular}{ l | r }
\hline
1 & 2 \\
7 & 8 \\
\hline
\end{tabular}
\end{table}
\end{document}
答案1
就便利性而言,这可能对你有用,也可能没用,因为它不是自动化。但我尝试解决实际问题(关于 TOC、LOF 和 LOT)以及您对章节和节标题的评论跟进。在这两种情况下,我都使用堆栈来尝试解决问题。
\doublespacing
首先,直到 TOC、LOF 和 LOT 打印出来后我才会调用。
然后,对于 TOC、LOF 和 LOT,我使用可选参数\chapter
、\section
和在可选文本的末尾\caption
插入 a \stackunder{}{}
,这实际上为其下方的项目提供了双倍间距。如果您愿意重新定义这些分段/标题命令(我在这里不这样做),该过程可以自动化。
注意:我的回答目录中的多重间距与此问题相关。在那里,我展示了如何通过重新定义(在该示例中)来自动化该过程\section
。
为了处理报告本身的标题双倍行距问题,我在进入双倍行距模式时设置了适当的长堆叠间隙,然后使用左对齐的\Longunderstack
s 来构建单倍行距标题。但请注意,对于章节和较低级别的标题,堆叠将根据章节编号完全缩进,而不是换行到左边距(如章节 1.1 中所示)。
\documentclass[a4paper,12pt]{report}
\usepackage{setspace}
\usepackage{mwe} % just for dummy images
\usepackage[usestackEOL]{stackengine}
\setstackgap{L}{\baselineskip}
\def\stacktype{L}
\begin{document}
\addcontentsline{toc}{chapter}{Contents}
\tableofcontents
\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures
\listoftables
\addcontentsline{toc}{chapter}{List of Tables}
\doublespacing
\setstackgap{L}{.6\baselineskip}
\chapter
[Test Chapter with a very very very very long name which \\splits over multiple lines\stackunder{}{}]
{\Longunderstack[l]{Test Chapter with a very very\\ very very long name which \\splits over multiple lines}}
Lorem ipsum dolor sit amet, consectetuer Lorem ipsum dolor sit amet, consectetuer Lorem ipsum dolor sit amet, consectetuer Lorem ipsum dolor sit amet, consectetuer
\section
[This is a long section title which splits across multiple lines. Dummy Text Dummy Text Dummy Text Dummy Text\stackunder{}{}]
{\Longunderstack[l]{This is a long section title which splits\\ across multiple lines. Dummy Text\\ Dummy Text Dummy Text Dummy\\ Text}}
Lorem ipsum dolor sit amet, consectetuer Lorem ipsum dolor sit amet, consectetuer Lorem ipsum dolor sit amet, consectetuer Lorem ipsum dolor sit amet, consectetuer
\subsection{Another section title}
\begin{figure}[!htb]
\centering
\includegraphics[width=3cm]{example-image}
\caption
[This is a long figure caption which splits across multiple lines. Dummy Text Dummy Text Dummy Text Dummy Text\stackunder{}{}]
{This is a long figure caption which splits across multiple lines. Dummy Text Dummy Text Dummy Text Dummy Text}
\end{figure}
\begin{figure}[!htb]
\centering
\includegraphics[width=3cm]{example-image}
\caption{This is a short caption}
\end{figure}
\begin{table}[!htb]
\caption
[This is a long table caption which splits across multiple lines. Dummy Text Dummy Text Dummy Text Dummy Text\stackunder{}{}]
{This is a long table caption which splits across multiple lines. Dummy Text Dummy Text Dummy Text Dummy Text}
\centering
\begin{tabular}{ l | r }
\hline
1 & 2 \\
7 & 8 \\
\hline
\end{tabular}
\end{table}
\begin{table}[!htb]
\caption{This is a short caption.}
\centering
\begin{tabular}{ l | r }
\hline
1 & 2 \\
7 & 8 \\
\hline
\end{tabular}
\end{table}
\end{document}
答案2
我也遇到过类似的问题,但在网上找不到好的解决办法。最后,我修改了代码中的几行,找到了一种解决方法,可以用于我的论文提交。
序言中:
\usepackage{tocloft} % For table of contents formatting
\usepackage{setspace} % For spacing
%% Table of contents formatting
\renewcommand{\cftchapdotsep}{\cftdotsep} % Give chapters dots too
\renewcommand{\cftchapfont}{\normalfont} % Change to normal font
\renewcommand{\cftchapleader}{\normalfont\cftdotfill{\cftchapdotsep}}
\renewcommand{\cftchappagefont}{\normalfont}
\renewcommand{\contentsname}{TABLE OF CONTENTS}
\renewcommand{\cfttoctitlefont}{\normalfont\hfill}
\renewcommand{\cftaftertoctitle}{\hfill}
\renewcommand\cftchapafterpnum{\vskip 5pt} % for spacing after each entry
\renewcommand\cftsecafterpnum{\vskip 5pt} % for spacing after each entry
\renewcommand\cftsubsecafterpnum{\vskip 5pt} % for spacing after each entry
\renewcommand\cftsubsubsecafterpnum{\vskip 5pt} % for spacing after each entry
\setlength{\cftbeforetoctitleskip}{0in}
% List of figures formatting
\renewcommand{\listfigurename}{LIST OF FIGURES}
\renewcommand{\cftloftitlefont}{\normalfont\hfill}
\renewcommand{\cftafterloftitle}{\hfill}
\setlength{\cftbeforeloftitleskip}{0in}
\setlength\cftbeforefigskip{\cftbeforechapskip} % for spacing after each entry
% List of tables formatting
\renewcommand{\listtablename}{LIST OF TABLES}
\renewcommand{\cftlottitlefont}{\normalfont\hfill}
\renewcommand{\cftafterlottitle}{\hfill}
\setlength{\cftbeforelottitleskip}{0in}
\setlength\cftbeforetabskip{\cftbeforechapskip} % for spacing after each entry
在文档中:
% Generate the table of contents and end it with a new page
\begin{singlespace}
\tableofcontents{\normalsize}
\newpage
% Generate a list of figures, making sure to include a table of
% contents line for the list.
\addcontentsline{toc}{chapter}{LIST OF TABLES}
\listoftables
\newpage
\addcontentsline{toc}{chapter}{LIST OF FIGURES}
\listoffigures
\end{singlespace}
\newpage