[Tex/LaTex] Overlay symbol with another

math-modeoverlayssymbols

Is it possible to overlay a symbol with another?

I want to write an equal sign with a question mark overlayed (or the other way around).

Note I don't want

\stackrel{?}{=}

I want the question mark to be right on top, to cross over the equal sign (which creates kind of a new sign).

Is this possible? How? Or is there a one character sign for this?

Best Answer

You can overlay the symbols the following way: Box the wider one and let the other one lap over it (using \rlap or \llap). The correct centering is achieved by placing the second character into a box with the equal width but using \hss to center it. The correct size for the different math modes can be adjusted using \mathchoice.

\documentclass{article}
\def\qeq{\mathrel{%
    \mathchoice{\QEQ}{\QEQ}{\scriptsize\QEQ}{\tiny\QEQ}%
}}
\def\QEQ{{%
    \setbox0\hbox{=}%
    \rlap{\hbox to \wd0{\hss?\hss}}\box0
}}

\textwidth=2cm
\begin{document}

$ A \qeq B $

$ A = B $

\[ A \qeq B \]
\[ A = B \]

$ S_{ A \qeq B } $

$ S_{ A = B } $

$ S_{S_{ A \qeq B }} $

$ S_{S_{ A = B }} $

\end{document}

Result

Result