1

I have a problem with multline inside gather.

I already found this old question (multline inside gather?) on the topic, but the answer I got does not really satisfy me.

The problem of using multlined inside gather is that it is not possible to get the nice effect that we get from multline, namely that the second line is shifted toward the right side of the page (at least that's what happens to me).

\documentclass{article}

\usepackage{mathtools}
\usepackage{amsmath}

\makeatletter
\newcommand{\mathleft}{\@fleqntrue\@mathmargin0pt}
\newcommand{\mathcenter}{\@fleqnfalse}
\makeatother

\begin{document}

%%% Multline
\begin{multline*}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\%
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\end{multline*}
%
\vspace{-1cm}
%
\begin{multline*}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\%
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\%
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\end{multline*}



%%% Gather + Multlined
\begin{gather*}
\begin{multlined}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\%
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\
%
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\%
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\%
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\end{multlined}
\end{gather*}

%%% Gather + Multlined + mathleft
\mathleft
\begin{gather*}
\begin{multlined}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\%
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\
%
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\%
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\%
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\end{multlined}
\end{gather*}

\end{document}

From this piece of code it can indeed be noticed that in the first case, when there is multline, we obtain this nice effect (the second line is aligned to the left, and in the case of a three line objects, it is centered, with the third left-aligned). On the contrary, this is not the case with gatherplus multlined, even when we add \mathleft.

  1. Is there a way to obtain this effect with multlined inside gather?
  2. If not, how can I reduce the space between the two multline I am writing down?

Any feedback is most welcome.
Thank you for your time.

  • 1
    You'll probably get more help if you provide a minimal example, that others can copy and test out. – daleif Sep 23 '16 at 9:27
  • @daleif: I do not really agree, in the sense that this is not a specific problem of my piece of code, but it is something general. Indeed, the question I linked does not provide a piece of code, for this very reason. Anyway, part of what I got derived from the fact that I was using mathleft. Still, the question stands. – Kolmin Sep 23 '16 at 9:31
  • 1
    @daleif: I made a search on metatex on why MWE are used so extensively, and I found this (meta.tex.stackexchange.com/questions/3386/…), which made me see the point of it (indeed, I inserted the MWE). Again, thanks for your feedback, even more so, for having me realize what is the real point of having a MWE. – Kolmin Sep 23 '16 at 10:06
  • 2
    See it as the cost of getting help – daleif Sep 23 '16 at 10:20
  • 2
    In general I want all the lines aligned or aligned and indented, not centered or right aligned. IMO this gives a better structure on the page. I tend to follow the recommendations from this: ftp.ams.org/pub/author-info/documentation/howto/… (section 3.3.5), here \MoveEqLeft from mathtools is very handy. – daleif Sep 23 '16 at 11:15
3

both multline and multlined rely on \multlinegap (defined in amsmath with a default value of 10pt). however, they use this dimension differently.

for multline it is the distance from the margin to the leftmost edge of the first line or to the rightmost edge of the last line. if both those lines are short, there can be a big horizontal gap in the middle of the display.

for multlined it is the distance that the first and last lines do not overlap. for this purpose, 10pt is very tiny, almost not noticeable.

\multlinegap can be reset, but it needs to be done with attention to the environment in which it is to be used. it must be reset outside the affected environment. for multline, the effect is global, and must be limited if it is not to persist; for multlined, however, it can be set within the enclosing display environment, effectively making the change local.

\documentclass{article}
\usepackage{mathtools}
\begin{document}

default \verb+\multlinegap+ (10pt)
\begin{multline*}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\end{multline*}

increase the value of \verb+\multlinegap+ from (default) 10pt to 2cm.
{\multlinegap=2cm
\begin{multline*}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\end{multline*}
}% end of enlarged \multlinegap

%%% Gather + Multlined
default \verb+\multlinegap+ (10pt)
\begin{gather*}
\begin{multlined}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\end{multlined}
\end{gather*}

increase the value of \verb+\multlinegap+ from (default) 10pt to 2cm.
\begin{gather*}
\multlinegap=2cm
\begin{multlined}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\end{multlined}
\end{gather*}

default \verb+\multlinegap+ (10pt)
\begin{gather*}
\begin{multlined}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\end{multlined}
\end{gather*}

\end{document}

enter image description here

observe that the first two lines of a multlined group are closer together vertically than additional lines in a group of more than two lines. this appears to be a bug in multlined that should be investigated.

edit:
here is a further example in which two multlined groups are combined into a single gather. the width of each multlined is set to the full \textwidth using the option provided by that environment; this width can, of course, be set to any value desired by the user. finally, to overcome the uneven vertical spacing observed in the examples shown above, the space between the second and third lines of the first multlined group is decreased by \jot, the unit used by amsmath to control the spacing in multiline structures. (an effort to determine what is causing the difference in spacing has yielded no useful information, hence the application of the workaround.)

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{gather*}
\begin{multlined}[\textwidth]
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\[-\jot]
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\end{multlined}\\
\begin{multlined}[\textwidth]
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\end{multlined}
\end{gather*}
\end{document}

output of example code

  • Thanks for the answer. Though, I don't think it actually answer my question, in the sense that it seems to me it deals mainly with vertical spacing, while my issue is on the horizontal behavior of the lines (see the very last comment of mine below the question: i.e what I am would like to achieve is to have – in gather - two long (!) equations leftaligned, and divided in such a way that the second line (second and third in the other example) behaves as in multline, that is right-aligning (in the other example, centering & left-aligning)). Thanks anyway! – Kolmin Sep 24 '16 at 11:30
  • @Kolmin -- perhaps the further example is closer to what you want. – barbara beeton Sep 24 '16 at 13:20
  • Well, super thanks a lot! Actually this is superclose to what I was looking for. I see the point of using \textwidth, which pretty much makes the job. At the same time, though, I think this is what makes the result not exactly what I was looking for, in the sense that this command should force the equation to take the entire space given by a line, which is a bit of a stretch (in particular in the example with only two lines), while I would like to get everything left-aligned, but without taking the entire line. Still, this is really superclose, and I have the feeling... – Kolmin Sep 24 '16 at 15:08
  • ... it is not really possible to get closer without messying around heavilty with the code. Again, thanks a lot! :) – Kolmin Sep 24 '16 at 15:08

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.