35

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

2
  • 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. Commented Nov 15, 2011 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? Commented Nov 15, 2011 at 13:36

2 Answers 2

30

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

4
  • 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. Commented Nov 15, 2011 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. Commented Nov 16, 2011 at 9:10
  • 2
    (1) is a loop, as already mentioned ... and it is my text from my book ... :-)
    – user2478
    Commented Nov 16, 2011 at 10:59
  • What is the unit vector e? If we do the the maths based on the cited paragraph, then e = (0.25, 0.25, 0.25) which is doesn't have norm 1.
    – ado sar
    Commented Mar 3, 2023 at 19:15
11

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .