# 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}

\tikzset{
every node/.style={
draw,
fill        = white,
},
}

\begin{document}
\begin{tikzpicture}
\node (a) {a};
\node[
right=of a,
% 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. – jub0bs Aug 28 '14 at 7:38

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}

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

\tikzset{
every node/.style={
draw,
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}

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

\tikzset{
every node/.style={
draw,
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}

• 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}

\tikzset{
every node/.style={
draw,
fill        = white,
},
}

\begin{document}
\begin{tikzpicture}
\node (a) {a};
\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};

• @Jubobs That is the difference between an expert (who knows internal code of tikz) and a beginner. – skpblack Aug 28 '14 at 10:19