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.

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?

share|improve this question
    
Can you try this? \DeclareMathOperator{\maybe}{\stackrel{?}{=}} –  Chuang Mar 7 '11 at 20:17
    
There must be a better way, but \DeclareMathOperator{\overlay}{?\hspace{-9pt}=} seems to work. With this version you'll have to adjust the spacing depending on the size of the font and the characters being overlaid. –  John Palmieri Mar 7 '11 at 20:39
    
@masterxilo: Thanks for accepting my answer. However in the meantime better answers appeared and one of it should be accepted to indicate the preferred solution to other users with the same issue. –  Martin Scharrer Jul 19 '11 at 10:25

3 Answers 3

up vote 23 down vote accepted

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

share|improve this answer
2  
For centering there's \mathclap if you're willing to load mathtools. –  Hendrik Vogt Mar 7 '11 at 21:10
    
Thanks @Hendrik, mathtools seems to be the way to go. I didn't know it before. As an engineer I'm not doing this much math with LaTeX... –  Martin Scharrer Mar 7 '11 at 21:12
    
Thanks a lot for this, exactly what I was looking for! However, this seems pretty complex for something I'd expect LaTeX to have built-in support for. Doesn't anyone ever use this sign? I use it all the time to start proofs... –  masterxilo Mar 7 '11 at 22:28
    
@masterxilo: I've never seen it before. I don't believe it's a common symbol in math or computer science. Maybe it is unique to your field. –  TH. Mar 10 '11 at 9:04

You could also use the Plain macro \ooalign:

$\mathrel{\ooalign{\hss?\hss\cr=}}$\bye
share|improve this answer
    
(Plain) TeX never ceases to amaze me. –  Andrey Vihrov Mar 8 '11 at 8:02
    
And while morbusg gave a plain TeX MWE, the code between the $ works perfectly in LaTeX. –  Hendrik Vogt Mar 8 '11 at 8:07
1  
See the answer by egreg to similar question why you'd want to use '\hidewidth' instead of '\hss': tex.stackexchange.com/questions/22371/… –  morbusg Jul 19 '11 at 13:42

The just submitted stackengine package is tailor made for combining glyphs. Since it was just submitted to CTAN, it will hopefully propagate this weekend.

\documentclass{article}
\usepackage{stackengine}
\usepackage{graphicx}
\parskip 1ex\parindent 0in
\begin{document}
%Arguments to inset commands{overlay image}{base image}{V-offset}{H-offset}
Relative to bottom vs. top:\\
\bottominset{*}{O}{}{}%
\topinset{*}{O}{}{}%

With V and H shifting:\\
\topinset{*}{O}{}{}%
\topinset{*}{O}{1pt}{}%
\def\stackalignment{r}%
\topinset{*}{O}{2pt}{-1pt}%

Glyphs of different scales:\\
\def\stackalignment{c}%
\def\newi{\stackon[-.4ex]{i}{\scalebox{3}{.}}}
\def\useanchorwidth{T}
Th\newi s uses width of anchor alone

\def\useanchorwidth{F}
Th\newi s uses width of complete stack
\end{document}

enter image description here

share|improve this answer
    
Later revisions of stackengine deprecate \topinset and \bottominset, and replace them both with \stackinset. It gives more alignment options and has a syntax more suited for nesting. –  Steven B. Segletes Feb 4 at 22:45

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.