# Splitting and flushing equations inside align

MWE

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align}
&f = \text{here goes a very very very very very long equation} \nonumber
\\
&\hspace*{7.5cm} + \text{which will be split} \label{a}
\\
&xxx = \text{here goes another super long long equation} \nonumber
\\
&\hspace*{5cm} + \text{which continues on the second line} \label{b}
\end{align}

\end{document}


I need to manually align the two equations such that

• The first line of each is flushed left.
• The second line is flushed right and just next to its label (in the example, I use \hspace*{}). It does not have to be flushed wrt the above line.
• I can still align the two equations (in the example, the = are not aligned).
• These are still two separate equations, so I can assign labels.

I tried with split + equation and align + aligned, but then I cannot assign multiple labels. I also tried with split inside align but then I cannot align the =.

Many thanks.

• To have the equations flushed left, use \documentclass[fleqn]{article}. – user121799 Oct 7 '18 at 16:12

## 2 Answers

You can't have two distinct alignment points for the split equation, for the top row aligning with the left-hand side and the equation number aligning with the bottom row.

You can center the equation number, though.

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align}
\begin{split}
\label{a}
f   &=\begin{aligned}[t]
\text{here goes a very very very very very long equation}
\\
{} + \text{which will be split}
\end{aligned}
\end{split}
\\
\begin{split}
\label{b}
xxx &=\begin{aligned}[t]
\text{here goes another super long long equation}
\\
{} + \text{which continues on the second line}
\end{aligned}
\end{split}
\end{align}

\end{document}


Honestly, this kind of alignment doesn't appeal to me at all.

You can get your desired alignment with eqparbox:

\documentclass{article}

\usepackage{amsmath,eqparbox}

\newcommand{\meqbox}[2]{\eqmakebox[#1][r]{$\displaystyle#2$}}

\begin{document}

\begin{align}
f ={}& \meqbox{A}{\text{here goes a very very very very very long equation}} \notag
\\
& \meqbox{A}{{} + \text{which will be split}} \label{a}
\\
xxx ={}& \meqbox{B}{\text{here goes another super long long equation}} \notag
\\
& \meqbox{B}{{} + \text{which continues on the second line}} \label{b}
\end{align}

\end{document}


Each block should be assigned a distinctive key, here A and B. Go on with the alphabet if you need other similar objects.

An even worse realization, notwithstanding it seems what you'd like to get:

\documentclass{article}

\usepackage{amsmath,mathtools}

\begin{document}

\begin{flalign}
f &= \mathrlap{\text{here goes a very very very very very long equation}} && \notag
\\
&    &&&{} + \text{which will be split} \label{a}
\\
xxx &= \mathrlap{\text{here goes another super long long equation}} && \notag
\\
&    &&&{} + \text{which continues on the second line}  \label{b}
\end{flalign}

\end{document}


• Thanks, but I need to have the second line of each equation completely flushed to the right, ending close to (1) and (2), not aligned with the above line (that's why I use hspace in my example, but I would like to get rid of it). I will make the question clearer. – Simon Oct 7 '18 at 16:49
• @Simon Does the last version reflect the horrible thing you want to do? ;-) – egreg Oct 7 '18 at 18:11
• Ahaha yes, thanks! I know it is a bit ugly, but I believe that the equation I have to split looks better this way than otherwise :D – Simon Oct 7 '18 at 20:10

I'd use fleqn, drop the \hspaces and also set the alignment point to the equality sign to get

\documentclass[fleqn]{article}

\usepackage{amsmath}

\begin{document}

\begin{align}
f ={}& \text{here goes a very very very very very long equation} \nonumber
\\
&+ \text{which will be split} \label{a}
\\
xxx ={}& \text{here goes another super long long equation} \nonumber
\\
& + \text{which continues on the second line} \label{b}
\end{align}

\end{document}


You may increase the space between the = signs and \texts. solved by @egreg's comment.

• ={}& or the space is very wrong. – egreg Oct 7 '18 at 16:16
• @egreg Mille grazie! – user121799 Oct 7 '18 at 16:18
• Thanks, I know fleqn, but it flushes all equations the same. In my case, I need the first line to be flushed left, and the second to be flushed left (as much as possible, just next to the label number). – Simon Oct 7 '18 at 16:53