7

I'd like to insert some symbols over the \dots. I'm doing it with \stackrel but I guess that it is changing the category of the \dots symbol so the space after it is different.

How is the right way to typeset this?

MWE

\documentclass{report}
\usepackage{amsmath}
\begin{document}
$[1,\dots,n]$

$[1,{\stackrel{\times r}{\dots}},n]$
\end{document}

enter image description here

Sigur
  • 37,330

3 Answers3

6

Don't use \stackrel under any circumstance: \overset does much better. In this case we need to help it a bit, however:

\documentclass{report}
\usepackage{amsmath}
\begin{document}
$[1,\dots,n]$

$[1,\mathpunct{\overset{\times r}{\dotsc}},n]$
\end{document}

enter image description here

Explanation: the space after the ellipsis in the first example is regulated by the fact that \dots acts as a punctuation symbol. With a simple \overset{\times r}{\dots} it wouldn't be considered as such, but just as an ordinary symbol, so we help LaTeX in order to find the correct spacing, because \overset doesn't catch all types.

egreg
  • 1,121,712
  • Nice! It also works with \dots instead of \dotsc. – Sigur Apr 07 '15 at 13:12
  • @Sigur Better use \dotsc, IMO. I changed the code, because otherwise the \times r bit would be shifted too much to the right. – egreg Apr 07 '15 at 13:15
  • Sorry, I can not see visual difference between \dotsc and\dots. Maybe reading the log. – Sigur Apr 07 '15 at 13:17
  • @Sigur \dots uses some rules to decide whether low or centered dots should be used, based on the token that follows it. With no clue it uses low dots. However, the system is set up so that different conventions can be enforced. Thus amsmath provides \dotsc (pretend a comma follows), \dotsb (pretend a binary operation follows, not multiplication), \dotsm (pretend a multiplication symbol follows), in order to be sure the correct dots are chosen, according to the publisher's convention. – egreg Apr 07 '15 at 13:20
  • thanks for the explanation. But you said \times r bit would be shifted too much to the right and I can not see this. But OK, I agree that it is better to use \dotsc. – Sigur Apr 07 '15 at 13:26
  • @Sigur With \overset{\times r}{\dotsc{}} it would, that's why I changed the code. – egreg Apr 07 '15 at 13:27
2

Here is a solution, with a correction for \times r to be centred over the dots:

\documentclass{report}
\usepackage{amsmath}

\begin{document}

$[1,\dots,n]$

$[1,\stackrel{\times r\;}{\dots{}},n]$

\end{document}

enter image description here

Sigur
  • 37,330
Bernard
  • 271,350
1

Solution by "trial by error".

Each column portrays the original unstacked \dots followed by the \stackreled \dots, subject to \mathpunct, \mathop, \mathrel, \mathbin, and \mathod, respectively.

The first column is with a trailing {}, the second column is with no leading or trailing placeholders, while the third column is with both leading and trailing {} placeholders.

[With egreg's help], I found two approaches that work. Clearly the favored one is \mathpunct, as it gives the proper result in all three columns. In addition, the $[1,\mathop{\stackrel{\times r}{\dots}}{},n]$, given on the third line of the first column, also matches the initial result.

\documentclass{report}
\usepackage{amsmath}
\begin{document}
{\tiny \verb|\mathxxx{...}{}              \mathxxx{...}               {}\mathxxx{...}{}| \par}

\parbox[t]{1in}{

$[1,\dots,n]$

$[1,\mathpunct{\stackrel{\times r}{\dots}}{},n]$

$[1,\mathop{\stackrel{\times r}{\dots}}{},n]$

$[1,\mathrel{\stackrel{\times r}{\dots}}{},n]$

$[1,\mathbin{\stackrel{\times r}{\dots}}{},n]$

$[1,\mathord{\stackrel{\times r}{\dots}}{},n]$
}
\parbox[t]{1in}{
$[1,\dots,n]$

$[1,\mathpunct{\stackrel{\times r}{\dots}},n]$

$[1,\mathop{\stackrel{\times r}{\dots}},n]$

$[1,\mathrel{\stackrel{\times r}{\dots}},n]$

$[1,\mathbin{\stackrel{\times r}{\dots}},n]$

$[1,\mathord{\stackrel{\times r}{\dots}},n]$
}
\parbox[t]{1in}{
$[1,\dots,n]$

$[1,{}\mathpunct{\stackrel{\times r}{\dots}}{},n]$

$[1,{}\mathop{\stackrel{\times r}{\dots}}{},n]$

$[1,{}\mathrel{\stackrel{\times r}{\dots}}{},n]$

$[1,{}\mathbin{\stackrel{\times r}{\dots}}{},n]$

$[1,{}\mathord{\stackrel{\times r}{\dots}}{},n]$
}
\end{document}

enter image description here