# Consistent color appearance with RBG and CMYK color models

I have trouble choosing a constitent color scheme. So far, I have worked with the xcolor package and custom RGB colors, but for printing, the CMYK color model seems to be prefered. I hope that I can put together a meaningful question. I am a bit confused about the different color models, gamuts, and conversions etc. (Please correct me if some assumption do not make any sense)

Let's assume that I want to color something in Cyan. With the RGB color model, I currently use the color (0, 183, 235) / #00B7EB. If I use the CMYK color model, I want to use the color (1,0,0,0) for that. The definition seems to be equivalent, see e.g. the "subtractive primary" cyan on wikipedia. Slight variations are observed in the output pdf, however. Picking the color of the cmyk definition gives (0,173,239) for me. But this is visually almost neglible. (A slightly better fit might be possible if the cmyk value is slightly decreased from 1, as I have observed)

The issue is that the CMYK color defition looks completely different in RGB, and vice versa.

How can I solve this issue in order to have the same output no matter which color model I choose? Is it necessary to find, by trial and error, "almost matching" combinations of rbg/cmyk definitions and switch these definitions if I want to compile the document with one of the two color models? Or is it acceptable for a purely digital PDF to use the CMYK color model to avoid double defintions (and how to find these definitions if I currently use RGB)? Or is there a solution within the xcolor package or any other package that I have overlooked so far?

In order to demonstrate the problem, a brief MWE and its output.

\documentclass{standalone}
\usepackage{xcolor}

\definecolor{cyan1}{RGB}{0, 183, 235}
\definecolor{cyan2}{cmyk}{1, 0,0,0}
\begin{document}
\begin{testcolors}[rgb,cmyk]
\testcolor{cyan1}
\testcolor{cyan2}
\end{testcolors}
\end{document}


(possibly related question: xcolor-material issue with cmyk document)

• you can check the formulae xcolor uses and use the same or you can let the package do the conversions for you. You can specify the colors in a different models but specify they are all output using cmyk (or rgb) see section 6 of the xcolor manual for the formulae it uses. also \convertcolorspec to explicly convert a color from rgb to cmyk or vice versa May 27, 2021 at 22:54
• There is no single solution and it is explained in the Wikipedia page that you mention: Cyan printing ink is typically more saturated than the RGB secondary cyan, depending on what RGB color space and ink are considered. That is, process cyan is usually outside the RGB gamut and there is no fixed conversion from CMYK primaries to RGB. May 27, 2021 at 23:52

Your end goal isn't quite clear.

But I think you'd like a single TeX source file and then be able to choose whether you'd like either RGB output for screen or CMYK output for print and have the two results looking vaguely similar.

As is pointed out in the comments there is no one correct answer to this since RGB does not map on to CMYK in one way. There are many variables including the screen you're looking at, the printing process you're using, and the paper you are printing on.

Neither can you use the xcolor formulae to convert from one colour model to another. It's so simplistic as to be useless.

Design software uses colour profiles to convert between colour models which allows a file to be designed in (say) RGB and then exported as a CMYK PDF. LaTeX does not have this ability (although it would be a cool feature).

So you have to do your conversions yourself as you've done in your question. You can use any piece of colour managed software for this (e.g., Photoshop, Illustrator, Scribus). You could also use https://www.pantone.com/color-finder which at least accounts for coated and uncoated stock variations. I'm not aware of an online tool to convert between colour models which makes use of colour profiles. Remember these are still approximate at typically rely on assumptions about your monitor and print conditions.

Once you have an RGB and a CMYK colour, you can define them in a way that picks up the current colour model:

\definecolor{PANTONE P 115-8 U}{RGB/cmyk}{0,158,220/1.0,0.0,0.0,0.0}


This will define a colour in either RGB or CMYK depending on the current xcolor colour model (selected with \usepackage[rgb]{xcolor} or \usepackage[cmyk]{xcolor}.

Then you can refer to the colour by name in your document and only have to change one line to switch between RGB and CMYK output when you compile.

# MWE

## For RGB

\documentclass{article}
\usepackage[rgb]{xcolor}
% Colour definitions taken from https://www.pantone.com/color-finder
\definecolor{PANTONE P 115-8 U}{RGB/cmyk}{0,158,220/1.0,0.0,0.0,0.0}
\definecolor{PANTONE P 48-7 U}{RGB/cmyk}{220,85,82/0.0,0.87,0.8,0.0}
\begin{document}
\begin{testcolors}[RGB]
\testcolor{PANTONE P 115-8 U}
\testcolor{PANTONE P 48-7 U}
\end{testcolors}
\end{document}


## For CMYK

\documentclass{article}
\usepackage[cmyk]{xcolor}
% Colour definitions taken from https://www.pantone.com/color-finder
\definecolor{PANTONE P 115-8 U}{RGB/cmyk}{0,158,220/1.0,0.0,0.0,0.0}
\definecolor{PANTONE P 48-7 U}{RGB/cmyk}{220,85,82/0.0,0.87,0.8,0.0}
\begin{document}
\begin{testcolors}[cmyk]
\testcolor{PANTONE P 115-8 U}
\testcolor{PANTONE P 48-7 U}
\end{testcolors}
\end{document}


• I have some LuaTeX code for doing color profile based conversions, but it's much less useful than you might expect since most of the time the colors we want to convert are outside of the gamut for the target color profiles (especially since common color names like cyan, red, green, etc map to primaries which are often not representable exactly in other color schemes) and for most users neither for the screen nor for the printer precise color profiles exists, therefore the conversion is still kind of arbitrary. May 28, 2021 at 11:09
• @MarcelKrüger, interesting! I'd wondered if anyone had done this. Do you use Lua bindings for LittleCMS? I guess it just works for solid colours and not images? Do you have example code and usage anywhere? May 28, 2021 at 13:23
• Thank you for this helpful answer! "[...] have the two results looking vaguely similar" sums my intentions up very well. I tried the pantone website and scribus, and this should fully enable me to find matching pairs of color definitions. My understanding of the issue is now that the current conversion of xcolor achieves that different looking colors stay distinguishable; my goal is contradictory, namely that colors in the gamut overlap should stay the same and outside the gamut should be approximated as good as feasible. May 28, 2021 at 14:21
• @DavidPurton No, it implements parsing of ICC profiles and color conversion directly. I uploaded it now to github.com/zauguin/luaicc , but there isn't any high level interface since I never saw a good use for it, but there is a test.tex demonstrating it's use with l3color. Feel free to add issues if you can think of a reasonable interface or find issues. (It has mostly been written to get a better understanding of the ICC profile file format, so I never used it for anything practical) May 28, 2021 at 21:24