7

I have three mathematical equations which I would like to have typeset in one block such that they are aligned at the equality sign = and the following comment. Up until now, I've been using eqnarray

\documentclass{article}

\usepackage{amsmath}

\begin{document}
\begin{eqnarray}
  \begin{aligned}
    aaa & = b   &\text{ in } Q\\
    c   & = d   &\text{ in } \Sigma\\
    e   & = fff &\text{ in } \Omega
  \end{aligned}
\end{eqnarray}
\end{document}

but I understand that this environment is obsolete (as per l2tabu).

What would be a better alternative?

2 Answers2

6

I think the following is what you are looking for:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{gather}
\begin{aligned}
  aaa &= b   &&\text{in $Q$}\\
  c   &= d   &&\text{in $\Sigma$}\\
  e   &= fff &&\text{in $\Omega$}
\end{aligned}
\end{gather}

\end{document}

output

Note the two consecutive ampersands (&&); this left-align the three "in .." blocks instead of align them to the right of the symbols.

P.S. Don't use eqnarray at all.

2

The not yet released tabstackengine package can do this. It was introduced at Writing a table with equally spaced columns, based on the widest column and the sty file can be found at Measuring align.

The package extends the macros of the stackengine package by adding tabbing commands.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tabstackengine}
\stackMath
\begin{document}
\begin{equation}
  \alignCenterstack{
    aaa & = b   &\text{ in } Q\\
    c   & = d   &\text{ in } \Sigma\\
    e   & = fff &\text{ in } \Omega
  }
\end{equation}
\end{document}

enter image description here