# The equations do not align with respect to +

I have the following code to align a system of equations

\begin{aligned}
p       &= q r             &+ r_0 \\
r       &= q_0 r_0         &+ r_1 \\
r_0     &= q_1 r_1         &+ r_2 \\
r_k     &= q_{k+1} r_{k+1} &+ r_{k+2} \\
&\mathrel{\vdots} \\
r_{k+1} &= q_{k+2} r_{k+2}
\end{aligned} I can not understand why these equations do not align w.r.t +.

• A general explanation of how elements of equations are treated by the align environment is given in this answer: Aligning equations Jun 13, 2019 at 3:12

You need one more & to have stuff left-aligned after it (if you want to work with aligned here).

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{aligned} p &= q r &&+ r_0 \\ r &= q_0 r_0 &&+ r_1 \\ r_0 &= q_1 r_1 &&+ r_2 \\ r_k &= q_{k+1} r_{k+1} &&+ r_{k+2} \\ &\mathrel{\vdots} \\ r_{k+1} &= q_{k+2} r_{k+2} \\ \end{aligned}
\end{document} If you want to center the \vdots, you can use the mathtools package.

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{aligned} p &= q r &&+ r_0 \\ r &= q_0 r_0 &&+ r_1 \\ r_0 &= q_1 r_1 &&+ r_2 \\ r_k &= q_{k+1} r_{k+1} &&+ r_{k+2} \\ &\vdotswithin{=} \\ r_{k+1} &= q_{k+2} r_{k+2} \\ \end{aligned}
\end{document} • Thank you so much! I got it. Could you please instruct me to put the \cdots right below the center of =? Jun 12, 2019 at 4:21
• @LeAnhDung I added something that does it. (Andrew Swann used this trick in an answer to a previous question of yours: tex.stackexchange.com/a/494424/121799.)
– user121799
Jun 12, 2019 at 4:26
• I admire your great memory :) Jun 12, 2019 at 4:28
• @LeAnhDung Those who live in burrows need it otherwise they cannot find out. ;-)
– user121799
Jun 12, 2019 at 4:30
• @marmot such a nice suggestion.... Jun 12, 2019 at 4:41

You need alignedat, that doesn't add horizontal spacing, but with one & more.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{alignedat}{2} p &= q r &&+ r_0 \\ r &= q_0 r_0 &&+ r_1 \\ r_0 &= q_1 r_1 &&+ r_2 \\ &\mathrel{\;\vdots} \\ r_k &= q_{k+1} r_{k+1} &&+ r_{k+2} \\ r_{k+1} &= q_{k+2} r_{k+2} \end{alignedat}

\end{document} • I'm happy to see you on TexExchange ;) Jun 12, 2019 at 9:28
• @Akira Happy to see you, too! Jun 12, 2019 at 9:29