4

There are many discussions over how to align multiple align environments with interspersed texts. However, I want to label multiple aligned blocks such that each number will center vertically for each aligned blocks and at the same time align across blocks.

Here is a MWE that achieves either at one time. The first part simply uses one giant align environment with some \nonumber directive. The second one use equation to wrap aligned but lose alignment info. How should I achieve the best of both worlds?

\documentclass{article}
\usepackage{amsmath}
\begin{document}
  % Part I
  \begin{align}
          x^2 + y^2 &= 1 \\
                z^2 &= 0 \nonumber \\
    x^2 + y^2 + z^2 &= 1
  \end{align}

  % Part II
  \begin{equation}
    \begin{aligned}
      x^2 + y^2 &= 1 \\
            z^2 &= 0 \\
    \end{aligned}
  \end{equation}
  \begin{equation}
    \begin{aligned}
      x^2 + y^2 + z^2 &= 1
    \end{aligned}
  \end{equation}
\end{document}

MWE

2 Answers 2

3

I'm not sure, if I understood you correctly, but seems that split environment is what you looking for:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
  \begin{align}
    \begin{split}
      x^2 + y^2 &= 1 \\
            z^2 &= 0 
    \end{split}             \\
      x^2 + y^2 + z^2 &= 1
  \end{align}
\end{document}

gives

enter image description here

1
  • Thanks. If anything I learned, it would be that I should read amsmath's documentation rather than googling around! Jan 10, 2017 at 19:09
2

Here are two ways of correcting for the alignment:

  1. If the equations are fairly similar (with some terms missing), you can use \phantom.

  2. If the equations are very different, use a \phantom of the widest element, together with a math overlap.

enter image description here

\documentclass{article}

\usepackage{mathtools}

\begin{document}

% Part I
\begin{align}
        x^2 + y^2 &= 1 \\
              z^2 &= 0 \nonumber \\
  x^2 + y^2 + z^2 &= 1
\end{align}

% Part II
\begin{equation}%
  \!\begin{aligned}
    x^2 + y^2 &= 1 \\
    \phantom{x^2 + y^2 + {}}z^2 &= 0
  \end{aligned}%
\end{equation}

% Part II
\begin{equation}%
  \!\begin{aligned}
    x^2 + y^2 &= 1 \\
    \phantom{x^2 + y^2 + z^2}\mathllap{a^2 - b^2} &= 0
  \end{aligned}%
\end{equation}

\begin{equation}
  x^2 + y^2 + z^2 = 1
\end{equation}

\end{document}

A minor \! correction is required in front of aligned.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .