pgf
pgf copied to clipboard
Coordinate transformation options invalid outside of `tikzpicture`
Brief outline of the bug
When used outside of tikzpicture, coordinate transformation options, like rotate and xshift, will throw error ! Undefined control sequence. [...] \tikz@transform.
Minimal working example (MWE)
\documentclass{article}
\usepackage{tikz}
\tikzset{rotate=0} % errors
\begin{document}
\end{document}
Direct cause
Currently \tikz@transform is undefined until \tikz@picture sets it to \relax.
More general discussion
Current behavior:
| Type | Example | Internals | Use outside of tikzpicture? |
Init/Reset at |
|---|---|---|---|---|
| Coordinate transformation options | rotate, xshift |
\tikz@addtransform and \tikz@transform |
No, errors | \tikz@picture |
| Other graphic state options | line width, line cap |
\tikz@addoption and \tikz@options |
Yes | \tikz@scope@env (inner name of \scope) |
| Options change mode | draw, fill |
\tikz@addmode, \tikz@mode, and other code |
Yes | \tikz@scope@env |
Expected normalized behavior:
Allow use of these options outside of tikzpicture without errors, but throw warnings to alert users that their effects are discarded at the beginning of tikzpicture.
These should go inside every x/.style keys in this case every picture/.style={rotate=0}. Otherwise it will never reach to a stable API. you should not write random keys and hope for TikZ doing the right thing. There is not a question of consistency here because the others are working coincidentally.
These should go inside
every x/.stylekeys in this caseevery picture/.style={rotate=0}.
Could be added to
- #869
I've had a look at the internals of \tikz@transform and found that this is in general a highly inconsistent mess. Since the resolution of this bug would actually be merely replace one error with another error, I'm inclined to mark this as closed-wont-fix.
An "Undefined control sequence" error is just too close to be considered a code bug. Or, at least some words can be added to pgfmanual, maybe just to comfort maintainers, "oh it's (now) documented."