7

In an attempt to connect two inline nodes as I used to in LaTeX, I wrote the following code:

\usemodule[tikz]
\starttext
\starttikzpicture[remember picture]
     \node (A) {Node 1};
\stoptikzpicture
Hi world
\starttikzpicture[remember picture]
\node (B) {Node 2};
\stoptikzpicture
\starttikzpicture[overlay,remember picture]
\draw (B) --++(0,0.5) -| (A);
\stoptikzpicture
\stoptext

But nothing appears and is considered a fatal error when running. I wonder if there are some libraries or options in TikZ that are exclusive to LaTeX. If options such as remember picture cannot be used in Context, is there an alternative?

  • that's not a MWE, just a snippet of your code. a MWE is fully compilable. – naphaneal May 22 at 12:45
  • 2
    @Muhammed Hashim: No problem on my PC with your code. The code is compilable when running context, no errors occur. A small improvement could be to write \starttikzpicture[remember picture,baseline=(A.base)] \node (A) {Node 1}; for correct baseline of the node with the surrounding text. – Marian G. May 22 at 12:45
  • 2
    @napahnael It is compilable. Simply run context on it. – TeXnician May 22 at 12:54
  • 1
    If you are running lmtx, it could be that you have not copied the folder with modules. What I'm trying to say is that it could be good to know what version you run. It could also be useful to see what error you get. – mickep May 22 at 15:19
  • 1
    Who downvoted this? The question is legitimate, well researched, and very good. – Henri Menke May 22 at 23:22
5

This is a problem in ConTeXt, which defines

\def\lastxpos{\clf_lastxpos}
\def\lastypos{\clf_lastypos}

and further down

\let\pdflastxpos\lastxpos
\let\pdflastypos\lastypos

where \clf_lastxpos and \clf_lastypos simply expand to numbers. This means that \pdflastxpos and \pdflastypos can no longer be used as registers. A simply workaround would be to wrap them in \numexpr. I have reported this on the mailing list: https://mailman.ntg.nl/pipermail/dev-context/2019/003602.html

\unprotect
% This fixes the present bug
\unexpanded\def\pdflastxpos{\numexpr\clf_lastxpos\relax}
\unexpanded\def\pdflastypos{\numexpr\clf_lastypos\relax}
% This might be needed if you run PGF 3.1.3
% see https://github.com/pgf-tikz/pgf/issues/675
\def\XC@tgt@mod#1{#1}
\def\XC@sdef#1#2{\edef#1{#2}}
\protect
\usemodule[tikz]
\starttext
\starttikzpicture[remember picture]
     \node (A) {Node 1};
\stoptikzpicture
Hi world
\starttikzpicture[remember picture]
    \node (B) {Node 2};
\stoptikzpicture
\starttikzpicture[overlay,remember picture]
    \draw (B) --++(0,0.5) -| (A);
\stoptikzpicture
\stoptext

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.