![如何在“alignat”和“align”环境中全局减少或删除行之间的垂直间距?](https://linux22.com/image/461728/%E5%A6%82%E4%BD%95%E5%9C%A8%E2%80%9Calignat%E2%80%9D%E5%92%8C%E2%80%9Calign%E2%80%9D%E7%8E%AF%E5%A2%83%E4%B8%AD%E5%85%A8%E5%B1%80%E5%87%8F%E5%B0%91%E6%88%96%E5%88%A0%E9%99%A4%E8%A1%8C%E4%B9%8B%E9%97%B4%E7%9A%84%E5%9E%82%E7%9B%B4%E9%97%B4%E8%B7%9D%EF%BC%9F.png)
首先,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}