2

Using the align or alignat environment, how do I achieve something that looks like the below?

enter image description here

I want the equations and equals signs to be, as usual, all nicely aligned at the center and also whatever custom text I want flushed left and right on both sides of each line, whenever I want it.

2
  • This is probably easier with tabularx instead of align. Commented Apr 20, 2018 at 2:41
  • @PeterGrill: How would I do that?
    – user158988
    Commented Apr 20, 2018 at 2:50

1 Answer 1

1

Here is an attempt with align* and tabularx:

enter image description here

Code:

\documentclass{article}
\usepackage{mathtools}
\usepackage{tabularx}
\usepackage{showframe}

\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}

\begin{document}
\noindent
With \verb|align*|
\begin{align*}
    &\text{Hi}        &    1+1 &=2  &\text{I}                                 \\
    &\text{can have}  &  1+1+1 &=2  &\text{whatever text}                     \\
    &\text{I like}    &      1 &=1  &\text{flushed left}                      \\
    &\text{and right} &      1 &=1  &\text{with tabularx, equation at center} \\
\end{align*}
%
With \verb|tabularx*| (left and right columns of same size)
\medskip\par\noindent
\begin{tabularx}{\linewidth}{@{}X r@{}l Y@{}}
    Hi         & $1+1    $ & ${}=2$ & I                                 \\
    can have   & $1+1 +1 $ & ${}=2$ & whatever text                     \\
    I like     & $1      $ & ${}=1$ & flushed left                      \\
    and right  & $1      $ & ${}=1$ & with tabularx, equation at center \\
\end{tabularx}
\end{document}

You must log in to answer this question.