# Right align text in align environment, while keeping maths centered

I use text at some lines of an align environment to justify how we go from one line to another. I would like to keep the maths centered, and text to be aligned to the right, but I did not succeed:

  \begin{align}
a &= bbbbbb &\nonumber \\
cccc  & =  dd & \text{(using Eq. 1)} & \nonumber \\
e &= f & \text{(using Thm. 2)}
\end{align}


gives which is OK for the maths, but not for the text as it is not completely at the end of the lign.

Using the flalign environement instead aligns the math equations to the left, while I'd like to keep them centered.

What is the cleanest way to achieve this ?

• Will there be several texts (on different lines) in this multiline equation? Aug 30, 2019 at 11:34
• @Bernard Yes, sorry, I have edited my question with a more representative example Aug 30, 2019 at 11:39

I propose one of these two dolutions, both based on the flalign environment:

\documentclass{article}
\usepackage{mathtools}
\usepackage{eqparbox}
\usepackage[showframe]{geometry}

\begin{document}

\begin{flalign}
& & a &= bbbbbb &\nonumber \\
& & cccc & = dd & \text{(using Eq. 1)} & \nonumber \\
& & e &= f & \text{(using Thm. 2)}
\end{flalign}

\begin{flalign}
& & a &= bbbbbb \nonumber \\
& & cccc & = dd & \eqparbox{C}{(using Eq. 1)} & \nonumber \\
& & e &= f & \eqparbox{C}{(using Thm. 2)}
\end{flalign}

\end{document}


In order to center the equations you need to make the text not to occupy any space. This has the consequence that you can't align the texts to the right (but this is good, as we read from left to right).

The \zerotext command accepts an optional argument to avoid overlapping (shown in the last example).

\documentclass{article}
\usepackage{amsmath}

\usepackage{showframe} % just for the example

\begin{document}

% for checking alignment
\begin{align}
a     &= bbbbbb \nonumber \\
cccc  &= dd     \nonumber \\
e     &= f
\end{align}

\begin{alignedat}[b]{2} a &= bbbbbb & \\ cccc &= dd & \zerotext{(using Eq. 1)} \\ e &= f & \zerotext{(using Thm. 2)} \end{alignedat}

\begin{alignedat}[b]{2} a &= bbbbbb+cccccccccc & \\ cccc &= dd & \zerotext[4em]{(using Eq. 1)} \\ e &= f & \zerotext[4em]{(using Thm. 2)} \end{alignedat}

\end{document}