删除两个连续多行环境之间的垂直空格

删除两个连续多行环境之间的垂直空格

如何删除两个多行环境之间的额外垂直空间?事实上,我有一个两行方程式列表,我希望第二行向右对齐。所以我写:

\begin{multline*}
x =  1 +  2 \\ + 3 +4
\end{multline*}
\begin{multline*}
y =  a + b \\ + c + d
\end{multline*}

但是,两个方程之间的垂直间距太大。我尝试了使用对齐、聚集等不同的解决方案,但仍然无法使第二行向右对齐。前段时间,我定义了宏

\newcommand{\SplitEq}[1][0cm]{\hfill\strut\\[#1]\strut\hfill} 

它按我希望的方式工作,但只是在内联数学中,因此我必须手动添加换行符和垂直空格:

\\[1ex] $ x =  1 +  2 \SplitEq + 3 +4 $ \\
$y =  a + b  \SplitEq + c + d $ \\[1ex]

有人知道这个问题的解决方案吗?我对一些“自动”解决方案感兴趣,即如果可能的话,不需要指定例如 \phantom{x=1+2}。非常感谢您的帮助!

答案1

也许这接近您想要的?

\documentclass{article}%
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{showframe}
\renewcommand{\ShowFrameLinethickness}{0.3pt}
\usepackage{mathtools}

 \begin{document}

\begin{flalign*}
   & x = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10\\
 & & & & & \mathllap{{} + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20} \\
  & y = a + b + c + d + e + f + g +h \\
  & & & & & \mathllap{{} + a^2 + b^2 + c^2 +d^2 + e^2 + f^2 + g^2 + h^2}
\end{flalign*}

 \end{document} 

在此处输入图片描述

答案2

我建议您multlined在一个环境中使用两个环境gather*

在此处输入图片描述

\documentclass{article}

\usepackage{mathtools} % for 'multlined' environment
\setlength\textwidth{6cm} % just for this example
\begin{document}
\noindent
proposed form
\hrule
\begin{gather*}
\begin{multlined}
x =  1 + 2 + 3 + 4 + 5 +6 \\ +7+8+9+10+11+12
\end{multlined}\\
\begin{multlined}
y =  a + b + c + d + e + f + g\\ +h+i+j+k+m+n+o
\end{multlined}
\end{gather*}
\hrule

\bigskip\bigskip

\noindent
OP's original form:
\hrule
\begin{multline*}
x =  1 + 2 + 3 + 4 + 5 +6 \\ +7+8+9+10+11+12
\end{multline*}
\begin{multline*}
y =  a + b + c + d + e + f + g\\ +h+i+j+k+m+n+o
\end{multline*}
\hrule

\end{document}

相关内容