0

I know, that when you create a PDF, you can easily have some elements as RGB and some as CMYK. But is it also possible, that the same element (e.g. a background) has both definitions in a PDF and depending on the driver (screen or printer) the RGB or CMYK definition is used.

So I know, that when we use xcolor, you can say

\usepackage[rgb]{xcolor}

or

\usepackage[cmyk]{xcolor}

but this definitely changes which color scope is used. So when we defined

\definecolor{Black}{RGB/CMYK}{0,0,0/0.0,0.0,0.0,1.0}

either one or the other is used. But can also both be used in the PDF depending on the purpose?

TobiBS
  • 5,240

1 Answers1

3

Yes. There are multiple ways of doing this. First, it's the default. If you load just \usepackage{xcolor}, every color will be saved in the way you specified it. Only if we explicitly request a colormodel through [rgb] or [cmyk] everything gets converted into a uniform model.

You can also change the model all colors get converted to by issuing \selectcolormodel{...}:

\documentclass{article}
\usepackage{xcolor}
\definecolor{BlueRGB}{RGB}{0,0,1}
\definecolor{BlueCMYK}{CMYK}{1,1,0,0}
\begin{document}
\color{BlueRGB} This is in RGB.

\color{BlueCMYK} This is in CMYK.

\selectcolormodel{CMYK}
\color{BlueRGB} Still CMYK.

\color{BlueCYMK} Still CMYK.

\selectcolormodel{RGB}
\color{BlueCMYK} Now we are back to RGB.

\color{BlueRGB} Nothing changed.

\selectcolormodel{natural}
\color{BlueCMYK} We are again in CMYK territory.

\color{BlueRGB} And back to RGB.
\end{document}

enter image description here

  • Thanks @Marcel Krüger for your explanation. As I mentioned I know, that there can be CMYK and RGB in a document at the same time. However with my example of \definecolor{Black}{RGB/CMYK}{0,0,0/0.0,0.0,0.0,1.0} is there a way to preserve both color definitions for the same element and let the driver displaying/printing the PDF decide? – TobiBS Apr 07 '20 at 19:48