[Tex/LaTex] Annotation on mathematical symbol

math-mode

Is it possible to annotate the equal-symbol like in the picture below?

enter image description here

\begin{equation}
E[|A\cup B|]=E[|A|+|B|-|A\cap B|]=E[|A|]+E[|B|]-E[|A\cap B|]
\end{equation}

Best Answer

You could use the \overset macro, which is provided by the amsmath package:

enter image description here

\documentclass{article}
\usepackage{amsmath} % for \overset and \text macros
\begin{document}

\begin{equation}
E[|A\cup B|]=E[|A|+|B|-|A\cap B|] 
\overset{\text{linearity}}{=} 
E[|A|]+E[|B|]-E[|A\cap B|]
\end{equation}\

\end{document}

Addendum: If you also need the vertical arrow below "linearity", just replace

\overset{\text{linearity}}{=}

with

\overset{\substack{\text{linearity} \\ \downarrow}}{=}

The \substack macro is also provided by the amsmath package.

Related Question