[tl2021] TikZ coordinates like `([] {X}, {Y})` require excessive braces
The syntax in the subject requires extra braces: ([] {{X}}, {{Y}}) works, but ([] {X}, {Y}) does not.
Minimal working example (MWE)
\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikz \path ([] {45+(45)}, 1);
\end{document}
gives ! Package pgf Error: No shape named 45+(45' is known.`
Why do you need braces to start with?
I'd argue that your placement of braces is wrong, i.e. I'd expect ([] {45+(45), 1}) but unfortunately that doesn't work either.
@muzimuzhi We have another brace-stripping problem.
@ilayn Nested parentheses. (For 45 + 45 you of course don't need extract parentheses)
Nested parentheses need two braces since a decade but there is a strict usage for this. If you need coordinate manipulations you need calc. This has been also the case with https://tex.stackexchange.com/questions/29734/combining-and-5-in-tikz
I use nested parentheses extensively for MANY years, and this is the first time I see a need for double braces. (But before I did not need ([] STUFF) syntax — this is only to work-around a bug in the plot subcommand.)
Tests on overleaf's various texlive versions show this is a long-existing issue.
--- a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
+++ b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
@@ -5202,7 +5202,7 @@
\def\tikz@scan@options[#1]#2{%
\def\tikz@scan@point@options{#1}%
- \tikz@@@scan@@absolute\tikz@scan@handle@options(#2%
+ \tikz@@@scan@@absolute\tikz@scan@handle@options({#2}%
}%
\def\tikz@scan@handle@options#1{%
The above proposal will make \tikz@scan@one@point accept ([] {45+(45)}, 1), but not ([] {45+(45), 1}). The pgfmanual reads (sec. 2.16 "Intersecting Paths"),
in general, you need to add braces around components of coordinates when these components contain parentheses
So it seems that fix is enough.
After a second look, I question why \tikz@scan@options need its second parameter.
--- a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
+++ b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
@@ -5199,9 +5199,9 @@
{\tikz@@@scan@@absolute#1(}%
}%
-\def\tikz@scan@options[#1]#2{%
+\def\tikz@scan@options[#1]{%
\def\tikz@scan@point@options{#1}%
- \tikz@@@scan@@absolute\tikz@scan@handle@options(#2%
+ \tikz@@@scan@@absolute\tikz@scan@handle@options(%
}%
\def\tikz@scan@handle@options#1{%
I use nested parentheses extensively for MANY years, and this is the first time I see a need for double braces.
Yes that's what I meant with strict usage that is coordinate syntax with options [] which @muzimuzhi is currently dissecting. Otherwise you can get away with it for some basic math. The issue I'm afraid is an XY problem that you are forcing one syntax too far to fix another. But I don't want to overreach
Is this issue not fixed? I see @muzimuzhi already got a patch above.
That said, the patch would make
\path ([] {45+(45), 1});
no longer work.
No, this issue is not fixed, as it still has an open state.