![数学文本上方、下方和周围的箭头?](https://linux22.com/image/340634/%E6%95%B0%E5%AD%A6%E6%96%87%E6%9C%AC%E4%B8%8A%E6%96%B9%E3%80%81%E4%B8%8B%E6%96%B9%E5%92%8C%E5%91%A8%E5%9B%B4%E7%9A%84%E7%AE%AD%E5%A4%B4%EF%BC%9F.png)
答案1
TikZ 中的解决方案是将数学表达式的组成部分设置为一系列节点。然后将注释标签放置为节点。最后在节点之间绘制箭头。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage{bookman}
\begin{document}
% \[
% \lambda x.\,(\lambda x.\, x\,y)\,
% (x\,(\lambda x.\,\lambda y.\,y\,z\,x))
% \]
\[
\begin{tikzpicture}[
inner sep=0pt,
outer sep=0pt,
baseline=(lx_1.base),
]
\path[every node/.append style={anchor=base west}]
(0, 0)
\foreach \name/\code in {
lx_1/\lambda x,
tmp/.\,(,
lx_2/\lambda x,
tmp/.\,,
x_1/x,
tmp/\,,
y_1/y,
tmp/)\,(,
x_2/x,
tmp/\,(,
lx_3/\lambda x,
tmp/.\,,
ly_1/\lambda y,
tmp/.\,,
y_2/y,
tmp/\,,
z_1/z,
tmp/\,,
x_3/x,
tmp/))%
} {
node (\name) {$\code$}
(\name.base east)
}
;
\path[
every node/.append style={
anchor=base,
font=\slshape\scriptsize,
},
]
% Annotation: frei
(y_1.base) -- node[above=1.2\baselineskip] (frei) {frei} (z_1)
% 4 annotations: gebunden
(lx_1.base) -- node[below=3\baselineskip] (geb_1) {gebunden} (x_2)
(lx_2.base) -- node[below=1.4\baselineskip] (geb_2) {gebunden} (x_1)
(lx_3.base) -- node[below=3\baselineskip] (geb_3) {gebunden} (x_3)
(ly_1.base) -- node[below=1.4\baselineskip] (geb_4) {gebunden} (y_2)
;
\begin{scope}[
>={Stealth[length=5pt]},
thick,
rounded corners=2pt,
shorten <=.3em,
shorten >=.3em,
]
\draw[->] (frei) -| (y_1);
\draw[->] (frei) -| (z_1);
\def\GebArrow#1#2#3{
\draw[->]
(#2.north) ++(0, .3em) coordinate (tmp)
(#1) |- (tmp) -| (#3)
;%
}
\GebArrow{x_2}{geb_1}{lx_1}
\GebArrow{x_1}{geb_2}{lx_2}
\GebArrow{x_3}{geb_3}{lx_3}
\GebArrow{y_2}{geb_4}{ly_1}
\end{scope}
\end{tikzpicture}
\]
\end{document}