[Tex/LaTex] How to get this strange alignment

alignamsmathhorizontal alignment

I would like to get a nonstandard alignment in the following code:

\begin{align}
  \text{First left hand side}  & = \text{First right hand side} \\
  \text{Second left hand side} & = \text{Second right hand side} \\
    & = \text{Loooooooooooooooooooooooooooooooong expanded right hand side}
\end{align}

where the last line should not be aligned with the first two lines. I know that I could split the last line to form multiple right hand sides, but I would rather avoid it, as it would fill four equations in my case.

I found an evil way of doing it by nesting align and gather:

\begin{gather}
  \begin{align}
    \text{First left hand side}  & = \text{First right hand side} \\ %% \label{} does not work here
    \text{Second left hand side} & = \text{Second right hand side}
  \end{align}\\
 = \text{Loooooooooooooooooooooooooooooooong expanded right hand side} \label{eq3}
\end{gather}

but alas, while this gives the visual output I want, I can not use labels to refer to the equations within the align.

I also don't want to place & somewhere in the middle of the third line due to spacing issues, and because it is a fragile way of doing that.

So how can I type that

  1. the first and second line align at =
  2. the third line is not aligned ot the first two lines (preferably flushed right)
  3. all three lines are numbered, and can be referenced
  4. all three lines are in one equation group (for the semantics and the spacing)?

Best Answer

A bit of a low-level trick:

\documentclass{article}

\usepackage{amsmath}

\begin{document}
\begin{align}
  \text{First left hand side}  & = \text{First right hand side} \\
  \text{Second left hand side} & = \text{Second right hand side} \\
  \omit \span  = \text{Loooooooooooooooooooooooooooooooong expanded right hand side}
\end{align}
\end{document}

enter image description here

The above left aligns the last line. If you want the last line to be flush right, use (note order of the expression and \omit\span has changed)

\begin{align}
  \text{First left hand side}  & = \text{First right hand side} \\
  \text{Second left hand side} & = \text{Second right hand side} \\
  = \text{ expanded right hand side} \span \omit
\end{align}

which gives

enter image description here