In reply to @cfr's comment, I think this is a serious problem because people (at least me) love fancy indentation:
\tikzset{
test1/.style={
drop shadow={
shadow xshift=1ex
}
}
}
In such case, TikZ got redundant spaces inevitably because of new lines.
Unfortunately, this seems to be a deep bug of pgfkeys. Consider the following example
\documentclass[tikz]{standalone}
\tikzset{
option a/.style={
#1
}
}
\tikzset{
option b/.style={
option a={
#1
}
}
}
\tikzset{
option c/.style={
option b={
red
}
}
}
\begin{document}
\tikz\fill[ red ]circle(1);
\tikz\fill[option a={red}]circle(1);
\tikz\fill[option b={red}]circle(1);
\tikz\fill[option c ]circle(1);
\end{document}
It produces two errors: One at option b={red}
I do not know the key '/tikz/ red '
And the other at option c
:
I do not know the key '/tikz/ red '
One can accumulate spaces as follows
\documentclass[tikz]{standalone}
\tikzset{option a/.style={ #1 } }
\tikzset{option b/.style={option a={ #1 } } }
\tikzset{option c/.style={option b={ #1 } } }
\tikzset{option d/.style={option c={ #1 } } }
\tikzset{option e/.style={option d={ #1 } } }
\tikzset{option f/.style={option e={ #1 } } }
\tikzset{option g/.style={option f={ #1 } } }
\tikzset{option h/.style={option g={ #1 } } }
\tikzset{option i/.style={option h={ #1 } } }
\tikzset{option j/.style={option i={ #1 } } }
\tikzset{option k/.style={option j={ #1 } } }
\begin{document}
\tikz\fill[option k=red]circle(1);
\end{document}
I do not know the key '/tikz/ red '
A partial solution
This trick is so fragile that if one replace } } }
by }} }
or } }}
, the corresponding spaces disappear.
Probably this is the why the source code of TikZ contains so many lonely %
. For instance tikz.code.tex
line 1209-1215
\tikzset{
no marks/.style={mark=none},%
no markers/.style={mark=none},%
every mark/.style={},
mark options/.style={%
every mark/.style={#1}%
}}
Appendix
drop shadow
is defined in tikzlibraryshadows.code.tex
\tikzset{
/tikz/drop shadow/.style={
general shadow={%
shadow scale=1,
shadow xshift=.5ex,
shadow yshift=-.5ex,
opacity=.5,
fill=black!50,
every shadow,
#1
}
}
}
Here, general shadow
is option a
, drop shadow
is option b
, and test1
is option c
.