# LaTeX color and ICC color profiles

I have a (pdf|Xe)LaTeX document and trying to keep it CMYK. For some documents, I use a certain color for it's elements, which is RGB #BDCDDA. As my final document should be using the Adobe CMYK profile "CoatedFOGRA39.icc", I need to manually convert that RGB value to e.g. this:

\DefineNamedColor{named}{mycolor}{cmyk}{0.3203,0.1602,0.1172,0.0000}


But, if in the future I want to switch to a different CMYK color profile for maybe another printing company, I have to edit the color definition again, as for example an USWebCoatedSWOP version of RGB #BDCDDA has different CMYK values.

Ideally, I would like to write something like

\DefineNamedColor{named}{mycolor}{/path/to/CoatedFOGRA39.icc}{#BDCDDA}


and have the color auto-converted from RGB (can be considered to be sRGB colorspace) to the correct CMYK value.

Can any LaTeX package help me here, or do I have to set up an external workflow to pre-generate LaTeX snippets with correct CMYK color definitions?

Sidenote: this question is not about embedded figures/pictures, but about using named colors for text and background.

• Would it be an option to include the colors as RGB and post-process your PDF using, e.g., Adobe Acrobat to convert all RGB colors to CMYK using the appropriate profile? (I haven't tested it, but think that it should work.) Jun 26, 2012 at 8:56
• Post-processing would be an option for me, but not using commercial software. I would need a free tool running on Ubuntu. Jun 26, 2012 at 19:27
• I had the feeling that tex.stackexchange.com/a/9973/13450 and tex.stackexchange.com/a/99666/13450 are somehow relevant here. Feb 25, 2013 at 0:21

I think the simplest is to put your definitions in a local package so they can easily be shared between documents and customised to different profiles.

In your document put something like

  \usepackage[CoatedFOGRA39]{mycolor}


if you specify a profile that you have set up, relevant definitions are made, otherwise you get an error. mycolor.sty could look something like this:

\RequirePackage{color}

\DeclareOption{CoatedFOGRA39}{\def\mycolor{CoatedFOGRA39}}
\def\mycolorprofileA{CoatedFOGRA39}
\ProcessOptions\relax

\ifx\mycolor\@undefined
\PackageError{mycolor}{No color profile declared}{declare a color profile}
\fi

\ifx\mycolor\mycolorprofileA
\DefineNamedColor{named}{mycolor}{cmyk}{0.3203,0.1602,0.1172,0.0000}
\fi


The above just declares one colour in one profile, but it could be extended...

• This sounds as a reasonable simple workaround to me if no real ICC handling exists. Jun 26, 2012 at 19:29
• Since there was no better idea proposed, I accepted this workaround as solution. Jul 1, 2012 at 6:56

After a close look this question does not make sense. Why? If you care about correct colours, RGB #BDCDDA is not a colour. It becomes a colour together with an RGB colour profile (sRGB and AdobeRGB being popular ones). But it does not become a colour together with a CMYK profile because for a conversion you need a start and a destination profile. Here we can guess because of the web-like hex style of the colour values that the source profile probably is sRGB. But likely the one who gave you the values does not master colour management otherwise he/she/they would have told you the profile.

I see three solutions how to handle this correctly:

### 1 RGB based colour managed document

\documentclass{book}
\usepackage{xcolor}
\usepackage{luatex85}

%Create an OutputIntent in order to correctly specify colours
\immediate\pdfobj stream attr{/N 3} file{sRGB.icc}
\pdfcatalog{%
/OutputIntents [
<<
/Type /OutputIntent
/S /GTS_PDFA1
/DestOutputProfile \the\pdflastobj\space 0 R
/OutputConditionIdentifier (sRGB)
/Info (sRGB)
>>
<<
/Type /OutputIntent
/S /GTS_PDFX
/DestOutputProfile \the\pdflastobj\space 0 R
/OutputConditionIdentifier (sRGB)
/Info (sRGB)
>>
]
}

\DefineNamedColor{named}{mycolor}{HTML}{BDCDDA}

\begin{document}
\textcolor{mycolor}{light blue text}
\end{document}


If this does not look as an answer because it's an RGB document keep in mind that every good print shop does a colour conversion anyway specifically for their machine. As long as they know the source profile they can handle it.

### 2 CMYK based colour managed document

\documentclass{book}
\usepackage[cmyk]{xcolor}
\usepackage{luatex85}

\immediate\pdfobj stream attr{/N 4} file{ISOcoated_v2_300_eci.icc}
\pdfcatalog{%
/OutputIntents [
<<
/Type /OutputIntent
/S/GTS_PDFA1
/DestOutputProfile \the\pdflastobj\space 0 R
/OutputConditionIdentifier (Coated FOGRA39)
/Info(FOGRA39L)
>>
<<
/Type /OutputIntent
/S/GTS_PDFX
/DestOutputProfile \the\pdflastobj\space 0 R
/OutputConditionIdentifier (Coated FOGRA39)
/Info(FOGRA39L)
>>
]
}

\DefineNamedColor{named}{mycolor}{cmyk}{0.3203,0.1602,0.1172,0.0000}

\begin{document}
\textcolor{mycolor}{light blue text}
\end{document}


This will work too. On a calibrated screen viewed with a colour management capable viewer you will see the correct colours. This under the assumption that the conversion of the values you have made is correct.

### 3 CMYK OutputIntent with RGB text object

\documentclass{book}
\usepackage[cmyk]{xcolor}
\usepackage{luatex85}

\immediate\pdfobj stream attr{/N 4} file{ISOcoated_v2_300_eci.icc}
\pdfcatalog{%
/OutputIntents [
<<
/Type /OutputIntent
/S/GTS_PDFA1
/DestOutputProfile \the\pdflastobj\space 0 R
/OutputConditionIdentifier (Coated FOGRA39)
/Info(FOGRA39L)
>>
<<
/Type /OutputIntent
/S/GTS_PDFX
/DestOutputProfile \the\pdflastobj\space 0 R
/OutputConditionIdentifier (Coated FOGRA39)
/Info(FOGRA39L)
>>
]
}

\DefineNamedColor{named}{mycolor}{HTML}{BDCDDA}

\begin{document}
\textcolor{mycolor}{light blue text}
\end{document}


Even if you declare an OutputIntent for the whole PDF you could assign a different colour profile to certain text objects as in this MWE. But I don't know which internal conversion algorithm is applied so I don't recommend this way.

For all three ways I recommend using the full PDF/A and/or PDF/X standard, not just the MWE I show here. Here I show how such a document would look like.

I used a dual OutputIntent in my examples because a viewer can apply the A or X. There will be colour unmanaged viewers too. If you use both with the same profile you are on the safe side.