LaTeX TikZ Option execute at end picture
There is a LaTeX TikZ option execute at end picture1:
/tikz/execute at end picture=āØcodeā©
This option installs āØcodeā© that will be executed at the end of the picture. Using this option multiple times will cause the code to accumulate. This option must also be given in the optional argument of the {tikzpicture} environment.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
\documentclass[tikz]{standalone}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}[execute at end picture=%
{
\begin{pgfonlayer}{background}
\path[fill=yellow,rounded corners]
(current bounding box.south west) rectangle
(current bounding box.north east);
\end{pgfonlayer}
}]
\node at (0,0) {X};
\node at (2,1) {Y};
\end{tikzpicture}
\end{document}

By the way, there is another similar option execute at begin picture1:
/tikz/execute at begin picture=āØcodeā©
This option causes āØcodeā© to be executed at the beginning of the picture. This option must be given in the argument of the {tikzpicture} environment itself since this option will not have an effect otherwise. After all, the picture has already āstartedā later on. The effect of multiply setting this option accumulates.
This option is mainly used in styles like the every picture style to execute certain code at the start of a picture.
but if we use it in the above case, we canāt get a normal output.
References