12

How would I do {text}_{i=1}^{i=n} with the written exactly above and below the text?

Hope you can help!

Ruben
  • 13,448
user82130
  • 197
  • 2
    Without a proper context and some information about the intended meaning and use it's hard to say which is the best option. In the preamble: \usepackage{amsmath} in the document \[ \overset{i=n}{\underset{i=1}{text}} \] – Gonzalo Medina Jul 21 '15 at 18:20

4 Answers4

11

I assume you'll want the subscript and superscript material to be in display-style math mode and to use a smaller font size than what's used for the "text" string. Sort of like \sum_{i=0}^{\infty}, except for the use of the string "text" instead of the large summation symbol, right?

If these assumptions are correct, you could use the \DeclareMathOperator* directive of the amsmath package to achieve your objective.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator*{\sometext}{text} % "\text" is already taken...
\begin{document}
\[
\sometext_{i=1}^{i=n} % not "{\sometext}"
\]
\end{document}
Mico
  • 506,678
  • 2
    Or \[ \overset{i=n}{\underset{i=1}{text}} \] could also be an option. No info about the context for the expression, it's difficult to decide the best approach. +1, by the way. – Gonzalo Medina Jul 21 '15 at 18:22
  • @GonzaloMedina - It definitely would be helpful to have more context. Your suggestion has the advantage of "working" in both inline-style and display-style math modes. – Mico Jul 21 '15 at 18:26
  • Does this not limit the text to the letters t-e-x-t, rather than arbitrary text? – Steven B. Segletes Jul 21 '15 at 18:29
  • @StevenB.Segletes - I honestly don't know what the intended use case may be. I was assuming that the string "text" (or whatever it may be in practice...) is meant to be fixed. Naturally, this assumption may not be correct. – Mico Jul 21 '15 at 18:35
10

Here are two ways:

\documentclass{article}
\usepackage{amsmath,stackengine}
\stackMath
\begin{document}
\[
\setstackgap{S}{2pt}
\stackunder{\stackon{\text{text}}{\scriptstyle i=n}}{\scriptstyle i=1}
\quad
\underset{i=1}{\overset{i=n}{\text{text}}}
\]
\end{document}

enter image description here

The gap between the text and the over/under-set is defined with \setstackgap{S}{2pt} for the stackengine approach on the left.

Either of these approaches will work in \displaystyle (shown) or in \textstyle. Note, however, that in \textstyle, the line spacing will be affected.

3

In addition to the other suggestions you could use: \mathop together with \operatorname from the amsmath package:

\documentclass{article}
\usepackage{amsmath}
\newcommand\mymathop[1]{\mathop{\operatorname{#1}}}
\begin{document}

\[
  \mymathop{text}_{i=1}^{i=n}
\]

This is in a paragraph: $\mymathop{text}_{i=1}^{i=n}$ or $\displaystyle\mymathop{text}_{i=1}^{i=n}$.

\end{document}

enter image description here

A.Ellett
  • 50,533
1

MWE

\documentclass{article}
\usepackage{stackrel}
\begin{document}
Some $\stackrel[i=1]{i=n}{\mathrm{text}}$ in line.
\end{document}
Fran
  • 80,769