Here are two other solutions.
In the first solution, I remove the overlay
option from your tikzpicture
and compute the depth of yours annotations (the distance between the top of first node and the bottom of the last node).
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{calc,tikzmark}
\begin{document}
A \emph{complex number} is an expression of the form
\[
z = \tikzmark{b}b\cdot\tikzmark{i}i+\tikzmark{a}a
\begin{tikzpicture}[
, line join=round
, line cap=round
, remember picture
, baseline=0 % to compute depth...
]
\begin{scope}[overlay]
\draw[<-, thick] ([shift={(3pt,-2pt)}]pic cs:b) |- ([shift={(-10pt, -10pt)}]pic cs:b)
node[anchor=mid east] (a) {``imaginary part'' $\Im(z)\in\mathbb{R}$};
\draw[<-, thick] ([shift={(4pt,-2pt)}]pic cs:i) |- ([shift={(-15pt,-25pt)}]pic cs:i)
node[anchor=mid east] {``imaginary unit'' $i^2=-1$};
\draw[<-, thick] ([shift={(4pt,-2pt)}]pic cs:a) |- ([shift={(15pt,-25pt)}]pic cs:a)
node[anchor=mid west] (b) {``real part'' $\Re(z)\in\mathbb{R}$};\
\end{scope}
\path let \p1=(a.north west), \p2=(b.south east) in (0,0) -- (0,\y2-\y1);
\end{tikzpicture}
\]
The collection of complex numbers is denoted by $\mathbb{C}$.
\end{document}
The second solution uses \tikzmarknode
and fit
to compute the math targets with margins then positions the commentary nodes with the same margins and finally draws the arrows. The syntax is more regular: no shift
and just two distances (the 2pt
margin and the 1em
horizontal shifting).
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{calc,tikzmark,fit}
\begin{document}
A \emph{complex number} is an expression of the form
\begin{equation}
z = \tikzmarknode{b}{b}\cdot\tikzmarknode{i}{i}+\tikzmarknode{a}{a}
\begin{tikzpicture}[
, line join=round
, line cap=round
, remember picture
, baseline=0 % to compute depth
]
\begin{scope}[overlay]
\tikzset{
text node/.style={inner sep=2pt},
fitmath/.style={node contents={},text node,fit=#1},
}
% math target nodes
\node[fitmath=(b),name=bt];
\node[fitmath=(i),name=it];
\node[fitmath=(a),name=at];
% commentary nodes
\path (bt.south) ++ (-1em,0)
node[text node,anchor=north east] (bc) {``imaginary part'' $\Im(z)\in\mathbb{R}$};
\path (bc.south east)
node[text node,anchor=north east] (ic) {``imaginary unit'' $i^2=-1$};
\path (ic.mid -| at) ++ (1em,0)
node[text node,anchor=mid west] (ac) {``real part'' $\Re(z)\in\mathbb{R}$};
% arrows between nodes
\draw[<-, thick] (bt.south) |- (bc.mid east);
\draw[<-, thick] (it.south) |- (ic.mid east);
\draw[<-, thick] (at.south) |- (ac.mid west);
\end{scope}
\path let \p1=(a.south), \p2=(ac.south) in (0,0) -- (0,\y2-\y1);
\end{tikzpicture}
\end{equation}
The collection of complex numbers is denoted by $\mathbb{C}$.
\end{document}