How to manually adjust symbol positioning in `\underset`?

Welcome to TeX.Stackexchange.

Edit # 2

To raise the whole operator, could use \scalebox from the graphics package. This translates better, as is found independent of the font size option of the documentclass (the original version doesn't scale equally well to a 10pt or 11pt document)

\documentclass{standalone}
\usepackage{amsmath, graphics}
\newcommand{\upperset}[2]{\:
  \underset{
            \text{\raisebox{1.2ex}{\smash{\scalebox{0.8}{$#1$}}}}%
           }
           {
            \text{\raisebox{0.2ex}{\smash{$#2$}}}
           }
                       \:}
\begin{document}
    $x \underset{{}^u}{\sim} y$ \quad\phantom{\strut}
    $x \upperset{{}^u}{\sim} y$
\end{document}

giving very near to what you wanted:

enter image description here

Original post

Maybe this could be a possible solution:

\documentclass[12pt]{standalone}
\usepackage{amsmath}
\newcommand{\upperset}[2]{%
    \underset{%
        \text{\raisebox{1ex}{\smash{\fontsize{5}{5}$#1$}}}
              }{#2}%
                         }
\begin{document}
    $x \underset{{}^u}{\sim} y$ \quad\phantom{\strut}
    $x \upperset{{}^u}{\sim} y$
\end{document}

which gives this:

enter image description here


If I understand correctly, the OP wants the underset to sit on the baseline.

\documentclass{article}
\usepackage{stackengine,amsmath}
\newcommand\runderset[2][\sim]{\mathrel{\ensurestackMath{%
  \stackengine{-.2pt}{\scriptscriptstyle#2}{#1}{O}{c}{F}{F}{S}}}}
\begin{document}
$a\runderset{x}b$

$a\runderset[=]y b$
\end{document}

enter image description here

Tags:

Math Mode