# Align text equation and math equation

How do align an textual equation with the mathematical expression under it?

Some text before          Sum = Summand + Summand * Factor of Eternity
x  =    a    +    b    *        c


I currently got this:

\documentclass[a4paper]{article}
\usepackage{amsmath}
\begin{document}

\begin{flalign*}
\text{Text before} && Sum & = \text{Summand + Summand * Factor of Eternity} & \\
&& x & = a + b * c &
\end{flalign*}

\end{document}


A combination of alignat and flalign would be something im looking for.

-
Why don't you write on the right hand side \text{Summand}&+&\text{Summand}&*&\text{Factor of eternity}. Isn't this working as intended? Of course you need to add some & in the second line – Quickbeam2k1 Apr 8 '14 at 9:01

## 3 Answers

Why don't use a tabular?

Code

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{array}

\begin{document}

\noindent
\begin{tabular}{p{2cm}c@{$\;=\;$}c@{$\;+\;$}c@{$\;*\;$}c}
Text before & Sum &  Summand &  Summand & Factor of Eternity \\
& $x$ &  $a$ & $b$ & $c$
\end{tabular}

\end{document}

-
Thank you! I didn't know about this. Have a nice day – Buni Apr 8 '14 at 9:20
@EBeyer You're welcome. Happy it helped. – karlkoeller Apr 8 '14 at 9:28
Is there a way to get the = aligned to some other equations around this one? I did it with adjusting the 2cm property, but I need to readjust everytime i change the outer equations then. – Buni Apr 8 '14 at 9:28
Insert them inside the tabular. – karlkoeller Apr 8 '14 at 9:29
Two niggling comments: 1) "Text before" is not left aligned; and 2) If you compare the results in \noindent \begin{tabular}{p{2.68cm}c@{$\;=\;$}c@{$\;+\;$}c@{$\;*\;$}c} & $x$ & $a$ & $b$ & $c$ \end{tabular} \par\noindent $\hspace{3.32cm}x = a +b * c$, you will see that the spacing of your relation is not the same as LaTeX math. Just sayin'... – Steven B. Segletes Apr 8 '14 at 13:35

Just for completeness, here's the way it is done with a TABstack.

The \TABbinary tells the stack components to assume that there are operands on the far side of the & and thus for any adjacent operators (e.g., = and +) to allow proper math space for them. The default is \TABunaryLeft which would tell a + following a & to consider itself as a positive sign rather than an addition operator (in this case though, we want &+& to be considered as an addition operator). Of course, these settings can be manually overridden in the usual way: {+} to force unary, and {}+{} to force binary.

The gap between the rows (default 3pt) can be changed with an optional argument to \tabbedstackunder, as in \tabbedstackunder[6pt]{...}{...}

\documentclass{article}
\usepackage{tabstackengine}
\usepackage{amsmath}
\stackMath
\begin{document}
\noindent Some text before$\qquad$\TABbinary\tabbedstackunder
{\text{Sum}&=&\text{Summand} &+&\text{Summand}&*&\text{Factor of Eternity}}
{x&=&a&+&b&*&c}
\end{document}


-

I'd suggest to use a matrix within your displayed math environment:

\documentclass[a4paper]{article}
\usepackage{amsmath}
\begin{document}

\begin{flalign*}
\begin{matrix}
\text{Text before} & \text{Sum} & = &\text{Summand} &+& \text{Summand}& *& \text{Factor of Eternity}  \\
& x & = &a &+& b &*& c
\end{matrix}
\end{flalign*}

\end{document}


That way you have a single displayed math environment for parts that belong together, and you won't get into trouble when you need equation numbers for such constructions at some point.

If you feel that the spaces between the columns are to wide you can adjust them by using

\arraycolsep 1pt


between \begin{flalign*} and \begin{matrix}.

-