ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: ntg-context@ntg.nl
Subject: [NTG-context] Re: Triaging tikz error: Cannot parse this coordinate
Date: Tue, 8 Aug 2023 20:57:21 +0200	[thread overview]
Message-ID: <3ce15914-4ecc-a84a-04b0-4444f8381b1d@xs4all.nl> (raw)
In-Reply-To: <bb37e773-8053-dcfc-b789-1e0abbd3675f@xs4all.nl>

[-- Attachment #1: Type: text/plain, Size: 1616 bytes --]

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

[-- Attachment #2: m-tikz.mkxl --]
[-- Type: text/plain, Size: 5882 bytes --]

%D \module
%D   [       file=m-tikz,
%D        version=2021.07.12,
%D          title=\CONTEXT\ Extra Modules,
%D       subtitle=TIKZ support,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D A fixed variant of the t-tikz module distributed with tikz. For practical reasons
%D per 2021 we split the module for \MKIV\ and \LMTX. (Maybe some day I'll optimize
%D TIKZ a bit.)
%D
%D All these t-* modules in the tikz distribution make no sense as we can just load
%D them here which is way cleaner. There is also some mkii filename mapping going on
%D that is not needed on todays systems (windows has no 8.3 limitation and on unix
%D tds finally adopted a case insensitive approach.)

%D Just in case someone does a hard input ...

\ifdefined\pgfdefined    \endinput \fi
\ifdefined\pgfcoredefined\endinput \fi

%D ... but normally we end up here:

\startmodule[tikz]

\ifdefined\pdflastxpos \else
    \unprotect
        \frozen\overloaded\protected\def\pdflastxpos{\numexpr\clf_lastxpos\relax}
        \frozen\overloaded\protected\def\pdflastypos{\numexpr\clf_lastypos\relax}
    \protect
\fi

\newcatcodetable \tikzcatcodes

\startcatcodetable \tikzcatcodes
    \catcode\tabasciicode             \spacecatcode
    \catcode\endoflineasciicode       \endoflinecatcode
    \catcode\formfeedasciicode        \endoflinecatcode
    \catcode\spaceasciicode           \spacecatcode
    \catcode\endoffileasciicode       \ignorecatcode
    \catcode\circumflexasciicode      \superscriptcatcode
    \catcode\underscoreasciicode      \subscriptcatcode
    \catcode\ampersandasciicode       \alignmentcatcode
    \catcode\backslashasciicode       \escapecatcode
    \catcode\leftbraceasciicode       \begingroupcatcode
    \catcode\rightbraceasciicode      \endgroupcatcode
    \catcode\dollarasciicode          \mathshiftcatcode
    \catcode\hashasciicode            \parametercatcode
    \catcode\commentasciicode         \commentcatcode
    \catcode\atsignasciicode          \lettercatcode
    \catcode\exclamationmarkasciicode \othercatcode
    \catcode\questionmarkasciicode    \lettercatcode
    \catcode\tildeasciicode           \activecatcode
    \catcode\barasciicode             \othercatcode
\stopcatcodetable

\permanent\protected\def\starttikzinput
  {\pushoverloadmode
   \pushcatcodetable
   \setcatcodetable\tikzcatcodes
   \pushmacro\meaning
   \let\meaning\meaningless
   \autoparagraphmode\zerocount}

\permanent\protected\def\stoptikzinput
  {\autoparagraphmode\plusone
   \popcatcodetable
   \popmacro\meaning
   \popoverloadmode}

\permanent\protected\def\tikzinputfile#1%
  {\starttikzinput
   \input{#1}\relax
   \stoptikzinput}

\permanent\protected\def\tikzerrormessage#1#2#3%
  {\writestatus{#1}{#2}}

% For now we need this but we need to educate the user to wrap settings in the
% wrappers. So some day the next line will go. I need to check what commands are
% possible outside a picture.

\overloadmode\zerocount

\newtoks\everytikzpicture
\newtoks\everyinsidetikzpicture

% \appendtoks
%     \resetcharacterspacing
% \to \everytikzpicture

\permanent\protected\def\starttikzsettings
  {\pushoverloadmode
   \pushmacro\meaning
   \let\meaning\meaningless
   \autoparagraphmode\zerocount}

\permanent\protected\def\stoptikzsettings
  {\autoparagraphmode\plusone
   \popmacro\meaning
   \popoverloadmode}

\permanent\protected\def\starttikzpicture
  {\dontleavehmode
   \hcontainer\bgroup
   \setcatcodetable\tikzcatcodes
   \the\everytikzpicture
   \autoparagraphmode\zerocount
   \pushmacro\meaning
   \let\meaning\meaningless
 % \pushoverloadmode
   \ifdefined\PackageError\else \let\PackageError\tikzerrormessage \fi
   \tikzpicture
   \the\everyinsidetikzpicture}

\permanent\protected\def\stoptikzpicture
  {\endtikzpicture
 % \popoverloadmode
   \popmacro\meaning
   \egroup}

\let\pgfdefined    \relax
\let\pgfcoredefined\relax

\tikzinputfile{pgfutil-common.tex}
\tikzinputfile{pgfutil-context.def}
\tikzinputfile{pgfrcs.code.tex}
\tikzinputfile{pgfsys.code.tex}
\tikzinputfile{pgfkeys.code.tex}
\tikzinputfile{pgfsyssoftpath.code.tex}
\tikzinputfile{pgfsysprotocol.code.tex}
\tikzinputfile{pgfcore.code.tex}
\tikzinputfile{pgffor.code.tex}
\tikzinputfile{pgfmoduleplot.code.tex}
\tikzinputfile{tikz.code.tex}

\let\startpgfpicture             \pgfpicture              \let\stoppgfpicture            \endpgfpicture
\let\startpgfscope               \pgfscope                \let\stoppgfscope              \endpgfscope
\let\startpgflowlevelscope       \pgflowlevelscope        \let\stoppgflowlevelscope      \endpgflowlevelscope
\let\startpgfinterruptpath       \pgfinterruptpath        \let\stoppgfinterruptpath      \endpgfinterruptpath
\let\startpgfinterruptpicture    \pgfinterruptpicture     \let\stoppgfinterruptpicture   \endpgfinterruptpicture
\let\startpgfinterruptboundingbox\pgfinterruptboundinbox  \let\stoppgfinterruptboudingbox\endpgfinterruptboundingbox

\let\normalusepgfmodule  \usepgfmodule
\let\normalusepgflibrary \usepgflibrary
\let\normalusetikzlibrary\usetikzlibrary

\tolerant\protected\def\usepgfmodule[#1]#;#2% somehow both variants are used
  {\starttikzinput
   \normalusepgfmodule[#1#2]%
   \stoptikzinput}

\tolerant\protected\def\usepgflibrary[#1]#;#2% somehow both variants are used
  {\starttikzinput
   \normalusepgflibrary[#1#2]%
   \stoptikzinput}

\tolerant\protected\def\usetikzlibrary[#1]#;#2% somehow both variants are used
  {\starttikzinput
   \normalusetikzlibrary[#1#2]%
   \stoptikzinput}

\usepgfmodule[shapes]
\usepgfmodule[plot]
\usepgfmodule[matrix]
\usepgfmodule[decorations]

\definefilesynonym [pgfplots]      [tikz-pgfplots]
\definefilesynonym [pgfplotstable] [tikz-pgfplotstable]

\stopmodule

[-- Attachment #3: Type: text/plain, Size: 495 bytes --]

___________________________________________________________________________________
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-08 18:59 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 [this message]
2023-08-09  8:02     ` Henri Menke via ntg-context
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=3ce15914-4ecc-a84a-04b0-4444f8381b1d@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=ntg-context@ntg.nl \
    /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).