# “blur shadow” messes up other nodes!

Consider the following code:

\documentclass{article}

\usepackage{tikz}

\pgfdeclarelayer{bg}
\pgfsetlayers{bg,main}

\begin{document}

\begin{tikzpicture}
\tikzstyle{MyNode}=[%
minimum height=8mm, minimum width=10mm,
fill=gray]

\begin{scope}
\node[MyNode]{A};
\begin{pgfonlayer}{bg}
\node at (1,0){A-bg};
\end{pgfonlayer}
\end{scope}

\begin{scope}[xshift=55mm]
\node[MyNode]{A};
\begin{pgfonlayer}{bg}
\node at (1,0){A-bg};
\end{pgfonlayer}
\end{scope}

\end{tikzpicture}
\end{document}


When the line blur shadow={shadow blur steps=5} exists, content of \begin{pgfonlayer}{bg} won't be in the PDF (or at least I cannot see it). When I comment that line, I can see it. What is it that I am missing? (I tried this code on overleaf and on my computer with pdflatex. The behavior is the same.) Below pictures are screenshots when the line is commented or not commented.

EDIT: I updated the code to show why switching the order of scopes does not help (no matter what order you put them, the one that comes first is missing the content of its \begin{pgfonlayer}{bg}).

• pdflatex --version gives me pdfTeX 3.14159265-2.6-1.40.20 (TeX Live 2019). I tried Adobe Acrobat, the Preview that is the default app for this on macOS, and whatever is used internally by VS Code and Overleaf. – Koosha Jan 14 at 4:54
• My bad. I didn't read the question carefully enough. +1. If you change the order, it seems to work. – Schrödinger's cat Jan 14 at 5:00
• Changing the order does not help me, since in my complete example, both nodes on the right sides should have the blur and both nodes in the left sides should have the \begin{pgfonlayer}{bg}. – Koosha Jan 14 at 5:04
• I meant put \begin{scope}[xshift=55mm] \node[MyNode]{A}; \end{scope} before the other stuff. – Schrödinger's cat Jan 14 at 5:06
• I understand. That does not help. Suppose the content of both scopes is \node[MyNode]{A}; \begin{pgfonlayer}{bg} \node at (1,0){A-bg}; \end{pgfonlayer} (the only difference is one of them is shifted). Then it does not matter which one comes first. – Koosha Jan 14 at 5:10

This is only (and at best) a workaround. You can place the background node after the node with the shadow. (Placing it before sort of defeats the purpose of putting it on a lower layer, but I understand that this is just a minimal working example and that there can be situations where this really makes sense.)

\documentclass{article}
\usepackage{tikz}
\pgfdeclarelayer{bg}
\begin{document}

\begin{tikzpicture}[MyNode/.style={minimum height=8mm, minimum width=15mm,
fill=gray
}]
\pgfsetlayers{bg,main}

\begin{scope}
\node{A};
\end{scope}

\begin{scope}[xshift=55mm]
\node[MyNode]{A};
\end{scope}

\begin{pgfonlayer}{bg}
\node{A-bg};
\end{pgfonlayer}

\end{tikzpicture}
\end{document}


As for the question why this happens I am not entirely sure. Both the layers and shadows.blur create some boxes that they shift around. For some reason the creation of the boxes by shadows.blur seems to destroy the boxes on the background layer. (However, putting \node[MyNode]{A}; on the bg layer also solves the problem.

If there is a real answer, I will be happy to remove this workaround.