# Annotating maths formulas?

Is it possible to draw annotations inside math formulas ? I want to see if it helps for pedagogical purposes.

For example I would like to draw the arrow in red between the two symbols in the following formula, to highlight the fact that they are the same:

\documentclass[10pt,landscape,a4paper]{article}
\begin{document}

$$P ( \xi \in B ) = \int_B f_{\xi} dx$$

\end{document}

• Can be much easier if you choose a certain color instead. May 22, 2021 at 10:02

Quite easy with pst-node: define both B's as rnodes and connect them by one of the node connections.

Unrelated: don't use $$…$$ in LaTeX, this is a plain TeX syntax, and you'll have bad vertical spacing. Use $…$ instead.

\documentclass[10pt,landscape,a4paper]{article}
\usepackage{pst-node}

\begin{document}

$P ( \xi \in \rnode{B1}{B} ) = \int_{\rnode{B2}{B}} f_{\xi} dx \psset{arrowinset=0.1, linejoin=1} \ncbar[linecolor=red, angle=-90, nodesep=2pt]{<->}{B1}{B2}$

\end{document}


You can do that with tikz:

\documentclass[10pt,landscape,a4paper]{article}
\usepackage    {tikz}
\usetikzlibrary{babel} % for issues with some babel packages
\usetikzlibrary{tikzmark}

\begin{document}
$P ( \xi \in \tikzmarknode{B1}B ) = \int_{\tikzmarknode{B2}B} f_{\xi}\,dx$
\begin{tikzpicture}[overlay,remember picture]
\draw[<->,red,out=-100,in=-100] ([yshift=-2pt]B1.south) to ([yshift=-2pt]B2.south);
\end{tikzpicture}
\end{document}