I always thought that none of the engines is capable of converting colors of external image files. However today I noticed that a gray scale image gets – somehow – converted to CMYK when using xelatex instead of pdflatex.

This is my test code:

% !TeX program = xelatex



With \XeTeX
%With \LaTeX


You can download the image file, my code and the resulting PDFs here: grayscale-test.zip

Here’s the result shown with Acrobats color separation preview. As you can see the PDF generated by xelatex has a CMYK image while the one made with pdflatex sticks to gray (K) only (same source file for the image!).

comparing results

(the cross indicates the measuring point)


In the meantime a colleague told me that both PDFs (from pdflatex and xetex) are missing the OutputIntent. So in fact the embedded images are in Grayscale but Acrobat doesn’t know how to interpret them (I don’t know what makes the difference in between the two engines). So the image seems to be CMYK and is interpreted as such but actually is in Grayscale.

This is the preflight result; showing that the image itself is still in gray scale.

preflight result

  • 1
    pdfTeX and XeTeX have different underlying approaches in including graphics. Using XeTeX seems to be like a minefield, better switch to LuaTeX. – Henri Menke Aug 24 '16 at 16:50
  • For pdfTeX the relevant bits are in image.h and writejpg.c. – Henri Menke Aug 24 '16 at 16:51
  • for XeTeX it's jepgimage.c, jpegimage.h, and XeTeX_pic.c. – Henri Menke Aug 24 '16 at 16:56
  • @HenriMenke: Thanks for the references, but I can’t read/understand them … is there anything I have to care about when switching to LuaTeX (e.g. changed line breaks etc.)? I thought LuaTeX is not yet considers production ready … – Tobi Aug 24 '16 at 17:25
  • Can you please test this pdf xelatex-ed from your MWE and tell if Adobe Acrobat still finds CMY components? I have an idea but can't test since I don't have Adobe A. – alwaysask Aug 24 '16 at 18:45

Why does XeTeX change gray scale JPG to CMYK?

Short answer: Neither XeLaTeX nor pdfTeX did convert the image. Proof: Export the image in Acrobat Pro and you get a grey gamma 1.8 .jpg with both engines.

The XeLaTeX behaviour is the standard way when a grey scale image is printed on a CMYK printer. This leads to darker black but registration errors may be visible.

Long answer:

Other people already have mentioned you should use an OutputIntent. They are correct but it does not answer the question.

If you intend to print your document on a printer with black ink only, you will obviously print all shades with black only. Plain black ink will be the darkest you can get.

However, if you print your document on a CMYK printer (standard case today) you have multiple options how to print black. One option would be to print black as 100% cyan, magenta and yellow as you would expect for subtractive colour theory. But in real world this would lead to a brownish black. And because there is too much paint on top of each other paint wouldn't dry fast enough (liquid paint) or not stick well enough on paper (digital/laser printing).

In practice black and dark greys are printed as pitch black (german Tiefschwarz). This means you use all four paints, with values between 60% and 70% for cyan, magenta and yellow, and ~90% black. The detailed values depend on the paper. More expensive paper can hold more ink and thus display darker black.

(sidenote: This is why OutputIntent is not only an ICC profile but also a paper type, together a reference printing condition.)

Each conversion method has it's advantages and disadvantages. The XeTeX method (called under colour reduction) results in darker blacks but registration errors may occur because the different paint never 100% lay over each other. Also grey shades can look less neutral. It's the preferred method for images. The Gray Component Replacement (GCR) applied by pdfTeX does not show registration errors at the price of a not so dark black. It's the preferred method for graphics with thin lines.

So is your «G» an image or a graphic? One could use both methods here but because it's a graphic letter alongside normal text (which is always printed black only) I would prefer the pdfTeX method. Both letters then look the same black.

So what was the problem? In my eyes it's better to define grey scale images as CMYK and select the colour method that fits the content best. Because the conversion from CMYK to grey scale is a function you still get the correct values on a b/w printer. But the opposite way round you get multiple solutions.

Assume you want to follow my suggestion to use black only and the image is already there: How to convert it correctly? In Photoshop, go to Colour Settings (Shift+Ctrl+K), click Custom CMYK, and along the values you get from your printshop selegt GCR and Maximum black generation. enter image description here
Then, convert your grey scale image to your custom CMYK profile.

PS: You show in the question a screenshot from Acrobat' print preview. But the most important setting is cropped: The simulation profile. Otherwise you would have seen that with UCR/XeTeX the exact values vary depending on the printing condition you select.

  • Thanks for your answer. I’m aware that Greyscakl can be printed with CMYK, but as long as I place an image using only the K Chanel I don’t want a software to automatically convert to all four CMYK channels … – Tobi Apr 20 '20 at 10:40
  • Neither XeLaTeX nor pdfTeX did convert the image. Proof: Export the image in Acrobat Pro and you get a greyscale jpg with both engines. If you do not want to use a CMYK image select a grey OutputIntent. – tanGIS Apr 20 '20 at 16:10
  • Sorry for the delayed reply. Thanks for the clarification! :-) – Tobi Apr 30 '20 at 14:01

I had grayscale file with embedded color profile "Dot Gain 20%". Removing this color profile in Photoshop solved the problem (partly).

Other options you have:

  • remove color profile by convert original.jpg +profile "*" clean.jpg
  • make your final pdf grayscale:

    gs -o path/to/output.pdf  \
       -sDEVICE=pdfwrite \
       -dPDFSETTINGS=/prepress \
       -sColorConversionStrategy=Gray \
       -sColorConversionStrategyForImages=Gray \
       -sProcessColorModel=DeviceGray \
       -dCompatibilityLevel=1.4 \

Update: I do not know why, but grayscale photo after removing "Dot Gain 20%" profile becomes darker in PDF. So one more option is:

  • convert your image to pdf via Photoshop "Save as...", keeping the "Dot Gain 20%" profile, and use \includegrahics{my-grayscale-image.pdf} in your TeX file. This will increase your file size a little, but it will give a better result.

Update 2: If you take a look at the code of your PDF files, you will see line /ColorSpace /DeviceGray in the ones generated by pdfLaTeX and luaTeX, and /ColorSpace 8 0 R in the one generated by XeLaTeX.

So, basing on this answer and especially this code, shown in the comment, you can use:


     \special{pdf: put @thispage <</Group << /S /Transparency /I true /CS /DeviceGray>> >>}%

This will make the monochrome PDF for you with the colors you wanted: 100% black and 58% gray.

  • Hi, I fixed the link. It may works to delete the profile but the profile is there on purpose (and important for professional printing) deleting it is like dumping an important information … so this doesn’t solve the problem … – Tobi Jul 24 '17 at 8:20
  • Just saw you update: The color change (darkening) happens because the profile tells how to interpret the Colors in the image and if it’s missing the viewer has to assume just some profile resulting in false colors. However converting the image to a PDF might be a workaround. – Tobi Jul 24 '17 at 8:22
  • I did not test the Ghostscript option, don't know how the color behaves in that case. – pantlmn Jul 25 '17 at 11:21
  • Ok … but making the final PDF grayscale doesn’t help in my case either, because I also have CMYK coloured images in the document … – Tobi Jul 26 '17 at 11:41
  • Edited my answer once again, added option /DeviceGray – pantlmn Jul 29 '17 at 7:06

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.