减少用户定义环境中的行距

减少用户定义环境中的行距

我的文档中有很多图表和表格,我创建了两个命令\source\notes来格式化图表/表格的源并添加任何注释(请参阅 MWE)。正文有双倍行距,如何在我新定义的环境中将行距减少到一半或单倍行距\notes

\documentclass[a4paper, 12pt]{report}

\usepackage[english,frenchb]{babel}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{subcaption}

\linespread{1.6} %Setting double spacing for document

%---- Create 'source' and 'notes' commands ----%
\newcommand{\source}[1]{\vspace{-1.5em}
\captionsetup{justification=justified} \caption*{\raggedright\textnormal{\footnotesize{\textit{#1}}}}}

\newcommand{\notes}[1]{\vspace{-0.5em} 
% Would like 1.5 spacing for 'notes' environment
\captionsetup{justification=justified} \caption*{\textnormal{\scriptsize{\textit{#1}}}}}

\linespread{1.6}

\begin{document}

\begin{figure}[h!]
\begin{center}
\caption{A figure}
\resizebox{!}{70mm}{\includegraphics{{example-image-a}}}
\end{center}
      \source{Source : source of figure.}
      \notes{Notes : Some very long notes spread over several lines of which I would like to reduce linespacing. Some very long notes spread over several lines of which I would like to reduce linespacing. Some very long notes spread over several lines of which I would like to reduce linespacing. Some very long notes spread over several lines of which I would like to reduce linespacing.}
\end{figure}

Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. Lots and lots of text. 

\end{document}

答案1

只需将\linespread{0.0}(单倍行距,或任何其他您喜欢的数字)添加到\notes宏的定义中即可。

\documentclass{report}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{lipsum}

\linespread{1.6}

\newcommand{\source}[1]{%
    \vspace{-1.5em}%
    \captionsetup{justification=justified}%
    \caption*{\raggedright\footnotesize\textit{#1}}%
}

\newcommand{\notes}[1]{%
    \linespread{0.0}\vspace{-0.5em}%
    \captionsetup{justification=justified}%
    \caption*{\scriptsize\textit{#1}}%
}

\begin{document}

\begin{figure}[h!]
    \begin{center}
        \caption{A figure}
        \includegraphics[height=70mm]{example-image-a}
    \end{center}
    \source{Source : source of figure.}
    \notes{Notes : \lipsum[1]}
\end{figure}

\lipsum[2]

\end{document}

在此处输入图片描述

答案2

将格式说明添加到\captionsetup并使用setspace。请注意\linespread{1.6}本质上与 相同\doublespacing

\documentclass[a4paper, 12pt]{report}

\usepackage[english,frenchb]{babel}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{subcaption}
\usepackage{setspace}

\doublespacing

%---- Create 'source' and 'notes' commands ----%
\newcommand{\source}[1]{%
 \begingroup
 \captionsetup{justification=raggedright,font={footnotesize,it,onehalfspacing}}%
 \caption*{#1}%
 \endgroup
}

\newcommand{\notes}[1]{%
  \begingroup
  \captionsetup{justification=justified,font={scriptsize,it,onehalfspacing}}%
  \caption*{#1}%
  \endgroup
}

\begin{document}

\begin{figure}[htp!]
\centering
\caption{A figure}
\includegraphics[width=70mm]{example-image-a}

\source{Source : source of figure.}
\notes{Notes : Some very long notes spread over several lines of which 
  I would like to reduce linespacing. Some very long notes spread over
  several lines of which I would like to reduce linespacing. Some very
  long notes spread over several lines of which I would like to reduce
  linespacing. Some very long notes spread over several lines of which
  I would like to reduce linespacing.}
\end{figure}

Lots and lots of text. Lots and lots of text. Lots and lots of text. 
Lots and lots of text. Lots and lots of text. Lots and lots of text. 
Lots and lots of text. Lots and lots of text. Lots and lots of text. 
Lots and lots of text. Lots and lots of text. Lots and lots of text. 
Lots and lots of text. Lots and lots of text. Lots and lots of text. 
Lots and lots of text. Lots and lots of text. Lots and lots of text. 
Lots and lots of text. 

\end{document}

在组中执行此操作将使设置变得本地化。

在此处输入图片描述

相关内容