10

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.

enter image description here

\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} 
  • 4
    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
  • 1
    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
  • 1
    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
13

1. Aligned with \rightarrow

You can align it with the \rightarrow as such:

enter image description here

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:

enter image description here

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:

enter image description here


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} 
| improve this answer | |
  • 1
    Or, without packages, \mathrel{\ooalign{\hphantom{$\rightarrow$}\cr\hfil\vdots\hfil\cr}}. ;-) – egreg Dec 5 '12 at 23:13
5

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

enter image description here

\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.)

| improve this answer | |
  • 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
2

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} 

enter image description here

| improve this answer | |
1

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}

align using <code>/vdotswithin</code>

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}

align using <code>\shortvdotswithin</code>

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}

gather

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

| improve this answer | |
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.