# How to put an arrow below a vector?

I am having trouble writing this vector:

$\textbf{v}=(2n-1,n-1,n-1,\ldots,n-1,1,1,\ldots,1)$.


I want to indicate that $n-1$ appears $n-1$ times and $1$ appears $n$ times by writing arrow under $\ldots$.

But I can't do it.

• Welcome to TeX.SE.
– Mico
Jul 10, 2019 at 6:22
• It should be \mathbf, not \textbf. Jul 10, 2019 at 9:17

I actually would not use arrows for the job at hand. I suggest, instead, that you use \underbrace directives (provided by the amsmath package) to provide a platform for the two explanatory text snippets $n-1$ times and $n$ times. Indicating explicitly that \mathbf{v} is a 2n\times1 vector might be helpful too.

\documentclass{article}
\usepackage{amsmath} % for \underbrace macro
\begin{document}
$\mathbf{v}^{}_{2n\times1}=(2n-1,\underbrace{n-1,\dots,n-1}_{\text{$n-1$times}},\underbrace{1,\ldots,1}_{\text{$n$times}}\,)'$
\end{document}

• This is so much better. In the original, for example, you do not know if the number of "1" is "n" or if the arrow substitutes for "n", leading to "n+4" ones... Jul 10, 2019 at 6:57
• This is excellent! Jul 11, 2019 at 2:45

The amsmath package provides \underrightarrow and \underset for this job.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\mathbf{v}=(2n-1,n-1,n-1,\underset{n-1}{\underrightarrow{\ldots}},n-1,1,1,\underset{n}{\underrightarrow{\ldots}},1)$.
\end{document}


• What about shifting the arrow a bit lower? Jul 10, 2019 at 6:53
• @CarLaTeX That's unfortunately hardcoded in amsmath.sty. Jul 10, 2019 at 7:28
• @HenriMenke - The arrows can be shifted down a bit by replacing \ldots with \ldots\mathstrut.
– Mico
Jul 10, 2019 at 13:08
• You may also want to replace \underset{n-1} with \underset{\mathclap{n-1}}. \mathclap requires the mathtools package, a fact I'm sure you're aware of too. :-)
– Mico
Jul 10, 2019 at 13:14

I have two proposals. In the first one, the arrow reaches a bit beyond the commas, in the second one the arrow covers all objects to be replicated.

The top line is meant to show that the spacing is the same.

\documentclass{article}
\usepackage{amsmath,calc}

\makeatletter
\newcommand{\replA}[2]{% #1 = number of times, #2 = object
\vtop{\offinterlineskip\m@th
\sbox\z@{$,\dotsc,{}$}%
\ialign{&\hfil##\hfil\cr
$#2$&$,\dotsc,{}$&$#2$\cr
\noalign{\kern 1.5pt}
&\scriptsize\makebox[\wd\z@]{\hspace{-0.3em}\rightarrowfill\hspace{-0.3em}}\cr
\multispan{3}\hfil\scriptsize$\mathstrut#1$\hfil\cr
}%
}%
}
\newcommand{\replB}[2]{% #1 = number of times, #2 = object
\vtop{\offinterlineskip\m@th
\ialign{\hfil##\hfil\cr
$#2,\dots,#2$\cr
\noalign{\kern 1.5pt}
\scriptsize\,\rightarrowfill\,\cr
\scriptsize$\mathstrut#1$\cr
}%
}%
}
\makeatother

\begin{document}

$\mathbf{v}=(2n-1,n-1,\dots,n-1,1,\dots,1)$

$\mathbf{v}=(2n-1,\replA{n-1}{n-1},\replA{n}{1})$

$\mathbf{v}=(2n-1,\replB{n-1}{n-1},\replB{n}{1})$

\end{document}
`