This is a MWE:
\documentclass{article}
\usepackage{xcolor}
\begin{document}
\definecolor{mycolor}{HTML}{4CAF50}
\extractcolorspecs{mycolor}{\tmpmodel}{\tmpcolorspec}
My color model: \tmpmodel
My color spec: \tmpcolorspec
\convertcolorspec{\tmpmodel}{\tmpcolorspec}{cmyk}{\cmykcolorspec}
My color in cmyk: \cmykcolorspec
\convertcolorspec{\tmpmodel}{\tmpcolorspec}{HTML}{\htmlcolorspec}
My color in HTML: \htmlcolorspec\\
\colorbox{mycolor}{\parbox[b][5em]{4em}{\tiny mycolor}}
% Change color model
\selectcolormodel{cmyk}
\colorbox{mycolor}{\parbox[b][5em]{4em}{\tiny mycolor cmyk}}
\definecolor{mynewcolor}{cmyk}{0.38821,0,0.37251,0.31374}
\colorbox{mynewcolor}{\parbox[b][5em]{4em}{\tiny mynewcolor}}
\definecolor{mylastcolor}{cmyk}{0.5656,0,0.5429,0.3137}
\colorbox{mylastcolor}{\parbox[b][5em]{4em}{\tiny mylastcolor}}
\end{document}
This is the result:
Notice that mycolor
is defined using an HTML model: 4CAF50
. The color model selected by xcolor as default is rgb, as we can see from the extracted model. The color specification for this rgb model is 0.29805,0.68626,0.31374
, which is indeed the same as that we can get using some online color converter (https://www.colorhexa.com/4caf50). The color specification after a cmyk conversion is 0.38821,0,0.37251,0.31374
,
which is completely different from almost any conversion performed online, for example, is this site the result is 0.5656,0,0.5429,0.3137
. Finally, as you can see, the HTML specification corresponds to the original value, so we can think that rgb-to-HTML conversion is performed properly but rgb-to-cmyk doesn't.
We are working here with two completely different color spaces, it is understandable that the colors look different from one space to another, you can see the same think in applications like Adobe Photoshop as well. The problem here is the apparent error in the color conversion when we go from rgb to cmyk.
Why is this happening? How can I correct it? Is there some parameter that I am missing?