I have been using \overset
and \underset
to stack text, e.g.:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\overset{\text{a}}{\text{b}}$ \\
$\underset{\text{c}}{\text{d}}$
\end{document}
The results seems better proportioned font size, line spacing, and baseline positioning than other solutions I have found for stacked text, however, recently, I found some incompatibilities between another package and amsmath
.
- How can I create an alternative to these commands which does not use math mode, but otherwise has identical font sizes and proportions (so that the output is visually the same)?
I found the source code for \overset
and \underset
in amsmath.dtx:
\newcommand{\overset}[2]{\binrel@{#2}%
\binrel@@{\mathop{\kern\z@#2}\limits^{#1}}}
\newcommand{\underset}[2]{\binrel@{#2}%
\binrel@@{\mathop{\kern\z@#2}\limits_{#1}}}
It seems to be using some code for \limits
to define the stacking, however, I can't find anything in the rest of the source of the amsmath
package showing how \limits
works or how to use it without first specifying math mode.
Best Answer
\limits
is a TeX primitive used in the specification of super- and subscripts for math operators.You could still use math mode, but just force the arguments to be typeset in text mode via some manipulation of the original
\overset
and\underset
definitions:In the above minimal example, the redefinition of
\overset
and\underset
style sets the two arguments in math mode, although it is not required to be specified explicitly. Additionally, since you're not interested in a math mode application, the binary relation spacing has been removed.