Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

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
}}}

Result

share|improve this answer
add comment

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).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.