I try in this in this question to use some shorthands with the library scopes.
I discover some difficulties and I can't explain why I get problems. (I use pgf 2.1 cvs)
The main code comes from the pgfmanual
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{scopes}
\begin{tikzpicture}
{ [ultra thick]
{ [red]
\draw (0mm,10mm) -- (10mm,10mm);
\draw (0mm,8mm) -- (10mm,8mm);
}
\draw (0mm,6mm) -- (10mm,6mm);
}
{ [green]
\draw (0mm,4mm) -- (10mm,4mm);
\draw (0mm,2mm) -- (10mm,2mm);
\draw[blue] (0mm,0mm) -- (10mm,0mm);
}
\end{tikzpicture}
\end{document}
This is perfect. Now I want to draw three times these lines
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{scopes}
\begin{document}
\begin{tikzpicture}
\foreach \i in {0,5,10}{%
\begin{scope}[xshift=\i cm]
{ [ultra thick]
{ [red]
\draw (0mm,10mm) -- (10mm,10mm);
\draw (0mm,8mm) -- (10mm,8mm);
}
\draw (0mm,6mm) -- (10mm,6mm);
}
{ [green]
\draw (0mm,4mm) -- (10mm,4mm);
\draw (0mm,2mm) -- (10mm,2mm);
\draw[blue] (0mm,0mm) -- (10mm,0mm);
}
\end{scope}}
\end{tikzpicture}
\end{document}
This is always perfect but now if I replace \begin{scope} ...\end{scope} by {..}, the code compiles but the scopes disappear.
\begin{tikzpicture}
\foreach \i in {0,5,10}{%
{[xshift=\i cm]
{ [ultra thick]
{ [red]
\draw (0mm,10mm) -- (10mm,10mm);
\draw (0mm,8mm) -- (10mm,8mm);
}
\draw (0mm,6mm) -- (10mm,6mm);
}
{ [green]
\draw (0mm,4mm) -- (10mm,4mm);
\draw (0mm,2mm) -- (10mm,2mm);
\draw[blue] (0mm,0mm) -- (10mm,0mm);
}
}}
\end{tikzpicture}
I know that { is the beginning of a TikZ's scope only if [ comes after { otherwise{..}` is a simple TeX's group.
Is-it possible to explain this problem?

trace-pgfkeysif If I want to progress. Thanks Sherlock ! – Alain Matthes May 25 '12 at 11:28