![\end{spacing} 后有不必要的空格](https://linux22.com/image/277097/%5Cend%7Bspacing%7D%20%E5%90%8E%E6%9C%89%E4%B8%8D%E5%BF%85%E8%A6%81%E7%9A%84%E7%A9%BA%E6%A0%BC.png)
这是我的乳胶文件:
\documentclass[11pt]{article}
\usepackage{setspace}
\begin{document}
\section*{Section 1}
\begin{spacing}{1.5}
Unnecessary\\
space\\
after\\
this1
\end{spacing}
\section*{Section 2}
Perfect\\
space\\
after\\
this2
\section*{Section 3}
\end{document}
这是输出:
我希望“this1”后面的空间和“this2”后面的空间一样大。如有任何帮助我将不胜感激。
答案1
spacing
您可以通过修改环境提供的环境来实现目标setspace
。这可以按照以下方式完成,即使用calc
包并更改环境结束时所做的事情spacing
。
\documentclass[11pt]{article}
\usepackage{setspace}
%% insert the following material in preamble
\usepackage{calc}
\newlength\modparskip
\newlength\modbaselineskip
\def\baselinestretch{1} % this parameter will be redefined at start of 'spacing' environment
\setlength\modparskip{\parskip/\real{\baselinestretch}}%
\setlength\modbaselineskip{\baselineskip/\real{\baselinestretch}}%
\makeatletter
\renewenvironment{spacing}[1]{\par%
\def\baselinestretch{#1}%
\ifx\@currsize\normalsize\@normalsize\else\@currsize\fi%
}%
{\par%
\vskip \modparskip% % originally: \vskip \parskip
\vskip \modbaselineskip% % originally: \vskip \baselineskip
}
\makeatother
%% end of material to be inserted in preamble
\begin{document}
\section*{Section 1}
\begin{spacing}{1.5}
Now also ``correct'' space after this1
\end{spacing}
\section*{Section 2}
Perfect space after this2
\section*{Section 3}
\end{document}