答案1
这是一个使用tikzmark
库的解决方案,而不是像您可以在此处找到的许多旧解决方案一样重新发明轮子。
\documentclass[12pt]{article}
\usepackage{tikz,amsmath}
\usetikzlibrary{tikzmark}
\begin{document}
\tikzset{
every node/.style={outer sep=1pt},
num/.style={draw,circle,fill=white,font=\tiny,inner sep=1pt}}
\[
(\tikzmarknode{A}{a}+\tikzmarknode{B}{b})(\tikzmarknode{C}{c}+\tikzmarknode{D}{d})=\tikzmarknode{AC}{ac}+\tikzmarknode{AD}{ad}+\tikzmarknode{BC}{bc}+\tikzmarknode{BD}{bd}
\]
\begin{tikzpicture}[remember picture, overlay,cyan]
\draw[->] (A) to[out=60,in=100,looseness=1.5] node[num,pos=0.5] {1} (C) ;
\draw[->] (A) to[out=60,in=110,looseness=1.8] node[num,pos=0.5] {2} (D) ;
\draw[->] (B) to[out=-90,in=-100,looseness=1.6] node[num,pos=0.5] {3} (C) ;
\draw[->] (B) to[out=-90,in=-110,looseness=1.9] node[num,pos=0.5] {4} (D) ;
\foreach \n [count=\i] in {AC,AD,BC,BD}
\node[num,above=10pt] at (\n.south) {\i};
\end{tikzpicture}
\end{document}