# TikZ scope options not working

Consider the following code:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\begin{scope}[fill=red, draw=green,text=blue]
\node[fill=red, draw=green] at (0,0) {A};
\node[text=black] at (2,0) {B};
\end{scope}
\end{tikzpicture}
\end{document}


My question is: Why do only the text option to the \scope environment work? (That is: I would like the B-node to have a red background and a green border, but as seen from the included image, nothing happens)

-

This is a common misunderstanding of how a node actually behaves. A node is not a \path in itself, per definition.

A node has its own name-space in terms of special keys which apply to it.

The reason is \node gets expanded to \path node and whatever is in the scope environment is only appended to paths. This means your code is equivalent to:

\begin{tikzpicture}
\begin{scope}[fill=red, draw=green,text=blue]
\node[fill=red, draw=green] at (0,0) {A};
\path (2,0) node[text=black] {B};
\end{scope}
\end{tikzpicture}


which much clearer what is happening. Hence, you could do this:

  \begin{scope}[all/.style={fill=red, draw=green,text=blue},all,
every node/.append style={all}]


to achieve what you want, all is then used every where, even on nodes.

-
Thank you for the nice explanation.. I think this point is not made very clear in the TikZ-documentation. As far as I can see, it is not mentioned in chapter 12.3, "Using scopes to structure a picture" –  Håkon Hægland Mar 10 '13 at 16:02

The nodes do not inherit the path options. To make it work you can use

  \begin{tikzpicture}
\begin{scope}[every node/.style={fill=red, draw=green,text=blue}]
\node at (0,0) {A};
\node[text=black] at (2,0) {B};
\end{scope}
\end{tikzpicture}


then the resulting picture is

-
Thank you.. I was not aware of the difference between nodes and paths regarding scope options.. –  Håkon Hægland Mar 10 '13 at 16:05