# Split equations inside align environment with amsmath and mathtools

I am using split inside align to align two equations, one of which is the splitted in two lines:

\begin{align}
\begin{split}
X &= firstline =\\
&= secondline
\end{split}
XYZ &= rightside
\end{align}


The & inside split work together with the & outside, but unfortunately split allows to use only one &. How could I align X and XX as I were writing &X = and &XYZ =, and at the same time align the two lines of the splitted equation at the =?

I'm using mathtools, and I need both equations to be numbered. Ideally, first equation should be numbered on first line. The output should be:

|Some text and some other text|
|and more text.               |
|   |X = firstline =          |
|   |  = secondline      (5.3)|
|   |XYZ = rightside     (5.4)|
|Some text and some other text|
|and more text.               |


Thank you!

EDIT: I need the group of equations to be aligned at the center, and the equations to be relatively aligned to the left, exactly as in the example above. Also, I can't use global settings because in many case I want equations centered.

• you do not appear to want any alignment at all between the two equations, so just use gather and not align (you should never need to start an equation with &X=... Commented Apr 21, 2018 at 20:15

An aligned environment nested in an align solves the problem, if I understood well what you want:

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{align}
& \begin{aligned}X & = \text{first line} = \\
& = \text{second line}
\end{aligned} \\
& XX = \text{right side}
\end{align}

\end{document}


With the optional argument [b] for aligned, you obtain this layout of the equations numbers:

• Thank you, that's exaclty what I want! Is there any option to veryically align (1) to the second line? If not, however, this is perfect too Commented Apr 21, 2018 at 21:42
• Yes there is: aligned (or gathered or multlined) accepts an optional argument: [t], [c] (the default) or [b]. Commented Apr 21, 2018 at 22:23

Your requirements are not too clear but I think you are looking for

\documentclass{article}
\usepackage[fleqn]{amsmath}
\begin{document}
\begin{gather}
\begin{split}
X  &= firstline \\
&= secondline
\end{split} \\
XX = rightside
\end{gather}
\end{document}

• It's almost like this. The relative align between equations is right, but the group of equations should be centered. Commented Apr 21, 2018 at 21:38

Why are you using split for that?

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
X & = firstline =\notag\\
&= secondline \\
XX &= rightside
\end{align}
\end{document}


UPDATE: If you just want to have some equations left-aligned, you may use flalign (see here for more details)

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{flalign}
&   X  = firstline =\notag &\\
&     = secondline &\\
& XX = rightside&
\end{flalign}
\end{document}


• Because I didn't know about \notag and i was getting three equation numbers instead of two. Your solution is perfect, thank you! (EDIT: except that I need the equations aligned on left, so I have to add & at the beginning of each line) Commented Apr 21, 2018 at 20:05
• @Taekwondavide Does my answer give you all the information or do you want me to add something? (I personally like aligning at the equality sign better, and if you encounter a very bulky left-hand side, you can use \MoveEqLeft from the mathtools package.)
– user121799
Commented Apr 21, 2018 at 20:11
• EDIT 2: sorry, I was wrong, this does not solve the problem as I need the two equations aligned on left and not on the equal, so there can't be &= in the second one. Commented Apr 21, 2018 at 20:11
• @Taekwondavide if you want equations left aligned don't add & to start of each line (will make the text after the = right aligned) use the fleqn option to amsmath Commented Apr 21, 2018 at 20:12
• @DavidCarlisle is that a global or local setting? I usually need equations to be centered, except for a few cases... Commented Apr 21, 2018 at 20:15