[Tex/LaTex] How to align a set of multiline equations


I am trying to align a set of long equations, that are themselves align environments as most of them are spreading on multiple lines.

Currently I just have a sequence of align environments, with each equation inside in order to align the pieces of each equations. I am attaching a screenshot of the result:


What would like to get instead is something looking more like


which is the same set of equations after going through the copyediting office of a journal and looks much better.

Here is a MWE. I would like all three equations to align on the equal sign.


a & =  b + c + d \nonumber \\
  & \qquad + e + f + g
k & = l + m + n + m + n + m + n \nonumber \\
  & \qquad + o + p + q
r = s + t (u + v + w)

Best Answer

without an actual example, here's how i interpret what you want.

output of example code

and here is the input:

This example shows \verb|aligned| equations within
an \verb|align| environment.
  \phantom{i + j + k}
    \mathllap{a} &= b + c + d\\
      &\qquad + e + f + g + x + y + z
    \mathllap{i + j + k} &= l + m + n\\
      &\qquad + o + p + q

the longest left-hand element is inserted at the beginning as a \phantom and the lengths of the left-hand elements of the individual aligned segments are made "invisible" by lapping them to the left using \mathllap from the mathtools package.

the original answer was (correctly) noted to align the segments properly only when the left-hand sides had the same length. this modification overcomes that problem.

Related Question