23

I fail to understand the color mixing of xcolor.

I want to have a lighter and a darker version of a color defined as

\definecolor{BlueLUH}{cmyk}{1.0,0.7,0,0}

My approach of lighter and darker is this one

\colorlet{LightBlue}{BlueLUH!20!white}
\colorlet{DarkBlue}{BlueLUH!80!black!20}

which according to the docs is replaced internally to

\colorlet{LightBlue}{BlueLUH!20!white!white}
\colorlet{DarkBlue}{BlueLUH!80!black!20!white}

Now I wonder what is actually calulated, bcause I get the same for Light and Dark, as can be seen in the following screenshot: enter image description here

  • 1
    I think white is only taken as default color if there is no second color, so: BlueLUH!20 is taken as BlueLUH!20!white, while BlueLUH!20!white will stay as it is and not taken as BlueLUH!20!white!white. But I could be wrong, of course. – Martin Scharrer Nov 15 '11 at 12:48
  • @MartinScharrer: that would make sence. Nevertheless how is it calulated? Blue*0.8 + black*0.2 + 1.0*white or blue*1.0+black*0.8+white*0.2 or even different? – Matthias Pospiech Nov 15 '11 at 13:36
21

That are different colors, but cannot be seen! 20% of black is less than light gray! Compare it with a 40% of black! The values for the cmyk color can easily be seen in the pdf output when using \pdfcompresslevel=0.

The colors are calculated as:

enter image description here

\pdfcompresslevel=0
\documentclass{article}
\usepackage[cmyk]{xcolor}

\definecolor{BlueLUH}{cmyk}{1.0,0.7,0,0}
\colorlet{LightBlue}{BlueLUH!20!white}
\colorlet{DarkBlue}{BlueLUH!80!black!20}
%\colorlet{LightBlue}{BlueLUH!20!white!white}
%\colorlet{DarkBlue}{BlueLUH!80!black!20!white}

\begin{document} 

\color{BlueLUH}\rule{1cm}{1cm}
\color{LightBlue}\rule{1cm}{1cm}
\color{DarkBlue}\rule{1cm}{1cm}

\color[cmyk]{1, 0.7, 0, 0}\rule{1cm}{1cm} 
\color[cmyk]{0.2, 0.14, 0, 0}\rule{1cm}{1cm}
\color[cmyk]{0.16, 0.112, 0, 0.04}\rule{1cm}{1cm}

\colorlet{DarkBlue}{BlueLUH!80!black!40}
\color{BlueLUH}\rule{1cm}{1cm}
\color{LightBlue}\rule{1cm}{1cm}
\color{DarkBlue}\rule{1cm}{1cm}

\end{document}

enter image description here

  • It is correct that they are not equal, but they are so close that the eye can not distinguish between them. Unfortunately this does not tell me how to get darker colors using colormixing with xcolor. – Matthias Pospiech Nov 15 '11 at 13:34
  • from which document are these formulas? i can not find them within the xcolor package. I understand how red!75 is calculated with eqn (1), but the calculation of red!75!blue!100 does not seems to be relatd to eqn (1). At least something in the calculation was left out, since eqn (1) does not mention how more than one color is combined. – Matthias Pospiech Nov 16 '11 at 9:10
  • 2
    (1) is a loop, as already mentioned ... and it is my text from my book ... :-) – user2478 Nov 16 '11 at 10:59
7

For darker color try \colorlet{DarkBlue}{BlueLUH!80!black} instead. This way it will be Blue*0.8 + black*0.2.

If you add second number then third color (i.e. white) will be added, and you don't need that.
As I understand it, BlueLUH!80!black!30 would be (Blue*0.8 + black*0.2)*0.3 + white*0.7

Please see http://en.wikibooks.org/wiki/LaTeX/Colors#Examples

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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