# tikz circle operation and fill

I would like to add circles on paths. for all circles except one I want them to be filled, therefore I set every circle node/.style={fill}. However there is one circle I do not want to be filled, however fill=none does not give the desired result.

MWE:

\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{tikz}
\usepackage{bm}
\usepackage[T1]{fontenc}

\usetikzlibrary{scopes}

\begin{document}
\begin{tikzpicture}
{ [every circle node/.style={minimum width=.5ex, fill=black}]
\draw (0,0) node[fill=none, circle]{a}; %this should not be filled, but all other circles in the scope should.
}
\draw (0,1) node[circle, draw]{a};
\end{tikzpicture}
\end{document}

-

The problem here is that TikZ applies the every <shape> node style after it has processed the options given explicitly to the node. A moment's thought reveals that that pretty much has to be the way it's done: TikZ doesn't know what shape the node is until it has processed the options given to the node, and since the shape could be buried deep in other styles, it basically has to process everything fully. So the fill=none is getting applied before the every circle style and thus is getting overridden by the fill=black therein.

To fix this, you need to find a hook further on than every circle style. One way is simply to add to the every circle style itself from within the node options. Since these are processed first, they can have an effect on the every circle style key. In full then it's a bit long-winded, but you can always define shortcuts.

\documentclass{article}
%\url{http://tex.stackexchange.com/q/119942/86}
\usepackage{tikz}

\usetikzlibrary{scopes}

\begin{document}
\begin{tikzpicture}
{ [every circle node/.style={minimum width=.5ex, fill=black}]
\draw (0,0) node[circle,every circle node/.append
style={fill=none}]{a}; %this should not be filled, but all other
circles in the scope should.
\draw (1,0) node[circle]{a};
}
\draw (0,1) node[circle, draw]{a};
\end{tikzpicture}
\end{document}


-
thank you, this was what I was looking for. Very nice reasoning why tikz behaves as it does. – ted Jun 19 '13 at 9:19

You can define two separate styles:

\documentclass{article}
\usepackage{tikz}

\tikzset{%
mynode/.style={circle,minimum width=.5ex, fill=none,draw}, % no filling
myfillnode/.style={circle,minimum width=.5ex, fill=black,draw}, % fill with black
}

\begin{document}
\begin{tikzpicture}[every node/.style ={myfillnode}]
\draw (0,0) node[mynode]{a}; %this should not be filled, but all other circles in the scope should.
\draw (0,1) node{a};
\end{tikzpicture}
\end{document}


Here mynode is not filled.

-