I am trying to draw two nodes who are on a different layer. The background layer consists of the 'big' node and the foreground layer consist of the 'small' node. Only the big node can have a background colour without affecting the background colour of the small one. Below is an image that is produced by the MWE. the 'small' node and it's background should be white.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{backgrounds,scopes}
\usetikzlibrary{arrows,positioning,shapes.geometric}
\begin{document}
\begin{tikzpicture}[remember picture]
{[on background layer]
\node (rect) at (4,2) [draw,thick,minimum width=2cm,minimum height=2cm, fill=red!30] {};
}
\node (smallRect) at (4,2) [draw,thick,minimum width=1cm, minimum height=1cm] {Small};
\end{tikzpicture}
\end{document}
I thought that the on background layer provided by the backgrounds TikZ library should work, but am I misunderstanding it?
fill=white
to the small square. – Alain Merigot Sep 27 '19 at 10:33