# Problem with \vdotswithin

I want to typeset a system of equations and set vertical dots between two rows centered at the equal sign. vdotswithin from 'mathtools' should do exactly that, but for some reason the following code

\begin{alignat*}{3}
x_1 &+ x_2 t_1 &= 0\\
x_1 &+ x_2 t_2 &= 0\\
&&\vdotswithin{=}\\
x_1 &+ x_2 t_m &= 0
\end{alignat*}


produces the following output

what am I doing wrong?

Problem is that your last column is set up for right, rather than left alignment.

\documentclass{article}
\usepackage{mathtools}
\begin{document}

\begin{alignat*}{3}
x_1 +{} &&x_2 t_1 &= 0\\
x_1 +{} &&x_2 t_2 &= 0\\
&&&\vdotswithin{=}\\
x_1 + {}&&x_2 t_m &= 0
\end{alignat*}

\end{document}


• Thanks! Is there any documentation which explains the logic behind the '&' and '{}'? There usage seems to be nontrivial in amsmath. – Dominik Jan 28 at 14:57
• @Dominik The {} has to do with letting the + know that something follows (in the next column), since technically, the + can't otherwise tell what follows the &. The & are, of course, column separators. The use of &= rather than &= is a quirk of amsmath that, to be honest, I don't wholly comprehend. But the underlying lesson is that the spacing around things like + and - will vary depending on if it is used in a binary or unary sense. The {} helps clarify the sense. – Steven B. Segletes Jan 28 at 15:01

I would do it this way:

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{alignat*}{2}
x_1 &+ x_2 t_1 &&= 0\\
x_1 &+ x_2 t_2 &&= 0\\
&          && \vdotswithin{=} \\
x_1 &+ x_2 t_m &&= 0
\end{alignat*}

\end{document}


Every time you have a & in one of the align environments, the alignment type switches between left and right. The first column is always right-aligned. Therefore, here, column alignments are respectively: right, left, right, and left.

Then, regarding the mandatory argument of alignat, the amsmath documentation (amsldoc.pdf) says:

Here, we have three & in each line, therefore the correct argument to pass to alignat is (3+1)/2 = 2, not 3. This is the number of (right, left ) pairs of columns.

In case you want the dots to be closer to the equal signs, I believe one way to do it should be:

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{alignat*}{2}
x_1 &+ x_2 t_1 &&= 0\\
x_1 &+ x_2 t_2 &&= 0\\
\MTFlushSpaceAbove
&          && \vdotswithin{=}
\MTFlushSpaceBelow
x_1 &+ x_2 t_m &&= 0
\end{alignat*}

\end{document}