# How do you locally override/cancel a shadow?

In the example below, the style I've defined for every node uses a drop shadow. My a node uses that default style without modification. However, I'd like to override that style for node b, which should have no shadow at all.

I've tried to

• pass fill opacity=0 to drop shadow locally, or
• pass nothing to the option (drop shadow=,),

but node b still has a shadow.

I've read section 66 of the TikZ/PGF (v3.0) manual about the shadows library, but I haven't found a way of overriding a drop shadow style. Any help?

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning,shadows}

\tikzset{
every node/.style={
draw,
drop shadow = {opacity=0.5,fill=red},
fill        = white,
},
}

\begin{document}
\begin{tikzpicture}
\node (a) {a};
\node[
right=of a,
drop shadow={opacity=0}, % the shadow is still there
% drop shadow=,            % also no effet
] (b) {b};
\end{tikzpicture}
\end{document}

-
Here is hack that seems to work: drop shadow={fill=white, opacity=1, draw=white}. –  Peter Grill Aug 28 '14 at 1:20
@PeterGrill Unfortunately, that only colours the shadow white; that won't do, because I may have stuff in the background. –  Jubobs Aug 28 '14 at 7:38

## 2 Answers

A shadow adds a preaction. TikZ does not provide a way to remove preactions. In your preamble, you may define your own reset preactions key :

\makeatletter
\tikzset{reset preactions/.code={\def\tikz@preactions{}}}
\makeatother


Here is a complete example:

\documentclass[margin=2mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning,shadows}

\makeatletter
\tikzset{reset preactions/.code={\def\tikz@preactions{}}}
\makeatother

\tikzset{
every node/.style={
draw,
drop shadow = {opacity=0.5,fill=red},
fill        = white,
},
}

\begin{document}
\begin{tikzpicture}
\node (a) {a};
\node[right=of a,reset preactions] (b) {b};
\end{tikzpicture}
\end{document}


As suggested by Claudio Fiandrino in its comment, to apply this new key to all nodes in a scope, you may append it to every node style:

\documentclass[margin=2mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning,shadows}

\makeatletter
\tikzset{reset preactions/.code={\def\tikz@preactions{}}}
\makeatother

\tikzset{
every node/.style={
draw,
drop shadow = {opacity=0.5,fill=red},
fill        = white,
},
}

\begin{document}
\begin{tikzpicture}
\node (a) {a};
\begin{scope}[every node/.append style={reset preactions}]
\node[right=of a] (b) {b};
\node[right=of b] (c) {c};
\end{scope}
\end{tikzpicture}
\end{document}

-
Thanks for that, Paul. –  Jubobs Aug 28 '14 at 7:35
However, i don't know how to do it work in several nodes enclosed in a scope (like in my answer) without add reset preaction in each one. –  skpblack Aug 28 '14 at 10:49
@skpblack: Try the following: \begin{scope}[every node/.append style={reset preaction}] –  Claudio Fiandrino Aug 28 '14 at 11:51

What if we enclose the node (or nodes that we don't want to shade) in a scope with the option general shadow/.style={}?

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning,shadows}

\tikzset{
every node/.style={
draw,
drop shadow = {opacity=0.5,fill=red},
fill        = white,
},
}

\begin{document}
\begin{tikzpicture}
\node (a) {a};
\begin{scope}[general shadow/.style={}]
\node[right=of a] (b) {b};
\end{scope}
\end{tikzpicture}
\end{document}


With more nodes we can better observe the effect.

\begin{tikzpicture}
\node (a) {a};
\begin{scope}[general shadow/.style={}]
\node[right=of a] (b) {b};
\node[right=of b] (c) {c};
\end{scope}
\node[right=of c] (d) {d};
\end{tikzpicture}


-
Thanks; that works too, but I find Paul's approach easier to use. –  Jubobs Aug 28 '14 at 7:34
@Jubobs That is the difference between an expert (who knows internal code of tikz) and a beginner. –  skpblack Aug 28 '14 at 10:19