[Tex/LaTex] Emulate \hfill in LaTeX equations

alignequationshorizontal alignment

I have a set of equations, where each line consists of a formula and an explanation (info about indices). Now, let's say the structure looks like this:

\newcommand{\lw}{\linewidth}
\begin{align*}
    &\framebox[0.4\lw]{Formula 1} & \framebox[0.3\lw]{Info 1}& \\
    &\framebox[0.7\lw]{Formula 1} & \framebox[0.1\lw]{Info 1}& \\
    &\framebox[0.5\lw]{Formula 1} & \framebox[0.2\lw]{Info 1}&
\end{align*}

This results in two columns of widths 0.7\lw and 0.3\lw, so the equation will be too wide for the page: output of the example code (too wide)

Yet, no single line is wider than 0.8\lw, so there is enough space if the two columns could "slide into each other", like this: desired output

In essence, I need some equiv. of \hfill between the two parts – but \hfill does not work here…

My question is whether there is a way to do this, i.e. to create a flexible space that would keep the left and right aligns. Note that the first align would typically be somewhere inside the formula, not in front of it.

Best Answer

I wouldn't put the conditions flush right, but if you really insist, you can use flalign:

\begin{flalign*}
\qquad A&=\mathrlap{B} &\text{condition}\\
\qquad C&=\mathrlap{D} &\text{cond}\\
\qquad E&=\mathrlap{F} &\text{some longer condition}
\end{flalign*}

Change the \qquad into some other spacing command that suits your needs.

This needs the package mathtools

Related Question