# TiKZ copy shadow with watermark issue

In the MWE we can see shadowed nodes with texts. If we don't add a watermark, the result is as desired on the first TiKZ node, but with a watermark, the fill=write option required by the copy shadow option fills the node with white taking off a region of the water mark, so I added the text opacity and fill opacity options (shown on the second TiKZ picture), but in this case the shadow is dropped, predictably due to the way shadows on TiKZ works.

How can I achieve the look of the first node with its shadows and also transparency to not overlap the watermark?

MWE (requires example-grid-100x100bp.jpg from mwe package):

\documentclass{article}
\usepackage{graphicx}
\usepackage[absolute]{textpos}
\parindent0pt
\begin{document}
\begin{textblock*}{\textwidth}(0pt,0pt)
\includegraphics[scale=2]{example-grid-100x100bp.jpg}
\end{textblock*}
\begin{tikzpicture}
\node[draw=black, fill=white, line width=1pt, rounded corners=3pt, copy shadow={top color=black, bottom color=black, shadow xshift=2pt, shadow yshift=-2pt}]{test1};
\end{tikzpicture}
\begin{tikzpicture}
\node[draw=black, fill=white, fill opacity=0, text opacity=1, line width=1pt, rounded corners=3pt, copy shadow={top color=black, bottom color=black, shadow xshift=2pt, shadow yshift=-2pt}]{test2};
\end{tikzpicture}
\end{document}

• what do you mean by the watermark? May 16, 2020 at 15:45
• @UlrikeFischer I mean whatever image behind the TiKZ picture; in my case I'll place a watermark with textblock but generally speaking it doesn't have to be a watermark. Thank you! May 17, 2020 at 1:10

I hope not to have misread the question. You can use a reverse clip. But unless one wants to go too hacky, this may mean that one has to draw the node twice. So the steps here are

1. Draw node without shadow and save node boundary path.
2. Protect node boundary path.
3. Draw node with shadow and fill opacity=1.

One could try to hack the shadow mechanism but not sure if this is worth the effort.

\documentclass{article}
\usepackage{tikz}
% based on
% https://tex.stackexchange.com/a/38995/121799
% https://tex.stackexchange.com/a/76216
% https://tex.stackexchange.com/a/59168/194703
% https://tex.stackexchange.com/q/448920/194703
\makeatletter
\tikzset{
reuse path/.code={\pgfsyssoftpath@setcurrentpath{#1}}
}
\tikzset{even odd clip/.code={\pgfseteorule},
protect/.code={
\clip[overlay,even odd clip,reuse path=#1]
(-6383.99999pt,-6383.99999pt) rectangle (6383.99999pt,6383.99999pt);
}}
\usepackage[absolute]{textpos}
\parindent0pt
\begin{document}
\begin{textblock*}{\textwidth}(0pt,0pt)
\includegraphics[scale=2]{example-grid-100x100bp.jpg}
\end{textblock*}
\begin{tikzpicture}
\node[draw=black, fill=white, line width=1pt, rounded corners=3pt, copy shadow={top color=black, bottom color=black, shadow xshift=2pt, shadow yshift=-2pt}]{test1};
\end{tikzpicture}
\begin{tikzpicture}
\node[draw=black, fill=white, fill opacity=0, text opacity=1, line width=1pt,
rounded corners=3pt,save path=\tmprotect,

• Thank you! it works for me; now I'm trying to understand! Why all the code after makeatletter? specially, what does those dimensions mean? May 17, 2020 at 1:13