3

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}
  • Please do not do this in general. Might work fine with pen and paper or on a black board. But it should not be used in typeset text. – daleif Feb 3 '16 at 19:48
  • 1
    @daleif Nonsense; it might not be appropriate in an academic paper, but there are plenty of contexts (textbooks, lecture notes, presentation slides) where annotating a mathematical expression is by far the clearest way to explain what's going on. – dbmag9 Feb 3 '16 at 20:24
  • 1
    @dbmag9 I beg to differ, good typographic manners should be used no matter if it is an academic paper or not. How else are people going to learn propper typography if some rules only apply to certain types of documents. – daleif Feb 3 '16 at 20:34
  • @daleif To take a simple example, if I am writing a textbook explaining the terms 'numerator' and 'denominator', by far the clearest way to explain them is by labelling the two on a fraction. We might also explain in words below, but for many the intellectual effort of reading a label and cross-referencing with what is above can make that far more difficult to follow. There are plenty of things appropriate in some contexts but not others. – dbmag9 Feb 3 '16 at 20:43
3

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.

| improve this answer | |
3

You can use \overset and \substack, with a trick for making the annotation to have zero width:

\documentclass{article}
\usepackage{amsmath}

\newcommand{\annoterel}[2]{%
  \overset{%
    \substack{\hidewidth\text{#1}\hidewidth\\\downarrow}%
  }{#2}%
}

\begin{document}

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

\end{document}

enter image description here

A slight modification if you need the arrow to be taller, maybe for accommodating fractions or other big symbols:

\newcommand{\annoterel}[3][]{%
  \overset{%
    \substack{\hidewidth\text{#2}\hidewidth\\#1\downarrow}%
  }{#3}%
}

Now the macro \annoterel has an optional argument that should be one of \big, \Big, \bigg or \Bigg; for instance

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

would produce

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.