1

I want to use the callout shape from tikz in order to explain some elements of a program listed in an alltt environment. But the callout shape is not pointing correctly to the desired element in the listing.

\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}

output

Any clues on how to fix this?

2

You seem to be missing an overlay parameter at the \node defining the callout.

\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}

result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.