[NTG-context] TikZ node and color

Christoph Reller christoph.reller at gmail.com
Wed Jul 6 08:12:08 CEST 2016


On Tue, 5 Jul 2016 10:21:48 +0200, Hans Hagen <pragma at wxs.nl> wrote:
> On 7/5/2016 9:25 AM, Christoph Reller wrote:
>> Dear List,
>>
>> I use the latest version of ConTeXt and I have the following MWE:
>>
>> \usemodule[tikz]
>> \starttext
>>   \starttikzpicture
>>     \node {\color[red]{red}};
>>     \node[xshift=30] {\color[red]{not red}};
>>   \stoptikzpicture
>> \stoptext
>>
>> Can anybody tell me why the second node is not colored red?
>>
>> Aside: In LaTeX when using \color{red}{...} this tikzpicture renders
>> correctly. For LaTeX I use TikZ version 3.0.1a, in ConTeXt it seems to
>> be version 3.0.1.
>>
>> Any feedback is welcome.
>
> tikz has its own color mechanisms and they don't mix well with context
> color support so context probbably thinks it's still in red (so you need
> to force something non red in front)
>
> \starttikzpicture
>      \node {\color[red]{red}};
>      \node[xshift=30] {\zwnj\color[red]{not red}};
> \stoptikzpicture

Thank you Hans! This workaround does the job.

For those interested: The \zwnj can be prepended automatically to
every node by setting "every node/.add code=\zwnj". The updated MWE
now is:

\usemodule[tikz]
\tikzset{every node/.add code=\zwnj}
\starttext
  \starttikzpicture
    \node {\color[red]{red}};
    \node[xshift=30] {\color[red]{not red}};
  \stoptikzpicture
\stoptext

Cheers,
Christoph


More information about the ntg-context mailing list