Debian Codegraph @

texmf-dist/doc/latex/codeanatomy/demo-anatomy-of-an-if-statement.tex

raw
1 %% LaTeX2e file `tmp-gen-anatomy-of-an-if-statement.tex'
2 %% generated by the `filecontents' environment
3 %% from source `codeanatomy.lstlisting' on 2025/10/19.
4 %%
5 \lstset{escapeinside={!}{!}}
6 \begin{lrbox}{\mycodebox}
7 \begin{lstlisting}
8 if (!\cPart{e}{x > y}!)
9 {
10 int t = x;!\mtPoint{tr}!
11 x = y;
12 !\mbPoint{bl}! y = t;!\extremPoint{br}!
13 }
14 \end{lstlisting}
15 \end{lrbox}
16
17 \begin{tikzpicture}[remember picture]
18 % {[on background layer]\draw[code grid debug] (-2.5,-0.5) grid (2.5,2.5);}
19 \node(code) [anatomy] at (0,0) {\usebox\mycodebox};
20
21 \fitExtrem{b}{(tr) (bl) (br)}
22 % Annotation
23 \codeAnnotation{eText} (1,3.5) {boolean\\expression}
24 \codeAnnotation{bText} (-1,1.125) {sequence\\of \extremPoint{bPoint}[0.75ex]\\statements}
25 % Arrow
26 \draw[->,annotation] (eText) -- (e);
27 \draw[->,annotation] (bPoint) -- (b);
28 \end{tikzpicture}