[Tex/LaTex] How to get text above and below text

text manipulation

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

Hope you can help!

Best Answer

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.