1

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.

David Carlisle
  • 757,742
  • 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=... – David Carlisle Apr 21 '18 at 20:15

3 Answers3

2

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}

enter image description here

enter image description here

  • 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) – Taekwondavide Apr 21 '18 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.) –  Apr 21 '18 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. – Taekwondavide Apr 21 '18 at 20:11
  • 1
    @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 – David Carlisle Apr 21 '18 at 20:12
  • @DavidCarlisle is that a global or local setting? I usually need equations to be centered, except for a few cases... – Taekwondavide Apr 21 '18 at 20:15
  • @marmot thank you, I'll try that (I'm not at pc atm) and let you know – Taekwondavide Apr 21 '18 at 20:17
  • @Taekwondavide global (I'd already posted my answer:-) there are answers on site about using both layouts, I'll see if I can find... – David Carlisle Apr 21 '18 at 20:21
  • @Taekwondavide Sure. I added some info about flalign, which may be what you are looking for. –  Apr 21 '18 at 20:22
  • @DavidCarlisle Is this what you wanted to search for. Seems like the question and the answers have been edited by your twin brother ;-) (BTW, the OP is saying that the first equation should be numbered in its last line, and I am not sure if your answer accommodates that.) –  Apr 21 '18 at 20:27
  • @marmot It is logically wrong to not number the first like with \notag and just number the last, rather than number the split equation as a whole (even if the OP asks for that:-) – David Carlisle Apr 21 '18 at 20:31
  • @marmot no somewhere there is a patch to allow both the standard and flush left versions of the alignments. (the fl in flalign does not stand for flush left:-) – David Carlisle Apr 21 '18 at 20:33
  • @DavidCarlisle How is that logically wrong? If you have one long equation, it is IMHO perfectly fine to put the number at the end of the last line. And here there is another equation below the first one. –  Apr 21 '18 at 20:36
2

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

enter image description here

\documentclass{article}
\usepackage[fleqn]{amsmath}
\begin{document}
\begin{gather}
\begin{split}
    X  &= firstline \\
      &= secondline
\end{split} \\
  XX = rightside
\end{gather}
\end{document}
David Carlisle
  • 757,742
2

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

Bernard
  • 271,350
  • 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 – Taekwondavide Apr 21 '18 at 21:42
  • 1
    Yes there is: aligned (or gathered or multlined) accepts an optional argument: [t], [c] (the default) or [b]. – Bernard Apr 21 '18 at 22:23