# Why doesn't “double” work in the options list of a scope?

An example document:

\documentclass[convert={size=320}]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\begin{scope}[line width = 2pt, red]
\foreach \x in {1, 2, 3, 4} {
\draw (\x, 0) -- (\x, 5);
}
\end{scope}
\begin{scope} [ line width = 2pt,
color = green!80,
double distance = 2pt,
double = blue          % <--- This doesn't have any effect
]
\draw (0, 4) -- (5, 4);
\end{scope}
\begin{scope} [ line width = 2pt,
color = green!80,
double distance = 2pt,
every path/.style = {double = blue}
]
\draw (0, 3) -- (5, 3);
\end{scope}
\begin{scope} [ line width = 2pt,
color = green!80,
every path/.style = { double distance = 2pt,
double = blue
}]
\draw (0, 2) -- (5, 2);
\end{scope}
\begin{scope} [every path/.style = { line width = 2pt,
color = green!80,
double distance = 2pt,
double = blue
}]
\draw (0, 1) -- (5, 1);
\end{scope}
\end{tikzpicture}

\end{document}


The result:

I don't understand this behaviour. Why do all the other options in the scope options list apply to the drawn paths, but not "double"? The other options can be put in the scope options list or in the every path/.style options list within the scope options list, and they'll work either way. But not "double". The PGF/TikZ manual, extensive though it is, did not illuminate things for me.

-
It doesn’t work in the same way like draw (or fill) wouldn’t work there. Both add an mode to the current path (all modes are reset at the start of the path after which the every path style is executed). All other options just set a specific setting. – Qrrbrbirlbel Dec 19 '13 at 22:39
I would be interested to know the part of the PGF/TikZ manual, or other resources, that I should read to understand better what you mean by the word "mode" in your comment. – Hammerite Dec 19 '13 at 22:53

This doesn’t work in the same way as giving the option draw or fill as an option to a scope will not stroke or fill all paths in tho scope. Given as an option to a scope, they just set the color in the event a path uses those options without a value.

\draw[double] (0, 4) -- (5, 4);


would use the blue from the scope’s setting.

The manual says to the option draw=<color>:

Although this option is normally used on paths to indicate that the path should be drawn, it also makes sense to use the option with a {scope} or {tikzpicture} environment. However, this will not cause all paths to be drawn. Instead, this just sets the <color> to be used for drawing paths inside the environment.

While the manual doesn’t say much regarding this topic about any other “actions” on a path, this also applies—besides draw and double—to

• fills,
• clips,
• use as a bounding box (which is very similar to a clip, just without the clipping),
• tips3.0.0 and
• shades.

The manual does again explain this behavior for both fadings, the

• path fading=<name>:

This option tells TikZ that the current path should be faded with the fading <name>. If no <name> is given, the <name> set for the whole scope is used. Similarly to options like draw or fill, this option is reset for each path, so you have to add it to each path that should be faded.

and

• the scope fading=<fading> (paradoxical as it seems):

[…] [J]ust as for path fading, providing the scope fading option with a {scope} only sets the name of the fading to be used. You have to explicitly provide the scope fading with a path to actually install a fading.

Also path picture (a very special and custom filling of a path) is an “action on a path” and abides these rules:

As with other keys like fill or draw this option needs to be given on a path, setting the path picture outside a path has no effect (the path picture is cleared at the beginning of each path).

With these words (“cleared at the beginning of each path”) we turn to the source of TikZ, the file tikz.code.tex. Each of these mentioned options include a call to \tikz@addmode which appends its argument to \tikz@mode. In the (internal) definition of \path, this macro is emptied:

\let\tikz@mode=\pgfutil@empty%


(The every path style is executed afterwards.) When ; is encountered (and the path has been constructed) all these modes are falsed:

\let\tikz@path@picture=\pgfutil@empty%
\tikz@mode@fillfalse%
\tikz@mode@drawfalse%
\tikz@mode@tipsfalse% (3.0.0)
\tikz@mode@doublefalse%
\tikz@mode@clipfalse%
\tikz@mode@boundaryfalse% (“use as bounding box”)

\tikz@mode% installs the mode settings