Triaging tikz error: Cannot parse this coordinate
After some time, I could write a minimal example with tikz with strange error: Cannot parse this coordinate. Can someone help me to find the bug? I attach the file and the log. Help very appreciate I run $ context --version mtx-context | ConTeXt Process Management 1.04 mtx-context | mtx-context | main context file: /usr/share/texmf-dist/tex/context/base/mkiv/context.mkiv mtx-context | current version: 2023.03.10 12:15 mtx-context | main context file: /usr/share/texmf-dist/tex/context/base/mkxl/context.mkxl mtx-context | current version: 2023.03.10 12:15 via texlive (arch) Thanks, Xavier
On 8/8/2023 6:13 PM, Xavier B. wrote:
After some time, I could write a minimal example with tikz with strange error: Cannot parse this coordinate.
Can someone help me to find the bug?
I attach the file and the log.
Help very appreciate I run \starttikzpicture \foreach \p in {(6,2)} { \tracingall \startscope[shift={\p}] \draw[color=green!60, thick] (0,0) -- (1,1); \stopscope } \stoptikzpicture
looks like some parsing issue, are you sure that you can assign \p to shift this way? ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 8/8/2023 7:43 PM, Hans Hagen wrote:
On 8/8/2023 6:13 PM, Xavier B. wrote:
After some time, I could write a minimal example with tikz with strange error: Cannot parse this coordinate.
Can someone help me to find the bug?
I attach the file and the log.
Help very appreciate I run \starttikzpicture \foreach \p in {(6,2)} { \tracingall \startscope[shift={\p}] \draw[color=green!60, thick] (0,0) -- (1,1); \stopscope } \stoptikzpicture
looks like some parsing issue, are you sure that you can assign \p to shift this way? ok, i found it but i'm not going to make it custom to fix tikz
you need to use this: \normalexpanded{\noexpand\startscope[shift={\p}]} instead of \startscope[shift={\p}] this can be automated with (maybe we need a m-fixz module for that) % fix \appendtoks \let\normaltikzstartscope\startscope \def\startscope[#1]% {\normalexpanded {\noexpand\normaltikzstartscope[#1]}}% \to \everyinsidetikzpicture % end of fix but for that you need to use the attached module so that we hook it in aftert tikz sets itself up the fix you can put in your style or in a cont-loc.mkxl in a local tree Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 8/8/23 20:57, Hans Hagen wrote:
On 8/8/2023 7:43 PM, Hans Hagen wrote:
On 8/8/2023 6:13 PM, Xavier B. wrote:
After some time, I could write a minimal example with tikz with strange error: Cannot parse this coordinate.
Can someone help me to find the bug?
I attach the file and the log.
Help very appreciate I run \starttikzpicture \foreach \p in {(6,2)} { \tracingall \startscope[shift={\p}] \draw[color=green!60, thick] (0,0) -- (1,1); \stopscope } \stoptikzpicture
looks like some parsing issue, are you sure that you can assign \p to shift this way? ok, i found it but i'm not going to make it custom to fix tikz
you need to use this:
\normalexpanded{\noexpand\startscope[shift={\p}]}
instead of
\startscope[shift={\p}]
this can be automated with (maybe we need a m-fixz module for that)
% fix
\appendtoks \let\normaltikzstartscope\startscope \def\startscope[#1]% {\normalexpanded {\noexpand\normaltikzstartscope[#1]}}% \to \everyinsidetikzpicture
% end of fix
but for that you need to use the attached module so that we hook it in aftert tikz sets itself up
the fix you can put in your style or in a cont-loc.mkxl in a local tree
This is likely going to break all kinds of stuff, because not everything in \startscope[...] can always be expanded. Also the brackets are optional in the original definition of \startscope, so a \dosingleempty would at least be in order: \appendtoks \let\normaltikzstartscope\startscope \def\dostartscope[#1]% {\normalexpanded {\noexpand\normaltikzstartscope[#1]}}% \def\startscope{\dosingleempty\dostartscope}% \to \everyinsidetikzpicture In fact, pgfkeys has a handler for expanding keys before doing assignment to work around exactly these situations: \startscope[shift/.expanded={\p}] No redefinition needed. We could also do \edef or \romannumeral expansion in the shift key in TikZ, but I'm not sure whether that would break someone's code. Cheers, Henri
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___________________________________________________________________________________
First of all, thanks, Hans for the answer.
I just do want others do [1] and it seems to work. What's my error here?
Xavier
[1] https://tex.stackexchange.com/a/7557
On Tue, 8 Aug 2023 19:43:01 +0200
Hans Hagen
On 8/8/2023 6:13 PM, Xavier B. wrote:
After some time, I could write a minimal example with tikz with strange error: Cannot parse this coordinate.
Can someone help me to find the bug?
I attach the file and the log.
Help very appreciate I run \starttikzpicture \foreach \p in {(6,2)} { \tracingall \startscope[shift={\p}] \draw[color=green!60, thick] (0,0) -- (1,1); \stopscope } \stoptikzpicture
looks like some parsing issue, are you sure that you can assign \p to shift this way?
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 8/8/2023 8:59 PM, Xavier B. wrote:
First of all, thanks, Hans for the answer. I just do want others do [1] and it seems to work. What's my error here? it looks like tikz expects shift={(a,b)} so with a brace but not a macro inside as it does not expand the value; it sees \p and not the meaning of \p which means that you cannot simply use the loop
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 8/8/2023 6:13 PM, Xavier B. wrote:
After some time, I could write a minimal example with tikz with strange error: Cannot parse this coordinate.
Can someone help me to find the bug?
I attach the file and the log.
Help very appreciate I run \starttikzpicture \foreach \p in {(6,2)} { \tracingall \startscope[shift={\p}] \draw[color=green!60, thick] (0,0) -- (1,1); \stopscope } \stoptikzpicture
looks like some parsing issue, are you sure that you can assign \p to shift this way?
On 8/8/2023 7:43 PM, Hans Hagen wrote: puzzle: \startMPcode draw textext ("\externalfigure[mill.png][height=1cm]") ; draw image ( draw for p = (6,0), (7,0), (5,1), (6,1), (7,1), (1,2), (2,2), (3,2), (4,2), (5,2), (7,2), (0,3), (1,3), (3,3), (4,3), (8,3), (0,4), (7,4), (8,4), (0,5), (1,5), (2,5), (6,5), (7,5), (2,6), (3,6), (4,6), (5,6), (6,6), (3,7), (4,7), (5,7), (6,7) : ( (0,0) -- (1,0) -- (1,1) -- (0,1) -- cycle &&& (0,0) -- (1,1) && (0,1) -- (1,0) ) shifted p && endfor nocycle withcolor red ; draw for p = (6,2), (2,3), (5,3), (6,3), (7,3), (1,4), (2,4), (3,4), (4,4), (5,4), (6,4), (3,5), (4,5), (5,5) : ( (0,0) -- (1,0) -- (1,1) -- (0,1) -- cycle &&& (0,0) -- (1,1) ) shifted p && endfor nocycle withcolor green ; ) ysized 4cm withpen pencircle scaled .5pt ; \stopMPcode ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
participants (4)
-
Hans Hagen
-
Hans Hagen
-
Henri Menke
-
Xavier B.