8

I have three simple files which load colour-related packages although they don't attempt to use any fancy colours. These are file col.tex:

\documentclass{minimal}
\usepackage{color}
\begin{document}
ABC
\end{document}

file col-black.tex:

\documentclass{minimal}
\usepackage{color}
\begin{document}
\textcolor{black}{ABC}
\end{document}

and file xcol.tex:

\documentclass{minimal}
\usepackage{xcolor}
\begin{document}
ABC
\end{document}

I latex and then dvips (with dvips(k) 5.994) each of them, and I look at the postscripts. I was expecting to get "ABC" in black in all cases, as if I had not loaded any colour package at all. However, when visualizing the files with evince, this is not the case for file col.ps, I get the "ABC" in a very dark grey, but clearly not black. If I ps2pdf the postscripts the differences are even more clear using a large magnification in acroread.

If I diff the three postscript files, apart from three mentions in each of them to the dvi file names, a couple of lines show differences: in col.ps:

%%Page: 1 1
TeXDict begin 1 0 bop Black Black 166 83 a Fa(ABC)p Black
Black eop end
%%Trailer

in col-black.ps:

%%Page: 1 1
TeXDict begin 1 0 bop Black Black 0 TeXcolorgray 166
83 a Fa(ABC)p Black Black Black eop end
%%Trailer

and in xcol.ps:

%%Page: 1 1
TeXDict begin 1 0 bop 0 TeXcolorgray Black 0 TeXcolorgray
166 83 a Fa(ABC)p 0 TeXcolorgray 0 TeXcolorgray eop end
%%Trailer

Am I doing anything wrong? Is this the expected behaviour of the color package? If it is, is there any way to set the default color in the header?


The problem seems to be with the definition of Black. In all files it is defined as

 /Black{0 0 0 1 setcmykcolor}

If I change the definition in col.ps to

 /Black{0 setgray}

I get the proper black I expected.

5
  • You might want to specify which driver you are using when you load the color package: TeX itself doesn't do colour, I believe. Try texdoc grfguide to learn about the color package options; texdoc xcolor for the xcolor package.
    – jon
    Commented Nov 1, 2014 at 2:25
  • In both cases (color and xcolor) I don't specify any driver, and this loads the dvips one, which is the default in TeXLive.
    – jme52
    Commented Nov 1, 2014 at 3:12
  • This could be a pdf viewer issue. I am no PostScript expert, but the PS code 0 TeXcolorgray is another form of 0 setgray which means black.
    – user31729
    Commented Nov 1, 2014 at 4:03
  • The file which displays grey-ish fonts is the first one, col.ps. The files that use TeXcolorgray seem to deliver proper black.
    – jme52
    Commented Nov 1, 2014 at 4:44
  • 1
    This must be a viewer issue; 0 0 0 1 setcmykcolor means black. Commented Nov 1, 2014 at 7:55

2 Answers 2

2

The choice of default colour is not really in the control of the color package, it is handled in the def file for the back end in use (dvips here. I'm not sure why its cmyk black isn't as black as rgb but anyway you can force it to use rgb black as the default by setting the colour in the preamble, compare the effect with or without the commented line.

enter image description here

\documentclass{minimal}
\usepackage{color}
%\definecolor{black}{rgb}{0,0,0}\color{black}
\begin{document}

 \rule{2cm}{1cm}

 \textcolor[rgb]{0,0,0}{\rule{2cm}{1cm}}

 \textcolor[rgb]{0,0,0}{\rule{2cm}{1cm}}



\end{document}
10

Your documents use different color models (and colors given in different color models): rgb and cmyk. Default color is a cmyk black. And black form color or xcolor is a rgb black.

With xcolor, you may convert color from a model to another. Here is an example to defined a cmyk black form rgb black:

\usepackage{xcolor}
\colorlet{black cmyk}[cmyk]{black}

With xcolor, you may choose a global color model:

\usepackage[rgb]{xcolor}

Here is a complete example to show the differences with black, green and cyan. In this example, each row of a big square contains three small squares: the color from xcolor, the color from xcolor converted to cmyk model and the color form xcolor converted to rgb model. The first row uses the global model natural (no conversion), the second row uses the global model rgb and the third row uses the global model cmyk (note: black and green from xcolor are in rgb color model while cyan is in cmyk color model).

enter image description here

\documentclass{minimal}
\usepackage{xcolor}
\usepackage{graphicx}
\colorlet{black cmyk}[cmyk]{black}
\colorlet{black rgb}[rgb]{black}
\colorlet{green cmyk}[cmyk]{green}
\colorlet{green rgb}[rgb]{green}
\colorlet{cyan cmyk}[cmyk]{cyan}
\colorlet{cyan rgb}[rgb]{cyan}

\def\myrule{\rule[-5mm]{1cm}{1cm}}
\def\mytest{
\textcolor{black}{\myrule}%
\textcolor{black cmyk}{\myrule}%
\textcolor{black rgb}{\myrule}
\textcolor{green}{\myrule}%
\textcolor{green cmyk}{\myrule}%
\textcolor{green rgb}{\myrule}
\textcolor{cyan}{\myrule}%
\textcolor{cyan cmyk}{\myrule}%
\textcolor{cyan rgb}{\myrule}
}
\def\mytitle{
  \parbox{2.5cm}{Colors}
  \parbox{1cm}{\centering\rotatebox{90}{\texttt{black} (default)}}%
  \parbox{1cm}{\centering\rotatebox{90}{\texttt{black cmyk}}}%
  \parbox{1cm}{\centering\rotatebox{90}{\texttt{black rgb}}}
  \parbox{1cm}{\centering\rotatebox{90}{\texttt{green (default)}}}%
  \parbox{1cm}{\centering\rotatebox{90}{\texttt{green cmyk}}}%
  \parbox{1cm}{\centering\rotatebox{90}{\texttt{green rgb}}}
  \parbox{1cm}{\centering\rotatebox{90}{\texttt{cyan} (default)}}%
  \parbox{1cm}{\centering\rotatebox{90}{\texttt{cyan cmyk}}}%
  \parbox{1cm}{\centering\rotatebox{90}{\texttt{cyan rgb}}}
}
\begin{document}
\mytitle

\selectcolormodel{natural}
\parbox{2.5cm}{Model \texttt{natural}:} \mytest

\selectcolormodel{rgb}
\parbox{2.5cm}{Model \texttt{rgb}:} \mytest

\selectcolormodel{cmyk}
\parbox{2.5cm}{Model \texttt{cmyk}:} \mytest

\end{document}
3
  • However, I think that what I get is slightly different from what you describe in your first paragraph: the default is (a) rgb black if no colour-related package is loaded or if I load xcolor without any option, and (b) cmyk black if color is loaded. Is that right? If that's the case, shouldn't the color package documentation clearly warn about it?
    – jme52
    Commented Nov 1, 2014 at 18:08
  • 1
    @ripero Neither LaTeX nor the package color define a color model to use in a document. Only package xcolor provides a way to apply a global (or local) color model. You may try \tracingcolors=4 from xcolor to show the used colors. Commented Nov 1, 2014 at 23:17
  • @ripero ... You are right about default (black) colors with or without color or xcolor. Commented Nov 1, 2014 at 23:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .