# centering a part of an equation

I am using \vdots in my equation, and I need it to be centered. As shown in the figure it is automatically left indented. I am not able to bring the dots to the center. I am providing MWE also.

\documentclass[12pt,letter]{report}

\usepackage{graphicx,cite,epsfig,amssymb,amsmath,endnotes,algorithm,algorithmic}

\begin{document}
\begin{align}
&X_{1} \rightarrow\mathcal{N}\left(A\right) \nonumber \,,\\
&X_{2} \rightarrow\mathcal{N}\left(B\right) \nonumber \,,\\
\vdots \nonumber
\\&X_{A-1} \rightarrow\mathcal{N}\left(C\right) \nonumber\,, \\
&X_{A} \rightarrow\mathcal{N}\left(D\right) \nonumber \,, \\
&X \rightarrow\mathcal{N}\left(E\right)\,.
\end{align}

\end{document}

-
Don't load epsfig, it's an obsolete package. Don't use \left and \right in that context: it just makes the formula worse. I never leave space before commas in math. –  egreg Dec 5 '12 at 22:43
I would define a macro to handle your use of \mathcal{N}(...). For example, \newcommand{\nat}[1]{\mathcal{N}(#1)} and then use \nat{A}, \nat{B}, ... See Consistent typography. –  Werner Dec 5 '12 at 22:48
Since it's not clear which horizontal alignment the OP is after, it's only 50% duplicate of Centering \vdots in a system of many equations. –  Werner Dec 5 '12 at 22:54

## 1. Aligned with \rightarrow

You can align it with the \rightarrow as such:

## Notes:

• You can use align* so that you don't need to add \nonumber to each line.
• Usually you would not want to put the alignment at the beginning of the first term, so I have moved it to be before the \rightarrow.

## 2. Centered with \rightarrow:

A better solution is to use \makebox to get the vdots centered within the space of the \rightarrow:

## Notes:

• This requires the use of the calc package.
• This has the benefit that no manual guessing of spacing is required. Hence, this solution can easily be adapted to other cases.

## 3. Centered with \rightarrow (with other enhancements)

I have provided another version which:

1. Incorporates Werner's recommendation of using Consistent typography by defining a \nat macro.

2. Incorporates egreg's recommendation to eliminate the space prior to the comma.

This yields:

## Code: aligned with \rightarrow

\documentclass[12pt,letter]{report}

\usepackage{amsmath}

\begin{document}
\begin{align}
X_{1} &\rightarrow\mathcal{N}\left(A\right) \nonumber \,,\\
X_{2} &\rightarrow\mathcal{N}\left(B\right) \nonumber \,,\\
&\vdots \nonumber
\\X_{A-1} &\rightarrow\mathcal{N}\left(C\right) \nonumber\,, \\
X_{A} &\rightarrow\mathcal{N}\left(D\right) \nonumber \,, \\
X &\rightarrow\mathcal{N}\left(E\right)\,.
\end{align}

\begin{align*}
X_{1} &\rightarrow\mathcal{N}\left(A\right) \,,\\
X_{2} &\rightarrow\mathcal{N}\left(B\right) \,,\\
&\vdots \nonumber
\\X_{A-1} &\rightarrow\mathcal{N}\left(C\right) \,, \\
X_{A} &\rightarrow\mathcal{N}\left(D\right) \,, \\
X &\rightarrow\mathcal{N}\left(E\right)\,.
\end{align*}
\end{document}


## Code: centered with \rightarrow

\documentclass[12pt,letter]{report}

\usepackage{amsmath}
\usepackage{calc}

\begin{document}
\begin{align*}
X_{1} &\rightarrow\mathcal{N}\left(A\right) \,,\\
X_{2} &\rightarrow\mathcal{N}\left(B\right) \,,\\
&\makebox[\widthof{${}\rightarrow{}$}][c]{\vdots}
\\X_{A-1} &\rightarrow\mathcal{N}\left(C\right) \,, \\
X_{A} &\rightarrow\mathcal{N}\left(D\right) \,, \\
X &\rightarrow\mathcal{N}\left(E\right)\,.
\end{align*}
\end{document}


## 3. Code: centered with \rightarrow (with other enhancements)

\documentclass[12pt,letter]{report}

\usepackage{amsmath}
\usepackage{calc}

\newcommand{\nat}[1]{\mathcal{N}(#1)}

\begin{document}
\begin{align*}
X_{1} &\rightarrow \nat{A}, \\
X_{2} &\rightarrow \nat{B}, \\
&\makebox[\widthof{${}\rightarrow{}$}][c]{\vdots} \\
X_{A-1} &\rightarrow \nat{C}, \\
X_{A} &\rightarrow \nat{D}, \\
X &\rightarrow \nat{E}.
\end{align*}
\end{document}

-
Or, without packages, \mathrel{\ooalign{\hphantom{$\rightarrow$}\cr\hfil\vdots\hfil\cr}}. ;-) –  egreg Dec 5 '12 at 23:13

You can do it like this. Notice the additionally needed package mathtools:

\documentclass{article}

\usepackage{mathtools}

\begin{document}
\begin{align}
X_{1} &\rightarrow\mathcal{N}\left(A\right) \nonumber \,,\\
X_{2} &\rightarrow\mathcal{N}\left(B\right) \nonumber \,,\\
&\,\mathclap{\phantom{\rightarrow}\vdots} \nonumber\\
X_{A-1} &\rightarrow\mathcal{N}\left(C\right) \nonumber\,, \\
X_{A} &\rightarrow\mathcal{N}\left(D\right) \nonumber \,, \\
X &\rightarrow\mathcal{N}\left(E\right)\,.
\end{align}

\end{document}
\end{document}


The construction \,\mathclap{\phantom{\rightarrow}\vdots} is a trick to make \vdots center with respect to the width of \rightarrow. As well, I consider the alignment by the arrows to be more proper here. (As @egreg correctly points out, I should have used a larger space \; here. However, this smaller one seems to work well because \rightarrow is an assymetric symbol.)

-
The right spacing is \; (a thick space) –  egreg Dec 5 '12 at 23:15
@egreg that's true, however, this seems to fit well since \rightarrow is assymetric. –  yo' Dec 5 '12 at 23:17

Yet another variation on the above:

\documentclass[12pt,letter]{report}
\usepackage{amssymb,amsmath}

\begin{document}
\begin{align}
\begin{split}
X_{1}     & \rightarrow\mathcal{N}\left(A\right)  \,,\\
X_{2}   & \rightarrow\mathcal{N}\left(B\right)  \,,\\
&  \mspace{10mu}\vdots  \\
X_{A-1} & \rightarrow\mathcal{N}\left(C\right) \,, \\
X_{A}   & \rightarrow\mathcal{N}\left(D\right)  \,, \\
X       & \rightarrow\mathcal{N}\left(E\right)\,.
\end{split}
\end{align}
\end{document}


-

Use the \vdotswithin command from the mathtools package, as it was designed exactly for this purpose:

\documentclass{article}
\usepackage{amsmath,mathtools}
\begin{document}
\begin{align*}
X_{1}   &\rightarrow\mathcal{N}(A), \\
X_{2}   &\rightarrow\mathcal{N}(B), \\
& \vdotswithin{\rightarrow} \\
X_{A-1} &\rightarrow\mathcal{N}(C), \\
X_{A}   &\rightarrow\mathcal{N}(D), \\
X       &\rightarrow\mathcal{N}(E).
\end{align*}
\end{document}


Alternatively, for less vertical space above and below the dots, use \shortvdotswithin. Be careful not to put \\ at the end of the line containing \shortvdotswithin, and you don't need the & on that line either:

\documentclass{article}
\usepackage{amsmath,mathtools}
\begin{document}
\begin{align*}
X_{1}   &\rightarrow\mathcal{N}(A), \\
X_{2}   &\rightarrow\mathcal{N}(B), \\
\shortvdotswithin{\rightarrow}
X_{A-1} &\rightarrow\mathcal{N}(C), \\
X_{A}   &\rightarrow\mathcal{N}(D), \\
X       &\rightarrow\mathcal{N}(E).
\end{align*}
\end{document}


These solutions come from this answer provided by Thomas.

Furthermore, since the question stated "I need it to be centered" and not "I need the \vdots to be aligned with the arrows", the answer to a literal reading of the question would be to use the gather environment, which centres all of its equations and doesn't take &: (Use the starred version for no numbering.)

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather*}
X_{1}  \rightarrow\mathcal{N}(A) ,\\
X_{2}  \rightarrow\mathcal{N}(B) ,\\
\vdots  \\
X_{A-1} \rightarrow\mathcal{N}(C) , \\
X_{A}   \rightarrow\mathcal{N}(D) , \\
X       \rightarrow\mathcal{N}(E).
\end{gather*}
\end{document}


EDIT: I've now uploaded the pictures above, but they're not cropped properly....

-

This aligns the \rightarrows and the \vdots:

\begin{align}
X_{1}  & \rightarrow\mathcal{N}\left(A\right) \nonumber \,,\\
X_{2}  & \rightarrow\mathcal{N}\left(B\right) \nonumber \,,\\
& \ \ \vdots \nonumber \\
X_{A-1}&  \rightarrow\mathcal{N}\left(C\right) \nonumber\,, \\
X_{A}  & \rightarrow\mathcal{N}\left(D\right) \nonumber \,, \\
X      & \rightarrow\mathcal{N}\left(E\right)\,.
\end{align}


Your LaTeX source will be much easier for you and other people to read if you align the align symbols.

The two forced blank spaces on the \vdots line are a bit of a hack.

-