[Tex/LaTex] Tool (or formula) that to convert RGB color to xcolor code (example of the type red!30!green)

colortools

Often I use xcolor package also to create several and customize kinds of colors.

Many times I use the combination of the page 33 because it's understandable to me:

enter image description here

But to find the exact shade of color, I do a lot of tests, which take even a few hours. Sometimes I use the colors of dvipsnames, via svgnames, via x11names.

I ask if somebody knows an online tool (or a specific formula) that convert me directly an RGB color with a code like, for example, blue!50!yellow. This question is closely connected to another one that you can find on this link:

https://graphicdesign.stackexchange.com/questions/120490/as-to-known-the-colors-used-in-an-image

I don't want to define a long list of \definecolor{name}{model}{color-spec} (for example \definecolor{ultramarine}{RGB}{0,32,96}) because I forget all the custom colors that I have customized.

Best Answer

You can search the internet with rgb to cmyk to find free online calculators to change an rgb color to an cmyk color. In this case it is important to respect the color profile the printer supposed to print your document is using.

For example you can have a look to https://www.rgb2cmyk.org/ or https://www.pdf2cmyk.com/ for pdf file.

With LaTeX you can use \testcolor (as mentioned in an comment by @Fran, see his answer here) to get an first idea of the used color in different models but that does not respect the needed color profile of the printer ...

At last the only one who can tell you which color values gives the printed color you want is the printing house you use to publish your document.

Why are colors problematic?

Let us have a look on rgb colors. They are used on monitors or screens. And that is the problem: the shown color depends on the configuration of the monitor (contrast, brightness). In other words: if you change the monitor (or the complete computer) you will see other colors displayed, but still using the same color value in rgb or cmyk.

To make things worse the used color modell to print colors on paper is cmyk. And again the real printed color depends on the used paper (thickness, color of paper) and the used printer, its used ink or toner and the used color profile.

So you can get different printed colors by using the same cmyk value!

To make things more worse the available colors in rgb model and cmyk model are not the same, some of them for example do not exist in the other color model.

To change a rgb value to cmyk (by exactly the rip software of the printing system) there are calculations neseccary resulting in rounding errors. So if you use a rgb value in your latex code/pdf file you can not be sure which cmyk value results.

Conclusion:

To get the best result talk to the printing house publishing your book/document. Ask them which cmyk values for the colors you should use to get the expected result. I'm sure they will ask you not to use too much colors.

Now use \definecolor{name}{model}{color-spec} in your LaTeX code like

\definecolor{myred}{cmyk}{0,1,1,0}

to use the named color in your document with \textcolor{myred}{This is in red!} or simular. Or you can name the colors after the reason to use, for example in section, chapter, etc. to be able to remember it easier ...

The main advantage now is that you can very easy change the color value depending on your printing house.

Conclusion:

  1. Talk with the printing house to define proper printing colors for your document.
  2. Use the given color values.
  3. Ignore the shown colors on your monitor. Only the printed result is important. (The only way to get the printed colors shown on the screens you need an expensive special printing system!)