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
> ___________________________________________________________________________________
___________________________________________________________________________________
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
___________________________________________________________________________________

Reply via email to