[Tex/LaTex] Typeset an = with an ! above

stacking-symbolssymbols

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.

Best Answer

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

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}
 \[
   a\stackrel{!}{=} b   % from vanilla LaTeX
 \]

 \[
   a\overset{!}{=} b    % from »amsmath«
 \]
\end{document}

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