ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Henri Menke via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Henri Menke <henri@henrimenke.de>
Subject: [NTG-context] Re: Triaging tikz error: Cannot parse this coordinate
Date: Wed, 9 Aug 2023 10:02:29 +0200	[thread overview]
Message-ID: <8f3911dd-e7fc-b9fb-416b-9a7d5eeb6ef3@henrimenke.de> (raw)
In-Reply-To: <3ce15914-4ecc-a84a-04b0-4444f8381b1d@xs4all.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
> ___________________________________________________________________________________
___________________________________________________________________________________
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	other threads:[~2023-08-09  8:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-08 16:13 [NTG-context] " Xavier B.
2023-08-08 17:43 ` [NTG-context] " Hans Hagen
2023-08-08 18:57   ` Hans Hagen
2023-08-09  8:02     ` Henri Menke via ntg-context [this message]
2023-08-08 18:59   ` Xavier B.
2023-08-08 19:52     ` Hans Hagen via ntg-context
     [not found]       ` <20230809130016.a41b4dab1957f7ca865714f1@posteo.net>
2023-08-09 11:41         ` Hans Hagen via ntg-context
2023-08-08 19:13   ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8f3911dd-e7fc-b9fb-416b-9a7d5eeb6ef3@henrimenke.de \
    --to=ntg-context@ntg.nl \
    --cc=henri@henrimenke.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).