# Flush Text to the Left in an Unaligned Centered Equation

I am looking for a way to write several centered equations with a left-aligned text on each line. In other words, I would like to mix the functionality of flalign with gather (so the first column would be flushed left, while the second column would be centered), but I have not found a way to do so. Please help.

• Could we have a minimal (non-)working example? – Bernard Feb 11 '15 at 14:04
• Are the equations to be numbered? Are the centered equations "aligned" to some tab, or are each of the equations individually centered? – Steven B. Segletes Feb 11 '15 at 14:27

I had asked in a comment whether the centered equations were also aligned, since the approach differs in that case. So here, I show it using both equation and align environments, with my macro \addlefttext[textwidth-fraction]{left text}{equation}.

If using it with the equation environment, there is no need for the optional argument and one should enclose the full equation as the second mandatory argument.

With the align environment, there is some manual tuning, as one can only enclose the left-most field of the aligned equations as the second mandatory argument of \addlefttext. This means that the required leftward shift will depend on the eventual location of that left most align field.

The optional argument provides the fraction of \textwidth to shift the label leftward (relative to the right end of the first align field). The bad news is therefore, that the optional argument must be tuned to the particular align environment. However, the good news is that the tuned fraction is the same for each row of the align environment.

EDITED to remove need for ifthen package.

\documentclass{scrartcl}
\usepackage{stackengine,amsmath,lipsum}
\def\stacktype{L}\def\useanchorwidth{T}%
\ifdim#1pt<0pt\relax%
\def\stackalignment{c}%
\stackon[0pt]{$\displaystyle#3$}{\makebox[\textwidth][l]{#2}}%
\else%
\def\stackalignment{r}%
\stackon[0pt]{$\displaystyle#3$}{\makebox[#1\textwidth][l]{#2}}%
\fi%
}
\begin{document}
\lipsum[1]
$$\addlefttext{My text}{y = mx + b}$$
$$\addlefttext{My other text}{E = mc^2}$$
\lipsum[1]
\begin{align}
\addlefttext[.452]{My text}{y} &= mx + b\\
\end{align}
\end{document}


• Thank you. Your answer is suitable for some other situations I did not put in the original question as well. – Tunococ Feb 11 '15 at 22:50

You can use a variant of my answer to Aligning equations with left and right comment, adapted to flalign:

\documentclass{article}
\usepackage{amsmath}

\usepackage{lipsum}

\makeatletter
\newcommand{\Cen}[2]{%
\ifmeasuring@
#2%
\else
\makebox[\ifcase\expandafter #1\maxcolumn@widths\fi]{$\displaystyle#2$}%
\fi
}
\makeatother

\begin{document}

\lipsum*[2]
\begin{flalign}
&\text{Straight line} & \Cen{3}{y=mx+q}      && \\
&\text{Parabola}      & \Cen{3}{y=ax^2+bx+c} &&
\end{flalign}
\lipsum[3]

\end{document}