2

What is the right way of using colors in a document ought for printing?

I am always simply using the xcolor package. Consider for example

\documentclass[margin = 12mm]{standalone}

\usepackage{xcolor}
\definecolor{foo}{rgb}{.4, .8, .2}

\begin{document}
Some \textcolor{foo}{example} text.
\color{red}\raisebox{.1em}{\rule{.3em}{.3em}}
\end{document}

green-ish colored text closed with a red square

Recently I came across a Reddit post (https://www.reddit.com/r/LaTeX/comments/d1tw6c/resource_for_best_packages_to_use_or_to_avoid/eztwtms), in which user u/0xe4524ffe comments:

Avoid color and xcolor packages, they mess up cmyk colors, make text printed with color ink instead of just black(they put insane amount of repeated "0 0 0 rg" instead of one "0 g" in pdf stream).

My local xcolor.sty (2016/05/11 v2.12) ends with

1456 ...
1457 \color{black}
1458 \endinput

And the color black is according to

\extractcolorspecs{black}{\model}{\black}\black

defined as a simple gray colorspace 0.

As there is no real solution given in the Reddit post on how to correctly use color and xcolor evaluates black (so everything with no color set) to 0, my question is

Is this answer still up-to-date and if so, how does one use color correctly?

3

It all depends on the color model you want to use. The default is rgb, so black is 0 0 0. You can load the package with the option cmyk and everything will be defined in cmyk. Or redefine colors in another model, for example:

\pdfcompresslevel=0
\documentclass{article}
\usepackage{xcolor}
\definecolor{black}{gray}{0}
\begin{document}    
\textcolor{black}{foo}

\definecolor{black}{rgb}{0,0,0}
\textcolor{black}{foo}

\definecolor{black}{cmyk}{0,0,0,1}
\textcolor{black}{foo}

\end{document}

the PDF then looks like:

stream
0 g 0 G
0 g 0 G
0 g 0 G
0 g 0 G
BT
/F8 9.9626 Tf 148.712 657.235 Td [(fo)-28(o)]TJ
0 g 0 G
0 0 0 rg 0 0 0 RG
 0 -11.955 Td [(fo)-28(o)]TJ
0 g 0 G
0 0 0 1 k 0 0 0 1 K
 0 -11.955 Td [(fo)-28(o)]TJ
0 g 0 G
0 g 0 G
 154.421 -543.96 Td [(1)]TJ
0 g 0 G
ET

endstream

you can also define the model for a single use of \textcolor e.g.:

\textcolor[gray]{0}{foo}

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.