6

The code

\documentclass{article}
\usepackage{mathtools}
\begin{document}
  \begin{align*}
  f(1) &= g(1) + g(2) + g(3) \\
  f(1) &= g(1) + g(2) + g(3) \\
  f(1) &= \!\begin{multlined}[t]g(1) + g(2) + g(3) + g(1) + g(2) + g(3)\\
          g(1) + g(2) + g(3) + g(1) + g(2) + g(3) 
          \end{multlined}
          \\
  f(1) &= g(1) + g(2) + g(3) \\
  f(1) &= g(1) + g(2) + g(3) 
  \end{align*}
\end{document}

produces output

I looked in the mathtools's code and could not see how to set things up so that the vertical spacing between multlined lines is exactly the same as between other amsmath constructs. I know I can say \\[10pt] to adjust one instance, but I'd like to set this up once and for all for all multlineds in the whole document.

Any ideas?

  • 1
    I don't know either, but I think it is better for an easy understanding of the equations: a multlined environment semantically corresponds to a block that one has to split because there's not enough horizontal space, so the corresponding lines do not have the same status as the other lines, individually. – Bernard May 11 '17 at 0:54
  • I understand that is the intention, but I find it more distracting than helpful —and the lines look way too cramped, in my opinion. I prefer to have the horizontal spacing as a cue of logical grouping in this situation. – Mariano Suárez-Álvarez May 11 '17 at 8:41
  • In this case, I believe aligned has the usual spacing, and you can align this group by the right side, for instance. – Bernard May 11 '17 at 8:45
  • That works if the multlined has only two lines, and only then. It usually doesn't. – Mariano Suárez-Álvarez May 11 '17 at 9:07
  • It is known that multlined has certain spacing issues that are not that easy to point point. I hardly ever use any of the multlined stuff and they end up having a very inconsistent look. – daleif May 11 '17 at 11:27
4

This might help

\usepackage{mathtools}
\MHInternalSyntaxOn
\def\MT_mult_invisible_line: {
  \crcr
  \global\MH_set_boolean_F:n {mult_firstline}
  \hbox to \l_MT_multwidth_dim{}\crcr
  \noalign{
    \vskip-\baselineskip 
    %\vskip-\jot 
    \vskip-\normallineskip
  }
}
\MHInternalSyntaxOff

Not quite sure why \jot was added in the first place, probably because of spreadlines.

  • Just to nag: Could the \! spacing issue be removed from mathtools, now that amsmath got rid of it? Or has it already happened and I didn't notice it? – campa May 11 '17 at 11:48
  • @campa it is on my top list. But did amsmath actually got rid of it for aligned? I had not noticed – daleif May 11 '17 at 11:57
  • 1
    Yep, see here. – campa May 11 '17 at 12:09
  • @campa good, though, not sure if the hspace issue in multline is the same. I'll have a look before the next release – daleif May 11 '17 at 12:16
  • @campa turns out to be a walk in the park to fix. Until release you can use this (requires etoolbox): \makeatletter \MHInternalSyntaxOn \ifpatchable{\MT_mult_internal:n}{% \MH_if_boolean:nF {outer_mult}{\null\,}% }{ \patchcmd{\MT_mult_internal:n}{% \MH_if_boolean:nF {outer_mult}{\null\,}% }{% \MH_if_boolean:nF {outer_mult}{\alignedspace@left}% }{ \typeout{patched} }{ \typeout{patch failed} } }{\typeout{no, not patchable}} \MHInternalSyntaxOff \makeatother – daleif May 22 '17 at 8:41
2

Here, I substituted the multilined with a \Longunderstack, where you can set the interline baselineskip explicitly with \setstackgap{L}{...}. I loaded tabstackengine (instead of stackengine), in case you wanted to employ additional tabbing features in your stacks.

\documentclass{article}
\usepackage{mathtools,tabstackengine}
\stackMath
\setstackgap{L}{\baselineskip}
\begin{document}
  \begin{align*}
  f(1) &= g(1) + g(2) + g(3) \\
  f(1) &= g(1) + g(2) + g(3) \\
  f(1) &= \Longunderstack[l]{ g(1) + g(2) + g(3) + g(1) + g(2) + g(3)\\
          \quad g(1) + g(2) + g(3) + g(1) + g(2) + g(3) 
          }
          \\
  f(1) &= g(1) + g(2) + g(3) \\
  f(1) &= g(1) + g(2) + g(3) 
  \end{align*}
\end{document}

enter image description here

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.