# How do magic \dots work in amsmath?

The amsmath package redefines the \dots command so that it "guesses" the correct height of the dots with respect to its context. For example

$x, \dots, y$


will produce three lowered dots, aligned with the commas. While

$x \to \dots \to y$


uses centered dots that align with the arrows. However, if I define my own macros, amsmath can no longer guess and it always uses the lowered dots. For example

\newcommand{\myto}{\to}
$x \myto \dots \myto y$


uses the wrong dots. How can I tell amsmath that I want centered and not lowered dots?

Btw., I know about \cdots but what I want is \dots to still be able to guess the correct ones automatically.

-

Looking at amsmath.sty, I see lots of lines like:

\gdef\coprod{\DOTSB\coprod@\slimits@}


I would guess that the \DOTSB controls what kind of dots go before (or after?) this symbol. Doing

\show\mapsto


shows that that has the magic \DOTSB. So if defining your own macro, I would experiment with adding \DOTSB, \DOTSI, \DOTSX (those appear to be the options) before or after them. (Please report back on what happens!). I would guess that \dots "knows" about certain commands, but has to be told about any extra. \to seems to come in under the "known" commands, but, for example, it has to be told about \mapsto:

> \mapsto=\long macro:
->\DOTSB \mapstochar \rightarrow .
l.3 \show\mapsto

-
If this is possible, I didn't know about it. (Sorry, no time to check myself right now.) Very interesting! – Will Robertson Jul 30 '10 at 16:10
Just a quick note before going to sleep: it works! If I use \newcommand{\myto}{\DOTSB\to} then \myto will produce the correct alignment! Thanks, tomorrow I'll try and check what the other options do. – Juan A. Navarro Jul 30 '10 at 22:31

This doesn't do what you're asking for, but in best semantic fashion, amsmath also defines

• \dotsc for “dots with commas”

• \dotsb for “dots with binary operators/relations”

• \dotsm for “multiplication dots”

• \dotsi for “dots with integrals”

• \dotso for “other dots” (none of the above)

(Quoted from the Short Math Guide for LaTeX.) Each of these specifies the height. I didn't find the behavior of \dots you described documented. Can you point out where it is?

-
Thanks, I already knew about these, but I'm actually trying to define a macro that will add \dots between some some relations/operators which are provided by the user. So I, as a package write, don't know in advance which of the semantic commands should be used. However, as the example in the question shows, amsmath somehow knows! – Juan A. Navarro Jul 30 '10 at 22:27

OK, so since I asked the debugging question, I ventured out and tried to debug!

Using just \show didn't work, producing the following in the log file:

> \dots=macro:
->\protect \dots  .
l.7 \show\dots


so I googled for the show command and found this page and so I did the following

\def\pshow#1{{\let\protect\show #1}}
\begin{equation*}
a \pshow{\dots} b=0;
\end{equation*}


which resulted in:

> \dots =\long macro:
->\ifmmode \@xp \mdots@ \else \@xp \textellipsis \fi .
\dots ->\protect \dots


Looking deeper to examine \mdots@ is possible (using \makeatletter and \makeatother) but is quite horrific:

 > \mdots@=macro:
->\FN@ \mdots@@ .
l.11 \show\mdots@


where

> \FN@=macro:
->\futurelet \@let@token .


and

> \mdots@@=macro:
->\gdef \thedots@ {\dotso@ }\ifx \@let@token \boldsymbol \gdef \thedots@ \boldsymbol {\boldsymboldots@ }\else \ifx ,\@let@token \gdef \thedots@ {\dotsc }\else \ifx \not \@let@token \gdef \thedots@ {\dotsb@ }\else \keybin@ \ifgtest@ \gdef \thedots@ {\dotsb@ }\else \xdef \meaning@ {\meaning \@let@token ..........}\xdef \meaning@@ {\meaning@ }\@xp \math@ \meaning@ \math@ \ifgtest@ \@xp \mathch@ \meaning@ \mathch@ \ifgtest@ \@xp \getmathch@ \meaning@ \getmathch@ \fi \else \@xp \macro@ \meaning@@ \macro@ \ifgtest@ \@xp \not@ \meaning@ \not@ \ifgtest@ \gdef \thedots@ {\dotsb@ }\else \@xp \DOTS@ \meaning@ \DOTS@ \ifgtest@ \ifcase \
number \DOTSCASE@ \gdef \thedots@ {\dotsb@ }\or \gdef \thedots@ {\dotsi }\else \fi \else \@xp \math@ \meaning@ \math@ \ifgtest@ \@xp \mathbin@ \meaning@ \mathbin@ \ifgtest@ \gdef \thedots@ {\dotsb@ }\else \@xp \mathrel@ \meaning@ \mathrel@ \ifgtest@ \gdef \thedots@ {\dotsb@ }\fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \thedots@ .


At this point, I give up....anyone care to continue this dissection?

-
The quick'n'easy answer is that it looks at the next token in the input stream and bases its decision on that. If it's something vertically raised such as a plus sign or an arrow, it uses \cdots, otherwise it uses \ldots. – Will Robertson Jul 30 '10 at 16:10