Background
I was trying to draw a mindmap using the tikz
mindmap
library for possible use in a beamer
presentation.
The Problem
Depending on my choice of colours, the colour of nodes does not match the colours of the connectors linking them to other nodes. This is true whether the connections are automatically created using the mindmap's hierarchy or whether the connections are added manually afterwards in a \path
operation.
MWE
This code demonstrates the problem. The first map is straight from page 662 of the manual and works fine. The second map is just like the first except that the colours used are different.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{mindmap}
\begin{document}
\tikz[mindmap,concept color=blue!80]
\node [concept] {Root concept}
child[concept color=red,grow=30] {node[concept] {Child concept}}
child[concept color=orange,grow=0] {node[concept] {Child concept}};
\tikz[mindmap,concept color=magenta]
\node [concept] {Root concept}
child[concept color=cyan,grow=30] {node[concept] {Child concept}}
child[concept color=yellow,grow=0] {node[concept] {Child concept}};
\end{document}
There are two problems:
- The node colours are not as expected. This is less obvious in the case of yellow but very obvious in the case of cyan and magenta.
- The colours are not consistent. That is, the connectors seem to use colours like those I would expect, even though the nodes do not. So the connectors do not flow smoothly to/from the nodes.
Investigation
The colours which work consistently are all defined using the RGB model. The colours which produce inconsistent results are all defined using the CMYK model. A work around is to define alternative colours in the RGB model. For example, to define a new colour, rgbmagenta
just like magenta
but in terms of rgb
rather than cmyk
.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{mindmap}
\definecolor{rgbmagenta}{rgb}{1,0,1}
\definecolor{rgbcyan}{rgb}{0,1,1}
\definecolor{rgbyellow}{rgb}{1,1,0}
\begin{document}
\tikz[mindmap,concept color=rgbmagenta]
\node [concept] {Root concept}
child[concept color=rgbcyan,grow=30] {node[concept] {Child concept}}
child[concept color=rgbyellow,grow=0] {node[concept] {Child concept}};
\end{document}
Question
Why exactly does this happen? Can it be avoided without redefining colours as I did in the workaround?
I fear this question is surely a duplicate but searching has so far turned up nothing especially enlightening. I have found threads suggesting that TikZ may be converting colours from the CMYK model to RGB but while that might explain the colours not being quite as expected, it doesn't explain the inconsistencies.
Best Answer
TikZ (before version 3.1.3) uses RGB colors for color gradients.
With the package
xcolor
(required bytikz
andbeamer
), you can:convert a CMYK color to a RGB color:
convert a RGB color to a CMYK color:
To always use RGB colors, pass the
rgb
option toxcolor
:As
beamer
requiresxcolor
, you must pass this option before: