I would like to define a command with three arguments which stacks three symbols or text on top of each other.
The \tmb
command below does that but creates a bit too much vertical space between the middle and the bottom
symbol. The commands \trialone
and \trialtwo
try to fix that with \raisebox
but fail (see below).
Then there is a contender based on \mystack
, but if the middle symbol is a \to
, then it is not vertically
aligned with the division bar of a fraction right next to it, for example. Also, there is too little space
around the three stacked symbols (to the left and right); see also below.
\documentclass{scrartcl}
\usepackage{amsmath}
\newcommand{\tmb}[3]{\underset{{\scriptscriptstyle #3}}{\overset{{\scriptscriptstyle #1}}{#2}}}% *t*op, *m*iddle, *b*ottom command
\newcommand{\trialone}[3]{\underset{{\scriptscriptstyle\raisebox{2mm}{#3}}}{\overset{{\scriptscriptstyle #1}}{#2}}}
\newcommand{\trialtwo}[3]{\underset{{\raisebox{2mm}{\tiny #3}}}{\overset{\scriptscriptstyle #1}{#2}}}
\newcommand{\mystack}[3]{\substack{#1\\{\textstyle #2}\\[-0.3mm]#3}}
\begin{document}
\begin{itemize}
\item LHS $\tmb{\text{approx.}}{\to}{\text{$n$ large}}$ RHS. Here you see too much vertical space for what's below the arrow.
\item LHS $\tmb{\text{approx.}}{\sim}{\text{$n$ large}}$ RHS. Here you also see too much vertical space for what's below the tilde.
\item LHS $\trialone{\text{approx.}}{\sim}{\text{$n$ large}}$ RHS. Font size not respected.
\item LHS $\trialtwo{\text{approx.}}{\sim}{\text{$n$ large}}$ RHS. Fails if the
command contains scriptscriptstyle instead of tiny. Still, the raisebox
command does not seem to work.
\item LHS $\mystack{\text{approx.}}{\sim}{\text{$n$ large}}$ RHS. Looks okay, but the tilde and other middle symbols are not vertically aligned correctly, see
\begin{align*}
\frac{A}{B} \mystack{\text{approx.}}{\to}{\text{$n$ large}} \frac{C}{D} \quad\text{versus}\quad \frac{A}{B}\tmb{\text{approx.}}{\to}{\text{$n$ large}} \frac{C}{D}.
\end{align*}
We see that the arrow on the left is vertically not aligned with the division bars of the two fractions. Also, there is not sufficient space around the command. None of these problems appears on the right (there is only too much vertical space between the arrow and the ``$n$ large''.
\end{itemize}
\end{document}
\sim
or\to
?\fboxsep=-\fboxrule\fbox{$\sim$}
you'll see the reason for the larger space below the tilde. However, a solution which works with the tilde might not work as well with other symbols.\sim
and\to
are probably used in most cases (I used\tmb
for long time and only realized that the spacing is off when combining it with\sim
). @campa: interesting, so it's more a problem of the symbol\sim
then... Ah, I didn't try to adjust that vertically, maybe that's easier.