[Tex/LaTex] Split equations inside align environment with amsmath and mathtools

alignamsmathequationsmathtools

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.

Best Answer

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} 

enter image description here

Added:

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

enter image description here