17

I'm using the \align* environment from the amsmath package. How can I center one of the lines inside the environment?

In the following example, I want to the \vdots to be centered, instead of awkwardly aligned with the b above it.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
& a = (a_1, a_2) \\
& b = (b_1, b_2) \\
& \vdots \\
& z = (z_1, z_2)
\end{align*}
\end{document}
David Carlisle
  • 757,742
jamaicanworm
  • 29,114
  • Do you want it centered, or under the equal sign? – Peter Grill Apr 18 '12 at 22:57
  • 1
    You're misusing align: try a &= (a_1,a_2) \\ and similarly for the other lines; then & \mathrel{\:\vdots} \\ will be aligned under the equals signs. – egreg Apr 18 '12 at 22:59
  • 1
    or since you don't seem to be aligning anything, perhaps gather: \begin{gather*} a = (a_1, a_2) \ b = (b_1, b_2) \ \vdots \ z = (z_1, z_2) \end{gather*} – David Carlisle Apr 18 '12 at 23:01

3 Answers3

11
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
 a &= (a_1, a_2) \\
 b &= (b_1, b_2) \\
 &\phantom{b=\,} \vdots \\
 z &= (z_1, z_2)
\end{align*}
\end{document}

enter image description here

8

This question is similar to this question, but to complete this page, I will add a similar answer here.

If you want to center the points unter the equal signs, then you should consider the package mathtools, which provides several corrections for and additions to amsmath.

\usepackage{mathtools}

It also provides a comfortable solution for your problem. You can even choose between a normal (\vdotswithin) and a short (\shortvdotswithin) distance.

\begin{align*}
  a &= b \\
  & \vdotswithin{=} \\
  & = c \\
  \shortvdotswithin{=}
  & = d
\end{align*}

The result convinces.

Example showing vdotswithin and shortvdotswithin

More details can be found in the documentation of the package, section "Centered \vdots", where also the example above is taken from.

One
  • 1,485
4

I am sure there are plenty of ways of doing this. One of which would be to use \ooalign:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\begin{align*}
  & a = (a_1, a_2) \\
  & b = (b_1, b_2) \\
  & \vdots \\
  & z = (z_1, z_2)
\end{align*}

\begin{align*}
  a &= (a_1, a_2) \\
  b &= (b_1, b_2) \\
  \makebox[0pt][l]{%
    \vphantom{$\vdots$}% For height
    \ooalign{\phantom{$a=(a_1, a_2)$}\cr\hss$\vdots$\hss}}% Centered \vdots
    \phantom{a}% For placement
      & \\
  z &= (z_1, z_2)
\end{align*}
\end{document}​

See this answer for a quick course on \ooalign.

Werner
  • 603,163