# How can I adjust the fine positioning of stackrel?

I use stackrel to define a custom stacked relation symbol:

\def\qMapsfrom{\stackrel{?}{\Mapsfrom}}


However, the question mark is not centered properly and has too much distance from the \Mapsfrom. Is there a way to fine-adjust the vertical and horizontal spacing of \stackrel?

-

For the vertical spacing you can use \raisebox{<amount>}{<content>} to raise or lower (negative amount) the content. The horizontal centering was already shown for the similar question Overlay symbol with another, which might need a little adjustment here:

Here my suggestion. It works in the shown tests in all the different math modes.

\documentclass{article}

\usepackage{amsmath}
\usepackage{stmaryrd}

\newcommand\qMapsfrom{\mathrel{%
\mathchoice{\qmf}{\qmf}{\scriptsize\qmf}{\tiny\qmf}%
}}
\newcommand\qmf{{%
\setbox0\hbox{$\Mapsfrom$}%
\rlap{\hbox to \wd0{\hss\hss\hss\raisebox{-.15\height}{?}\hss}}\box0
}}

\textwidth=2cm
\begin{document}

$A \qMapsfrom B$

$A \Mapsfrom B$

$A \qMapsfrom B$
$A \Mapsfrom B$

$S_{ A \qMapsfrom B }$

$S_{ A \Mapsfrom B }$

$S_{S_{ A \qMapsfrom B }}$

$S_{S_{ A \Mapsfrom B }}$

\end{document}


## Update:

I just remembered that amsmaths \text can be used for math style depending scaling. It already uses similar code as the one above. This simplifies the macro to:

\newcommand\qMapsfrom{\mathrel{\text{%
\setbox0\hbox{$\Mapsfrom$}%
\rlap{\hbox to \wd0{\hss\hss\hss\raisebox{-.15\height}{?}\hss}}\box0
}}}


-

There's a neater way, which avoids many of Martin's boxes

\newcommand{\qMapsfrom}{\mathrel{\mathpalette\qmf\relax}}
\newcommand{\qmf}[2]{%
\ooalign{$#1\Mapsfrom$\cr
\hidewidth\raisebox{-.15ex}{$#1\mkern6mu?$}\hidewidth\cr}}


The code is actually inspired by Martin's, but seems to be clearer and more easily adaptable to other fonts (some trial and error is necessary for positioning correctly the question mark).

-