# Status of TiKz with ConTeXt MkIV

Whats the recent status of TiKz support in ConTeXt MkIV? I'm asking because in pgfmanual 2.10 on page 25 it says:

Note that pgf/TikZ is not supported by recent ConTEXt versions (like mark IV, the LuaTEX-aware part of ConTEXt).

I tried the following example but it doesn't work as expected.

\setupcolors[state=start]
\usemodule[tikz]

\starttext

\starttikzpicture
[node distance=4cm,
place/.style={circle,draw=blue!50,fill=blue!20,thick,
inner sep=0pt,minimum size=6mm}]

\node[place] (wat) {};
\node[place] (wag) [below=of wat] {};

\stoptikzpicture

\stoptext


No matter how big the node distance=4cm is, the circles are overlapping with an offset of approximately 0.5cm.

ConTeXt version: mtx-context | current version: 2012.05.22 16:12

I fail to find the quote you mention in the manual. (see edit)

TikZ is supported in the current ConTeXt. However, there are not many people using TikZ in ConTeXt. That, in turn, means that bugs are not detected that easily. When you translate the LaTeX specific commands that are used in the manual (e.g. font switching commands) to ConTeXt-flavoured ones, you should get the desired result.

When the file compiles, but the output is unexpected, a look at the logfile almost always tells you what is wrong. You, in your particular example are missing the \usetikzlibrary[positioning] call.

Edit: I had an older version of the manual not containing the quote you mention. The newer version apparently does not officially support ConTeXt MkIV (I guess neither did the old one). However, I use TikZ in combination with a current MkIV and most of the time it works as expected.

• It seems it has a bug with colors – somenxavier Dec 10 '16 at 21:01

My notes on going from LaTeX tikz to ConTeXt MkIV tikz.

Step one, installation:

first-install.sh --modules="t-tikz"


Step two, usage: Like tikz under LaTeX, except for these differences:

• \start...\stoptikzpicture for \begin{tikzpicture}...
• \start...\stopscope for \begin{scope}...
• Every named color used by tikz must be defined like so (\unprotect not needed, at least not in MkIV):

\pgfutil@definecolor{coscolor}{rgb}{0, 0, 0.8}
\pgfutil@definecolor{fillcolor}{gray}{.625}

• Every named color used by tikz in a text node must be defined the normal ConTeXt way:

\definecolor[coscolor][r=0, g=0, b=0.8]
\definecolor[fillcolor][s=.625]

• (For comparison: this is how tikz/pgf defines colors)

\definecolor[coscolor][r=0,g=0,b=.8]
\definecolor[fillcolor][.625black]

• It does not matter where you place the color definitions!

Lastly, for those interested in automatic conversion, here is a list of all substitutions to make:

\\begin{tikzpicture}  --> \\starttikzpicture
\\end{tikzpicture}    --> \\stoptikzpicture

\\begin{scope}        --> \\startscope
\\end{scope}          --> \\stopscope

% Because we don't know for any of the defined colours whether tikz
% will use them in a text node or in a drawing bit, we replace the
% original with the ConTeXt definition *and* the pgfutil definition.
\\definecolor[named]{coscolor}{rgb}{r=0,g=0,b=.8}
-->
\\definecolor[coscolor][r=0,g=0,b=.8]
\\pgfutil@definecolor[named]{coscolor}{rgb}{0, 0, 0.8}

\\definecolor[named]{fillcolor}{.625black}
-->
\\definecolor[fillcolor][s=.625]
\\pgfutil@definecolor{coscolor}{gray}{.625}

• Some additional information: The \pgfutil@… hack is a temporary one. A fix was recently discussed on the mailing list. With that fix you can use ConTeXt colours in TikZ without double-defining them. However, that issue needs to be fixed upstream, which takes some time. Also see the bug report. – Marco May 23 '12 at 8:29
• @Marco: And I see the fix was not merely discussed, but also indeed submitted to TikZ. Thanks! to the both of you. Now we wait. Good things come to those who wait. – Esteis May 23 '12 at 10:16
• @Marco I patched this afternoon the corresponding file in the cvs repo thanks to the fix provided. So work now. – cjorssen May 23 '12 at 20:46