28

I am trying to produce a CMYK PDF file to pass onto a printshop.

When I use the [cmyk] option for the xcolor package, the colours in the resulting PDF do look muted and less vibrant as is the case with the CMYK colorspace. For example,

\documentclass{minimal}
\usepackage[cmyk]{xcolor}
\begin{document}
\textcolor{blue}{\fontsize{24}{28}\selectfont A}
\end{document}

when processed by pdflatex produces a PDF file that appears onscreen like a muted, darkish CMYK colorspace document, but when I run ImageMagick's identify command on the PDF using

identify -verbose cmyk.pdf | grep Colorspace

I get

Colorspace: RGB

Surely the PDF uses only one of CMYK or RGB for colour. How can I reliably tell which?

Also, if it is indeed an RGB PDF why does it appear so different from the version I get if the line

\usepackage[cmyk]{xcolor}

is replaced by

\usepackage[rgb]{xcolor}

Thanks in advance.

2
  • 6
    tex.stackexchange.com/questions/9961/pdf-colour-model-and-latex has a lot to say about color and PDF. Mar 9, 2011 at 18:45
  • The option [cmyk] causes xcolor to automatically transfrom RGB colors to cmyk (unless it already knows the result), doesn't it? If so: the conversion RGB -> cmyk in xcolor is acceptable, but it could be better. Ah: it is mentioned in @ChristianLindig's link: "which are not very sophisticated -- compare them to the formulas in 10.3 of the PDF spec, with BG(k) and UCR(k) functions, etc" Jun 30, 2013 at 10:42

3 Answers 3

19

With using \pdfcompresslevel=0 for PDFTeX or with \pdfvariable compresslevel for LuaTeX I'll get the pdf with no compressed streams and can see what happens inside the pdf.

With the cmyk option I get:

stream
0 0 0 1 k 0 0 0 1 K
0 g 0 G
0 0 0 1 k 0 0 0 1 K
1 1 0 0 k 1 1 0 0 K
BT
/F15 24.7871 Tf 91.925 752.955 Td [(A)]TJ
0 0 0 1 k 0 0 0 1 K
0 0 0 1 k 0 0 0 1 K
0 0 0 1 k 0 0 0 1 K
ET
endstream

and with the rgb option:

stream
0 0 0 rg 0 0 0 RG
0 g 0 G
0 0 0 rg 0 0 0 RG
0 0 1 rg 0 0 1 RG
BT
/F15 24.7871 Tf 91.925 752.955 Td [(A)]TJ
0 0 0 rg 0 0 0 RG
0 0 0 rg 0 0 0 RG
0 0 0 rg 0 0 0 RG
ET
endstream

which is what I would expect, a correct color setting. But printing a RGB color is not the same as printing a CMYK color ...

3
  • How did you get that? Mar 9, 2011 at 21:40
  • \pdfcompresslevel=0
    – user2478
    Jan 18, 2013 at 7:19
  • If you're using xelatex, use \special{dvipdfmx:config z 0} instead.
    – richard
    Oct 24, 2020 at 17:09
20

There's not really such a thing as a 'CMYK PDF' or an 'RGB PDF'. PDFs can contain objects coloured in RGB and CMYK (and many other) colour spaces. See my answer here for some details. So your statement "Surely the PDF uses only one of CMYK or RGB for colour." is wrong, and it's unclear to me on what basis "identify -verbose" is deciding that it is RGB. Maybe the colorspace just defaults to RGB, even for formats where that doesn't make sense?

As for your question: "How can I reliably tell which?", in addition to @Herbert's suggestion to look at the uncompressed PDF stream (if that means anything to you) you can use Adobe Acrobat Professional has various tools to see which colour spaces are being used and where. An "Output preview" tool; a "Preflight" tool; a "convert colors" tool; etc.

3
  • Thank you for setting me right. Is there a Linux-friendly software package to do what Adobe Acrobat Professional does above? Thanks.
    – chandra
    Mar 14, 2011 at 14:47
  • +1---I just ran identify on a PDF created with ConTeXt using only CMYK colors and got Colorspace: RGB as well. Makes me suspect ImageMagick isn't telling the whole story.
    – Sharpie
    May 9, 2011 at 4:56
  • identify (or for that matter ImageMagic) does not properly identify the color space of a PDF file -- even if the PDF file uses only one color space. It converts the PDF to an RGB image and then reports the color-space of that image (which is obviously RGB). The problem has been reported to ImageMagic developers, but it is not taken very seriously by any of them -- so it is not likely to get fixed.
    – Paulo Ney
    Jun 27, 2018 at 2:52
2

I add the same problem with a LaTeX file.

I wanted to obtain a cmyk PDF file by using \includepackage[cmyk]{xcolor} but my document was in RGB.

So, since I insert a picture in CMYK color format, the PDF file is in CMYK.

I think if you use coloration for your text, you must add the cmyk option.

For example \definecolor{red}{rgb}{This is text RGB}

For example \definecolor{red}{cmyk}{This is text CMYK}

CMYK does not run if you don't use it.

If all you document is in RGB, your PDF file will be in RGB.

If you insert one mention of cmyk in your code, like in the example, your PDF file will be in CMYK.

Good luck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.