Is there a way to switch off shading for one node, in a scope where the nodes are shaded?
In other words, I want something like shading=none
, but did not find it. Motivation:
\documentclass{article}
\usepackage{tikz}
\tikzset{default/.style={}}
\tikzstyle{st1}=[circle, shading=ball, ball color=red, inner sep=1.5pt]
\tikzstyle{st2}=[default, rectangle, inner xsep=0pt, inner ysep=2pt, draw]
\begin{document}
\begin{tikzpicture}[grow=right, level distance=10pt, every node/.style={st1}]
\path node{} child {node{} child {node{} child {node[st2]{}}}};
\end{tikzpicture}
\end{document}
This gives the following result:
.
The problem is that the shading is inherited in the last node, which I want without shading. I thought the
default
option in definition of st2
might help, but it does not have any effect.
The only way to achieve what I want is to add [every node/.style={default}]
to the last child
in the command; this resets/clears the style for all children. While writing this question, I realized that I can define \tikzstyle{st3}=[every node/.style={default, st2}]
and use it on the last child
. This makes it easy to use - but I would still like to know why I have to put the 'style reset' on the child
, instead of on the node
?
And one more thing: the reason I have inner ysep=0.0pt
on the last node is that I actually want a single line, i.e. a box with zero width. Is there a way to achieve this in my setup, i.e. in a sequence of nodes?
Thanks.
default
option? I looked for it in the manual without success.=default
. Somehow, I noticed it and I tried it for styles .. and it works, in a way :-)default
style is not defined on my system (TiKZ/PGF v2.1) and throws an error. I also can't find it in the manual (only as a value that's passed to other keys, but not as an independent style). Are you using a different version of TikZ/PGF?! Package pgfkeys Error: I do not know the key '/tikz/default' and I am going to ignore it
. Indeed, for what I understood,default
is used to reset values to the original configuration inbaseline
,trim left
,trim right
\documentclass
and containing only those things necessary to demonstrate the problem). That avoids ambiguity and makes it easier for others to come up with a solution. By the way, your definition ofdefault
does not have any effect on anything.\node [default] {...}
is equivalent to\node [] {...}
.