我有一个带有许多复杂树的 beamer 文档,因此我设置了颜色、阴影等的默认值。有没有办法从单个节点移除阴影?例如,在下面的树中,假设 Winesap 苹果应该没有阴影。我最接近的结果是[drop shadow={fill=white,opacity=1}]
,但阴影仍然有一条微弱的灰色轮廓。并且该轮廓在 xpdf、evince、mupdf、zathura、acroread 甚至 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}
答案1
您可以general shadow
用杀死钥匙general shadows/.style=
并将其用在孩子身上,即:
% Preamble:
\tikzset{no shadows/.style={general shadow/.style=}}
% In the tree:
child[no shadows] {node {Winesap}}
这将禁用该孩子身上的所有阴影。
另一个选择是清空存储预操作的宏,例如
% Preamble:
\makeatletter
\tikzset{no shadows/.code=\let\tikz@preactions\pgfutil@empty}
\makeatother
% In the tree:
child {node[no shadows] {Winesap}}
这将终止所有可能的预行动但只会影响这个节点。
代码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}
代码 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}
答案2
这可能会变得很丑陋,但这里是藏身之处。如果你无法将其取下,请尝试将其遮盖起来。
\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}]
不会消除阴影,但会覆盖它。