4

How can I remove the additional vertical space between two multline environments? In fact, I have a list of two-line-equations and I want the second line aligned to the right. So I write:

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

However, there is too much vertical space between the two equations. I tried different solutions using aligned, gathered, ... but I still can not get the second line aligned to the right. Some time ago I defined the macro

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

which works as I would like it to work but just in inline math so that I have to add line breaks and vertical spaces manually:

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

Does anybody know any solution to this problem? I am interested in some "automatic" solutions, i.e. not requiring to specify e.g. \phantom{x=1+2}, if possible. Thank you very much for your help!

5
  • 2
    welcome to tex.sx. mathtools has a multlined environment, so two of them could be included within a single gather* environment. that might actually need a little extra space added between them. – barbara beeton Mar 8 '18 at 18:17
  • Welcome to TeX SX! Are these examples representative? I don't understand what you're trying to achieve exactly. – Bernard Mar 8 '18 at 18:18
  • 1
    These are just examples, my equations are much longer. I would like to have a list of equations such that every odd equation is aligned to the left and every even to the right. The multlined environment sounds like what I want, I will give it a try. Thanks! – Pavel Mar 8 '18 at 18:22
  • @barbarabeeton - Just after I posted my answer, I noticed that you'd written a comment with the exact same solution suggestions. If you want to post your comments as an answer, I'd be happy to delete my answer. – Mico Mar 8 '18 at 18:24
  • @Mico -- you've got good examples, so keep it. – barbara beeton Mar 8 '18 at 18:28
2

Maybe this is is close to what you want?

\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} 

enter image description here

4
  • Yes, the result looks like what I want, thank you! However, I need some time to understand how this works... – Pavel Mar 8 '18 at 18:57
  • Doesn't it work just with & & instead of & & & & & and without {} ? – Pavel Mar 8 '18 at 19:06
  • It's quite simple: flalign* has three columns, flushleft , middle and flushright, each with its own alignment point. There's nothing in the middle column, as you can see, and the supplementary trick is the use \mathllap from mathtools, which places its maths flushright as though it had 0 width, in case the left and right parts vertically overlap. – Bernard Mar 8 '18 at 19:14
  • @user32817: You're right, it works with onlythree & (the number of them for n columns has to be 2n -1), but I'm not sure it works for shorter lines. As to the {}+, it is to make + a binary operator , not a unary one, at the beginning of a line: they use a different spacing. – Bernard Mar 8 '18 at 19:18
5

I suggest you use two multlined environments inside a gather* environment.

enter image description here

\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}
2
  • I would like to have the second case without the vertical space in the middle. My equations are namely longer and I find it better when the second equation is aligned to the right. – Pavel Mar 8 '18 at 18:25
  • @user32817 - Having longer equations is not a problem for the multlined environments. I've modified the code to feature "longer" equations. – Mico Mar 8 '18 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.