我想使用callout
形状来tikz
解释alltt
环境中列出的程序的一些元素。但callout
形状没有正确指向列表中所需的元素。
\documentclass{article}
\usepackage[papersize={7cm,2cm}]{geometry}
\usepackage{alltt}
\usepackage{tikz}
\usepgflibrary{shapes.callouts}
\usetikzlibrary{decorations.text}%workaround for undefined \pgf@test
\newcommand{\refnode}[2]{\tikz[remember picture,baseline=-.5ex]{\node[draw](#1){#2};}}
\begin{document}
\begin{alltt}
let \refnode{r}{greatest} a b =
if a > b then a else b
\end{alltt}
\tikz[remember picture,overlay]{%
\node[rectangle callout,fill=green!30,callout absolute pointer={(r)}]
at (4,0) {function name};}
\end{document}
关于如何解决这个问题有什么线索吗?
答案1
您似乎在定义标注时缺少一个overlay
参数。\node
\documentclass{article}
\usepackage[papersize={7cm,2cm}]{geometry}
\usepackage{alltt}
\usepackage{tikz}
\usetikzlibrary{shapes.callouts}
\usetikzlibrary{decorations.text}%workaround for undefined \pgf@test
\newcommand{\refnode}[2]{%
\tikz[remember picture,baseline=-.5ex]{%
\node[draw](#1){#2};
}%
}
\begin{document}
\begin{alltt}
let \refnode{r}{greatest} a b =
if a > b then a else b
\end{alltt}
\tikz[remember picture,overlay]{%
\node[rectangle callout,fill=green!30,overlay,%
callout absolute pointer={(r.east)}] at (4,0) {function name};
}
\end{document}