TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've seen an equals sign with a small exclamation mark on top being used to say "equals because of data that was given in the problem", for example for a boundary condition or initial value in a differential equation.

A rough picture of what I mean:

f(x) = 4

How do I typeset this in LaTeX? I've tried $=^!$ (which doesn't produce the desired result) and looked through the "relations" section of the Comprehensive List of Symbols without success.

share|improve this question
up vote 55 down vote accepted

That's very easy. And there are at least two identical solutions.


   a\stackrel{!}{=} b   % from vanilla LaTeX

   a\overset{!}{=} b    % from »amsmath«

Both give identical output in this case but \overset should be preferred because it takes care of operator spacing.

share|improve this answer
Is there any reason to use the ams solution over the plain TeX version? – Seamus Dec 17 '10 at 18:05
»amsmath« is always preferable. – Thorsten Donig Dec 17 '10 at 22:18
in most cases, it's preferable for some reason! For my part I'm not skeptical that it is better here, but I would be interested to know in what ways it's better :-) – Peter LeFanu Lumsdaine Dec 21 '10 at 6:32
@Peter: when you use amsmath, \stackrel can be considered obsolete as \overset does the same thing better, because it gives correct spacing with binary operators (like +, \oplus, etc.) and ordinary symbols. – Philippe Goutet Jan 20 '11 at 13:07
@ThorstenDonig: The output is ugly when I want to put a questionmark over equals sign, because "?" is too high above "=". How can I make it appear lower, right above "="? – Leon Aug 22 '12 at 7:02

is the command you search.


will lead to the sign you want to typeset. The first argument sits on top of the second argument, where the first one is smaller than the second one.

share|improve this answer

just to add another one....

share|improve this answer
Also fine! Just the spacing is too tight for a relation symbol, but you could add \mathrel around the expression. – Stefan Kottwitz Dec 17 '10 at 18:28

If you needed to customize the separation between the overset, here's a way it could be done. The default is 3pt, halfway between the two examples shown.

 a \mathrel{\stackon[5pt]{$=$}{$\scriptstyle!$}} b
 a \mathrel{\stackon[1pt]{$=$}{$\scriptstyle!$}} b

enter image description here

share|improve this answer

Here's an oldie goldie

\[ a \buildrel!\over= b \]
share|improve this answer

Your Answer


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.