[Tex/LaTex] How to align two split environments at the equal signs

alignmath-mode

\documentclass{scrartcl}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{amsmath,  amsthm,  amssymb}
\usepackage{mathtools}

\begin{document}
    \begin{align}
        \begin{split}
            \label{eq:lines}
            Q_{1x} &= C_{1x} + \mu_1 \vec{h_{1x}} \\
            Q_{1y} &= C_{1y} + \mu_1 \vec{h_{1y}} \\
            \vdots \\
            Q_{3z} &= C_{3z} + \mu_3 \vec{h_{3z}}
        \end{split} \\
        \begin{split}
            \label{eq:distances}
            \overline{Q_1 Q_2}^2 &= (Q_{1x}-Q_{2x})^2 + (Q_{1y}-Q_{2y})^2 + (Q_{1z}-Q_{2z})^2\\
            \vdots
        \end{split}
    \end{align}
\end{document}

I want to align the equations in both split-environments along the "="-Symbol in the same way.
Any ideas?

Best Answer

All you need to do is to remember to put alignment signs & on all the lines in your splits (your code has none on the \vdots lines). Minimising your example gives:

\documentclass{scrartcl}

\usepackage{amsmath}

\begin{document}

\begin{align}
   \label{eq:lines}
   \begin{split}       
      Q_{1x} &= C_{1x} + \mu_1 \vec{h_{1x}} \\
      Q_{1y} &= C_{1y} + \mu_1 \vec{h_{1y}} \\
      \vdots& \\
      Q_{3z} &= C_{3z} + \mu_3 \vec{h_{3z}}
   \end{split} \\
   \label{eq:distances}
   \begin{split}        
      \overline{Q_1 Q_2}^2 &= (Q_{1x}-Q_{2x})^2 + (Q_{1y}-Q_{2y})^2 
                                      + (Q_{1z}-Q_{2z})^2\\
      \vdots&
   \end{split}
  \end{align}
\end{document}

Sample output

Now you need to decide how you want to place the \vdots...

Discussion

The documentation amsmath.pdf is not so clear about this structure saying

The split structure should constitute the entire body of the enclosing structure, apart from commands like \label that produce no visible material.

in the section "Split equations with alignment", in contrast to the description under gather

Any equation in a gather may consist of a \begin{split} ... \end{split} structure—...

However, the accompanying filed testmath.pdf contains two explicit examples of multiple splits within an align. What you can't do is enclose such a split construction inside e.g. a \left ... \right construction.

Note that there is the package breqn which contains code that allows complicated alignment between various blocks, but it alters fundamental constructions in math mode, and so has a number of compatibility issues.