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.

  • This is probably easier with tabularx instead of align. – Peter Grill Apr 20 '18 at 2:41
  • @PeterGrill: How would I do that? – dtcm840 Apr 20 '18 at 2:50
2

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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.