6

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 '19 at 6:22
  • It should be \mathbf, not \textbf. – egreg Jul 10 '19 at 9:17
10

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.

enter image description here

\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}
|improve this answer|||||
  • 1
    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... – Rmano Jul 10 '19 at 6:57
  • This is excellent! – Math_Freak Jul 11 '19 at 2:45
4

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}

enter image description here

|improve this answer|||||
  • What about shifting the arrow a bit lower? – CarLaTeX Jul 10 '19 at 6:53
  • @CarLaTeX That's unfortunately hardcoded in amsmath.sty. – Henri Menke Jul 10 '19 at 7:28
  • @HenriMenke - The arrows can be shifted down a bit by replacing \ldots with \ldots\mathstrut. – Mico Jul 10 '19 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 '19 at 13:14
3

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}

enter image description here

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