# Aligning equations with alignat and vertical dots

I'm trying to get this result However, I'm very new and don't even know where to start with using alignat or making the vertical dots, thank you.

## 2 Answers

Like this? With use of the directive \vdotswithin{...} from ˙\mathtools package:

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\begin{alignat*}{5}
a_{11}x_1 & +{} & a_{12}x_2 +{} & \dotsm              &{} +  a_{1n}x_n & = b_1   \\
a_{21}x_1 & +{} & a_{22}x_2 +{} & \dotsm              &{} +  a_{2n}x_n & = b_2   \\
&     &               & \vdotswithin{\dotsm}&         \\
a_{m1}x_1 & +{} & a_{m2}x_2 +{} & \dotsm              &{} +  a_{mn}x_n & = b_m
\end{alignat*}
\end{document} Here are three ways to do this:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
Align, not good, can't get horizontal and vertical dots to line up (easily, could mess around with spacing by eye)
\begin{align*}
a_{11}x_1 + a_{12}x_2 + &\dotsb + a_{1n}x_n = b_1\\
a_{21}x_1 + a_{22}x_2 + &\dotsb + a_{2n}x_n = b_2\\
&\vdots\\
a_{m1}x_1 + a_{m2}x_2 + &\dotsb + a_{mn}x_n = b_m
\end{align*}
Matrix with two columns, extra spacing around dots
$\begin{matrix} % notice {} before/after & to ensure proper spacing of binary operator (as opposed to the unary version that LaTeX tries to put in if there is no {} a_{11}x_1 + a_{12}x_2 + {}&\dotsb&{} + a_{1n}x_n = b_1\\ a_{21}x_1 + a_{22}x_2 + {}&\dotsb&{} + a_{2n}x_n = b_2\\ & \vdots &\\ a_{m1}x_1 + a_{m2}x_2 + {}&\dotsb&{} + a_{mn}x_n = b_m \end{matrix}$
Matrix with lots of columns even spacing but larger than in a normal equation.
Most closely matches example
$\begin{matrix} a_{11}x_1 & + & a_{12}x_2 & + & \dotsb & + & a_{1n}x_n & = & b_1 \\ a_{21}x_1 & + & a_{22}x_2 & + & \dotsb & + & a_{2n}x_n & = & b_2 \\ & & & & \vdots & & & & \\ a_{m1}x_1 & + & a_{m2}x_2 & + & \dotsb & + & a_{mn}x_n & = & b_m \end{matrix}$
\end{document}



The first uses the align* environment (remove * to have it numbered). This is probably the worst way in my opinon as the vertical dots (\vdots) are not centred on the horizontal dots (\dotsb). The second uses a matrix environment (it does look like these equations come from a matrix after all). There are three columns, one before the dots, one with the dots, and one after the dots. The third uses a matrix environment and each binary operator/relation (+ and =) is in its own column as well as each term and the dots. If I had to guess I'd say this is how the original was done. Notice the large spacing between +` and its arguments.