ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Tikz CD
@ 2024-11-25 15:07 Aditya Mahajan
  2024-11-25 15:50 ` [NTG-context] " Hans Hagen
  0 siblings, 1 reply; 3+ messages in thread
From: Aditya Mahajan @ 2024-11-25 15:07 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

There was a recent question about what appeared to be commutative diagrams, and I wanted to reply saying that one option is to use tikzcd module. However, testing showed that it fails.

This is what tikzlibrarycd.code.tex does:

% ConTeXt-specific stuff
\pgfutil@IfUndefined{starttikzpicture}{}{%
  \def\starttikzcd{\tikzcd}
  \def\stoptikzcd{\endtikzcd}
  \tikzcdset{
    every matrix/.append code={%
      \def\NC{\pgfmatrixnextcell}%
      \def\NR{\pgfmatrixendrow}}}
}


where 

\def\tikzcd@[#1]{%
  \tikzpicture[/tikz/commutative diagrams/.cd,every diagram,#1]%
  ...}

So, it fails because \tikzpicture is being called with wrong catcodes. It can be fixed in the same manner as we patched tikzpicture as shown by the following MWE:

\usemodule[tikz]
\usetikzlibrary[cd]

\permanent\protected\def\starttikzcd%
  {\starttikzinput
   \hcontainer\bgroup
   \tikzcd}

\permanent\protected\def\stoptikzcd
  {\endtikzcd
   \egroup
   \stoptikzinput}

\starttext
\startformula
  \starttikzcd
    x \arrow[d] \NC A \arrow[d] \NC D \NR
    y \NC B \NC D \NR
  \stoptikzcd
\stopformula
\stoptext


What is the best way to go about this? I can try to ask the 

Should we include a wrapper for tikzcd (as we do for circuitikz) or should I try to push a patch upstream. 

BTW, why do we need a \hcontainer in the above code?


Aditya


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-26  6:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-25 15:07 [NTG-context] Tikz CD Aditya Mahajan
2024-11-25 15:50 ` [NTG-context] " Hans Hagen
2024-11-26  6:39   ` Aditya Mahajan

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