10

I have a beamer document with many complex trees, so I set defaults for colors, shadows, and so on. Is there a way to remove the drop shadow from a single node? E.g., in the following tree, suppose that Winesap apples should have no shadow. The closest I’ve come is with [drop shadow={fill=white,opacity=1}], but there’s still a faint gray outline of the shadow. And that outline is visible in xpdf, evince, mupdf, zathura, acroread, and even ImageMagick.

\documentclass{beamer}
\usecolortheme[named=teal]{structure}
\usepackage{tikz}
\usetikzlibrary{shadows,trees}
\begin{document}

\tikzset{edge from parent fork right,grow'=right,
every node/.style={rectangle,rounded corners,thick,draw=structure,fill=white,drop shadow},
edge from parent/.style={thick,draw=structure}}

\begin{frame}
\begin{tikzpicture}[level 1/.style={level distance=7em,sibling distance=9em},
        level 2/.style={level distance=7em,sibling distance=6em},
        level 3/.style={level distance=7em,sibling distance=3em}]
\node {food}
child {node {fruit}
child {node {apples}
child {node {Granny Smith}}
child {node[drop shadow={fill=white,opacity=1}] {Winesap}}}
child {node {pears}}}
child {node {veggies}
child {node {beets}}
child {node {Swiss chard}}};
\end{tikzpicture}
\end{frame}
\end{document}

enter image description here

2 Answers 2

7

You can kill the general shadow key with general shadows/.style= and use this on the child, i.e.:

% Preamble:
\tikzset{no shadows/.style={general shadow/.style=}}

% In the tree:
  child[no shadows] {node {Winesap}}

which would disable all shadows on that child.

Another option is to empty the macro that stores the preactions, something like

% Preamble:
\makeatletter
\tikzset{no shadows/.code=\let\tikz@preactions\pgfutil@empty}
\makeatother

% In the tree:
  child {node[no shadows] {Winesap}}

which would kill all possible preactions but would only affect this node.

Code A

\documentclass{beamer}
\usecolortheme[named=teal]{structure}
\usepackage{tikz}
\usetikzlibrary{shadows,trees}
\tikzset{
  edge from parent fork right,
  grow'=right,
  every node/.style={rectangle,rounded corners,thick,draw=structure,fill=white,drop shadow},
  edge from parent/.style={thick,draw=structure},
  no shadows/.style={general shadow/.style=},
}
\begin{document}
\begin{frame}
\begin{tikzpicture}[
  level 1/.style={level distance=7em,sibling distance=9em},
  level 2/.style={level distance=7em,sibling distance=6em},
  level 3/.style={level distance=7em,sibling distance=3em}]
\node {food}
  child {node {fruit}
    child {node {apples}
      child {node {Granny Smith}}
      child[no shadows] {node {Winesap}}
    }
    child {node {pears}}
  }
  child {node {veggies}
    child {node {beets}}
    child {node {Swiss chard}}
  };
\end{tikzpicture}
\end{frame}
\end{document}

Code B

\documentclass{beamer}
\usecolortheme[named=teal]{structure}
\usepackage{tikz}
\usetikzlibrary{shadows,trees}
\makeatletter
\tikzset{no shadows/.code=\let\tikz@preactions\pgfutil@empty}
\makeatother
\tikzset{
  edge from parent fork right,
  grow'=right,
  every node/.style={rectangle,rounded corners,thick,draw=structure,fill=white,drop shadow},
  edge from parent/.style={thick,draw=structure},
}
\begin{document}
\begin{frame}
\begin{tikzpicture}[
  level 1/.style={level distance=7em,sibling distance=9em},
  level 2/.style={level distance=7em,sibling distance=6em},
  level 3/.style={level distance=7em,sibling distance=3em}]
\node {food}
  child {node {fruit}
    child {node {apples}
      child {node {Granny Smith}}
      child {node[no shadows] {Winesap}}
    }
    child {node {pears}}
  }
  child {node {veggies}
    child {node {beets}}
    child {node {Swiss chard}}
  };
\end{tikzpicture}
\end{frame}
\end{document}
1
  • Code A worked in my mouth-watering example, but something interfered with it in my real, complex trees. However, Code B worked perfectly with the complex trees. Thanks!
    – Thérèse
    Commented Aug 21, 2013 at 3:17
5

This can get ugly, but here is a hideout. If you can't get it off then try to cover it.

\documentclass{beamer}
\usecolortheme[named=teal]{structure}
\usepackage{tikz}
\usetikzlibrary{shadows,trees}
\begin{document}

\tikzset{edge from parent fork right,grow'=right,
every node/.style={rectangle,rounded corners,thick,draw=structure,fill=white,drop shadow},
edge from parent/.style={thick,draw=structure}}


\begin{frame}
\begin{tikzpicture}[level 1/.style={level distance=7em,sibling distance=9em},
        level 2/.style={level distance=7em,sibling distance=6em},
        level 3/.style={level distance=7em,sibling distance=3em}]
\node {food}
child {node {fruit}
child {node {apples}
child {node {Granny Smith}}
child {node[general shadow={fill=white,shadow scale=2}] {Winesap}}}
child {node {pears}}}
child {node {veggies}
child {node {beets}}
child {node {Swiss chard}}};
\end{tikzpicture}
\end{frame}
\end{document}

node[general shadow={fill=white,shadow scale=2}] doesn't eliminate the shadow but covers it.

enter image description here

1
  • Thanks, Harish. I’ve used Qrrbrbirlbel’s Code B, but clearly this is tricky business, and I may yet need your hideout. And now I understand why my initial attempts to shrink the shadow to nothing by saying shadow scale=0 made matters worse!
    – Thérèse
    Commented Aug 21, 2013 at 3:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .