Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}

Mindmap colouring oddities

There are two problems:

  1. 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.
  2. 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}

Mindmap with alternative colour definitions

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.

share|improve this question
1  
You may try \usepackage[rgb]{xcolor} or \usepackage[cmyk]{xcolor} in your preamble... –  Paul Gaborit Mar 22 at 23:58
    
Thanks. I did try something along those lines but not quite that. Loading xcolor before tikz with the option rgb does solve the issue. Unfortunately, it does not work in a beamer presentation due to an option clash for xcolor. This is actually one reason for the 'Background' section of my question. I suspected some solutions wouldn't work in that context. –  cfr Mar 23 at 0:12

1 Answer 1

TikZ uses RGB colors for color gradients.

With the package xcolor (required by tikz and beamer), you may:

  1. convert a CMYK color to a RGB color:

    \colorlet{yellow}[rgb]{yellow}
    
  2. convert a RGB color to a CMYK color:

    \colorlet{red}[cmyk]{red}
    

To always use RGB colors, pass the rgb option to xcolor:

\usepackage[rgb]{xcolor}

As beamer requires xcolor, you may pass this option before:

\PassOptionsToPackage{rgb}{xcolor}
\documentclass{beamer}
share|improve this answer
1  
Thanks - the \PassOptionsToPackage might be useful here. Why are the colours inconsistent, though? I could understand if, say, magenta produced something which was not quite magenta because it was trying to interpret a CMYK specification as an RGB one. What I don't understand is why magenta produces one colour for the nodes and one for the connectors. –  cfr Mar 23 at 15:11
    
I fear that choosing a color model different than rgb does not really help with shadings. In fact, it will cause (lossy) colorspace conversions, and the resulting shading will be in RGB. pgf currently supports only RGB for shadings. –  Christian Feuersänger May 21 at 20:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.