How can I align two split environments at the equal signs?
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}
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.
Ok, I have to admit, I have no idea why this worked, just wanted to add an example using the \vdotswithin{}
from mathtools
and all of a sudden the =
's aligned. I also changed the \vec
to only go over the h
's.
\documentclass{scrartcl}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{amsmath, amsthm, amssymb,mathtools}
\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} \\
&\vdotswithin{=} \\
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\\
&\vdotswithin{=}
\end{split}
\end{align}
\end{document}
You need aligned
instead of split
:
\documentclass{scrartcl}
\usepackage{amsmath}
\newlength{\templen}
\begin{document}
\settowidth{\templen}{$\displaystyle\overline{Q_1 Q_2}^2$}
\begin{align}
\label{eq:lines}
&\begin{aligned}
\makebox[\templen][r]{$\displaystyle 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{aligned} \\
\label{eq:distances}
&\begin{aligned}
\overline{Q_1 Q_2}^2 &= (Q_{1x}-Q_{2x})^2 + (Q_{1y}-Q_{2y})^2 + (Q_{1z}-Q_{2z})^2\\
\vdots
\end{aligned}
\end{align}
\end{document}
The \templen
width can be reused at will. It must be set outside the align
environment.