0

I read this post: How to align a set of multiline equations

It works in some sense but my question seems a little different.

This is the print screen of the output that I need:

enter image description here

Note that the last few rows are quite longer than the formulas in the previous rows. This causes the problem. Here is the simplified code. The texts in the first two lines are aligned at the left, and are supposed to be above the formulas below, but not to the right, leaving blanks. I tried split environment with {}&, but it conflicts with aligned environment in it. Can anyone help? Thanks!

\documentclass{article}
\usepackage{mathtools,xcolor}
\begin{document}
\begin{align*}
A &=a+b && \textcolor{cyan}{\begin{aligned} & \text{This formula is correct.} \\ & \text{Continue from here.}\end{aligned}}\\
&=c+d && \textcolor{cyan}{\text{Not correct}} \\
&=e+f+g+h+i+j+k+l+m+n+o+p+q \\
&=1+2+3+4+5+6+7+8+9+10+11+12+13+14 \quad \text{OK}
\end{align*}
\end{document}
David Carlisle
  • 757,742

1 Answers1

1

You can use two alignments and a \phantom it's a bit easier if you use [fleqn] or as here the flalign environment so the left hand side is at the left margin.

enter image description here

\documentclass{article}
\usepackage{mathtools,xcolor}
\begin{document}
\begin{flalign*}
  A &=a+b && \textcolor{cyan}{\begin{aligned} & \text{This formula is correct.} \\
                                              & \text{Continue from here.}\end{aligned}}\\
    &=c+d && \textcolor{cyan}{\text{Not correct}}
\end{flalign*}
\vspace{\dimexpr-\abovedisplayskip-\belowdisplayskip}
\begin{flalign*}
\phantom{A}&=e+f+g+h+i+j+k+l+m+n+o+p+q \\
           &=1+2+3+4+5+6+7+8+9+10+11+12+13+14 &&\text{OK}
\end{flalign*}
\end{document}
David Carlisle
  • 757,742