1

In the Tik Z & PGF Manual for Version 2.10-CVS, page 120/880 there is an example to create a yellow rounded rectangular background as below:

enter image description here

And here is the code I used:

\documentclass{standalone}
\usepackage{tikz}
\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}

However I got an error as below: ! Package pgf Error: Sorry, the requested layer 'background' could not be found . Maybe you misspelled it?.

Do you know how to fix this? Thanks for your support in advance.

3

In the manual you must to use \usetikzlibrary{backgrounds}. It is written in gray color:

enter image description here

\documentclass{standalone}
\usepackage{tikz}
\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}

Here there is the output:

enter image description here

2
  • 1
    I appreciate your excellent answer! Thanks! – Aria Jul 12 '20 at 22:30
  • 1
    @Aria happy to help you :-) "excellent" it is not exact ahahahah. – Sebastiano Jul 12 '20 at 22:31

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.