首先,MWE 及其输出如下。
\documentclass{article}
\usepackage{amsfonts,amssymb,amsmath}
\begin{document}
An example in `alignat'
\begin{alignat*}{2}
x&=3&\hspace*{1em}&why\\
&=2+1&&so\\
x&=3&\hspace*{1em}&why\\
&=2+1&&so\\
x&=3&\hspace*{1em}&why\\
&=2+1&&so.
\end{alignat*}
and an example in `align'
\begin{align*}
x&=3\\
&=2+1\\
x&=3\\
&=2+1\\
x&=3\\
&=2+1.
\end{align*}
and an example in `array'
\[
\begin{array}{rl}
x&=3\\
&=2+1\\
x&=3\\
&=2+1\\
x&=3\\
&=2+1.
\end{array}
\]
\end{document}
如你所见,和环境中的x=3
和等行之间的垂直间距比环境中的要大。然后2+1
alignat
align
array
如何全局减少或删除alignat
和align
环境中行之间的垂直空格?
答案1
详细阐述@daleif 的评论,我提出以下内容并希望这对您来说足够接近。
\documentclass{article}
\usepackage{amsmath}
%%%Set some lengths to zero.
\setlength{\jot}{0pt}
%\setlength{\abovedisplayskip}{0pt}
%\setlength{\belowdisplayskip}{0pt}
%\setlength{\abovedisplayshortskip}{0pt}
%\setlength{\belowdisplayshortskip}{0pt}
% Save all variants into boxes to measure their heights.
\newsavebox{\alignatbox}
\savebox{\alignatbox}{%
\begin{minipage}{\linewidth}%
\begin{alignat*}{1}%
x&=3\\&=2+1\\x&=3\\&=2+1\\x&=3\\&=2+1.%
\end{alignat*}%
\end{minipage}
}
\newsavebox{\alignbox}
\savebox{\alignbox}{%
\begin{minipage}{\linewidth}%
\begin{align*}{2}%
x&=3\\&=2+1\\x&=3\\&=2+1\\x&=3\\&=2+1.%
\end{align*}%
\end{minipage}
}
\newsavebox{\arraybox}
\savebox{\arraybox}{%
\begin{minipage}{\linewidth}%
\[%
\begin{array}{rlll}%
x&=3\\&=2+1\\x&=3\\&=2+1\\x&=3\\&=2+1.%
\end{array}%
\]
\end{minipage}
}
\begin{document}
\paragraph{An example in `alignat'.}
height: \the\ht\alignatbox\par
\usebox{\alignatbox}
\paragraph{An example in `align'.}
height: \the\ht\alignbox\par
\usebox{\alignbox}
\paragraph{An example in `array'.}
height: \the\ht\arraybox\par
\usebox{\arraybox}
\end{document}