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
On 11/25/2024 4:07 PM, Aditya Mahajan wrote:
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:
sounds ok to me
\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
i assume youy send me a patch(ed file)
Should we include a wrapper for tikzcd (as we do for circuitikz) or should I try to push a patch upstream.
wrapper
BTW, why do we need a \hcontainer in the above code?
it makes sure we don't go into the box to mess around with context things (who knows what tikz adds in there that can interfere) 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 -----------------------------------------------------------------
On Mon, 25 Nov 2024, Hans Hagen wrote:
On 11/25/2024 4:07 PM, Aditya Mahajan wrote:
What is the best way to go about this? I can try to ask the
i assume youy send me a patch(ed file)
We need to add the following at the end of m-tikz.mkxl (I am no longer testing tikz for MkIV, so no patch for that). \startsetups tikz:hacks:tikzcd \permanent\protected\def\starttikzcd% {\starttikzinput \hcontainer\bgroup \tikzcd} \permanent\protected\def\stoptikzcd {\endtikzcd \egroup \stoptikzinput} \stopsetups \installtikzlibraryhacks{cd}{}{\directsetup{tikz:hacks:tikzcd}} A patched file is also attached. Then the following code works fine: \usemodule[tikz] \usetikzlibrary[cd] \starttext \startformula \starttikzcd x \arrow[d] \NC A \arrow[d] \NC D \NR y \NC B \NC D \NR \stoptikzcd \stopformula \stoptext I also wanted to add tikzcd to mtx-install-imp-tikz, but a TDS zip is not available at https://ctan.org/tex-archive/graphics/pgf/contrib/tikz-cd. I will check why that is not the case later, and if a CTAN TDS is available, send a patch to include it in install-imp-tikz. Aditya
participants (2)
-
Aditya Mahajan
-
Hans Hagen