# Writing text above \cdots

My question is: How can I write an index above a set of dots? I mean

\mathbb{R} \cdots^{HERE} \mathbb{R}


just to say that I have "n" times cartesian product of R.

-
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). – clemens Feb 10 '13 at 10:43
Oh okey ^^ thanks for the tip :) – Dan Feb 10 '13 at 10:44

Let's make a more realistic example: you want to put n above the dots to denote an omission of terms. Here are possible codes:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

$X_{1}\times \stackrel{n}{\cdots} \times X_{n}$

$X_{1}\times \overset{n}{\cdots} \times X_{n}$

$X_{1}\times \cdots \times X_{n}$
\end{document}


The last is just for comparison. Here's the result:

As it's immediately seen, the first has all the spacing wrong because, by rule, TeX transforms the binary operation symbols \times into ordinary symbols since they aren't between "legal" operands. This doesn't happen with \overset and, in fact, the spacings are correct if we compare the second and third lines.

If the "superscripted \cdots doesn't appear between binary operators, it might be necessary to help TeX in adding the correct spacings and

\mathinner{\overset{n}{\cdots}}


would be the right incantation.

## Final version

Taking into account all of the above, I believe that the best is to define a new command:

\newcommand{\scdots}[2][]{\mathinner{#1\overset{#2}{\cdots}#1}}


where an optional argument is reserved for additional spacing in case it's needed (I think to overlong superscripts); so

\scdots{n}

\scdots{\textup{HERE}}


or, maybe,

\scdots[\,]{\textup{HERE}}


if the superscript really clashes with the adjacent terms.

-
$a \stackrel{\scriptstyle\mathrm{HERE}}{\cdots} b$


An alternative if you use amsmath and want to make egreg happy would be \overset

$a \overset{\mathrm{HERE}}{\cdots} b$


-
Thank you very much!! :D – Dan Feb 10 '13 at 10:53
Wouldn't \overset be better? – egreg Feb 10 '13 at 11:07

If you place the n index above the dots, there may actually be some ambiguity as to whether the Cartesian product contains n or n+2 elements (since the qualifier may be perceived not to include the first and last element). To avoid any such ambiguity, you could use the \overbrace command to generate the following expression:

\documentclass{article}
\usepackage{amsmath,amsfonts}
\newcommand{\R}{\mathbb{R}}
\begin{document}
$\overbrace{\R\times\cdots\times\R}^{\text{n times}}$
\end{document}

-