# Aligning vdots with terms in a system of equations

I am attempting to write a system of linear equations that looks like this:

A_{11}x_1 + A_{12}x_2 + \cdots + A_{1n}x_n = y_1
A_{21}x_1 + A_{22}x_2 + \cdots + A_{2n}x_n = y_2
\vdots      \vdots               \vdots      \vdots
A_{m1}x_1 + A_{m2}x_2 + \cdots + A_{mn}x_n = y_m

where the vdots are centered on the terms rather than the equal sign. Here is my attempt:

\documentclass{report}
\usepackage{amsmath}
\begin{document}

\begin{align*}
&A_{11}x_1& + &A_{12}x_2& + \cdots + &A_{1n}x_n& = &y_1& \\
&A_{21}x_1& + &A_{22}x_2& + \cdots + &A_{2n}x_n& = &y_2& \\
&\vdots&  &\vdots& &\vdots& &\vdots& \\
&A_{m1}x_1& + &A_{m2}x_2& + \cdots + &A_{mn}x_n& = &y_m& \\
\end{align*}

\end{document}

Anyone have an elegant solution?

EDIT. Here is a second attempt, using the better-suited array environment. It looks better, but still unnatural.

\documentclass{report}
\begin{document}

$\begin{array}{ccccccccc} A_{11}x_1 & + & A_{12}x_1 & + & \cdots & + & A_{1n}x_n & = & y_1 \\ A_{21}x_1 & + & A_{22}x_2 & + & \cdots & + & A_{2n}x_n & = & y_2 \\ \vdots & & \vdots & & & & \vdots & & \vdots \\ A_{m1}x_1 & + & A_{m2}x_2 & + & \cdots & + & A_{mn}x_n & = & y_m \\ \end{array}$

\end{document}

Is there any way to have the vdots aligned like this but make the equations look normal?

-
An array environment? – Abhimanyu Arora Jun 12 '14 at 15:47
@AbhimanyuArora That works better, but it still doesn't look right. See edit. – Randy Randerson Jun 12 '14 at 15:53

I suggest the following modification:

\documentclass{report}
\usepackage{array}
\begin{document}

$\begin{array}{*{9}{@{}c@{}}} A_{11}x_1 & {}+{} & A_{12}x_1 &{}+{} & \cdots & {}+{} & A_{1n}x_n & {}\mathrel{=}{} & y_1 \\ A_{21}x_1 & + & A_{22}x_2 & + & \cdots & + & A_{2n}x_n & = & y_2 \\ \vdots & & \vdots & & & & \vdots & & \vdots \\ A_{m1}x_1 & + & A_{m2}x_2 & + & \cdots & + & A_{mn}x_n & = & y_m \\ \end{array}$

\end{document}

-
Looks great, thanks! – Randy Randerson Jun 12 '14 at 16:11

I'd recommend you use the a \makebox to get the \vdots centered and use the alignat environment to do multiple alignment points:

## Code:

\documentclass{report}
\usepackage{amsmath}
\usepackage{calc}

\newcommand*{\MyVdots}[1][$A_{22}x_n$]{\makebox[\widthof{#1}]{$\vdots$}}%
\newcommand*{\Ph}{\hphantom{{}+{}}}%
\begin{document}

\begin{alignat*}{5}
&A_{11}x_1 &&{}+ A_{12}x_2  &&{}+ \cdots &&{}+ A_{1n}x_n && = y_1 \\
&A_{21}x_1 &&{}+ A_{22}x_2  &&{}+ \cdots &&{}+ A_{2n}x_n && = y_2 \\
&\MyVdots  &&\Ph \MyVdots   &&           &&\Ph  \MyVdots &&\Ph \MyVdots[$y_1$] \\
&A_{m1}x_1 &&{}+ A_{m2}x_2  &&{}+ \cdots &&{}+ A_{mn}x_n && = y_m \\
\end{alignat*}

\end{document}
-

Here are two TABstacks, one with a lesser space around the \vdots, the other with a greater space.

\documentclass{report}
\usepackage{tabstackengine}
\stackMath
\begin{document}
$\TABbinary \let\svvdots\vdots\def\vdots{\protect\raisebox{-3pt}{\svvdots}} \tabbedCenterstack{ A_{11}x_1 & + & A_{12}x_1 & + & \cdots & + & A_{1n}x_n & = & y_1 \\ A_{21}x_1 & + & A_{22}x_2 & + & \cdots & + & A_{2n}x_n & = & y_2 \\ \vdots & & \vdots & & & & \vdots & & \vdots \\ A_{m1}x_1 & + & A_{m2}x_2 & + & \cdots & + & A_{mn}x_n & = & y_m \\ }$
$\TABbinary \let\svvdots\vdots\def\vdots{\protect\raisebox{3pt}{\svvdots}} \tabbedShortstack{ A_{11}x_1 & + & A_{12}x_1 & + & \cdots & + & A_{1n}x_n & = & y_1 \\ A_{21}x_1 & + & A_{22}x_2 & + & \cdots & + & A_{2n}x_n & = & y_2 \\ \vdots & & \vdots & & & & \vdots & & \vdots \\ A_{m1}x_1 & + & A_{m2}x_2 & + & \cdots & + & A_{mn}x_n & = & y_m \\ }$
\end{document}

-