7

The xcolors package mentions three color options in its package documentation at http://mirrors.ctan.org/macros/latex/contrib/xcolor/xcolor.pdf. They are dvipsnames, svgnames, and x11names.

I normally use the dvipsnames option like this:

\usepackage[dvipsnames]{xcolor}

I want to know whether it matters which one of these three options I choose. Is there any obviously preferred option used by most of the LaTeX community or does it just boil down to one's personal preferences?

In other words, to keep this question objective, I want to know if there are any specific pros and cons for each option that we need to be aware of before we decide which option to use with the xcolor package?

1
  • 2
    They are simply different sets of colors, I use the one(s) which contains the colors I want to use by looking at the list. Aug 5, 2019 at 16:42

1 Answer 1

10

One difference is that the colours with dvipsnames are defined in CMYK, but svgnames and x11names are defined in RGB. So you might choose dvipsnames if your final output is intended for offset or digital print.

This difference leads to a potential pitfall to be aware of when using the dvipsnames option of xcolor.

By default pgf shadings are output in RGB, so unless you explicitly ask for CMYK shadings, you won't get the colours you want in shadings. This is especially noticeable when you have the solid colours at either end of the shading, which can sometimes happen in beamer templates.

Consider this MWE demonstrating the issue. Both Blue and LimeGreen are defined by dvipsnames and are in CMYK. The top shading has the wrong colours because it's in RGB. This is what you get unless you explicitly change the colour model to CMYK (e.g., by using \usepackage[cmyk,dvipsnames]{xcolor}).

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\begin{document}
\section*{Natural Colour model}

\begin{tikzpicture}
  \fill[Blue] (0,0) rectangle (1,1);
  \shade[left color=Blue, right color=LimeGreen] (1.25,0) rectangle (3.75,1);
  \fill[LimeGreen] (4,0) rectangle (5,1);
\end{tikzpicture}

\section*{CMYK colour model}

\selectcolormodel{cmyk}
\begin{tikzpicture}
  \fill[Blue] (0,0) rectangle (1,1);
  \shade[left color=Blue, right color=LimeGreen] (1.25,0) rectangle (3.75,1);
  \fill[LimeGreen] (4,0) rectangle (5,1);
\end{tikzpicture}
\end{document}

MWE output

2
  • Can changing the color model to CMYK affect other things or is it safe to always use it with dvipsnames? Jan 19, 2020 at 12:29
  • 1
    @JoãoBravo, there shouldn't be anything major. Depending on your printer and printer driver, you can sometimes end up with your blacks coming out dark grey. Colours defined in RGB will look different (e.g., compare the colour green), but your PDF viewer will give a reasonable approximation of what they will look like when printed. Jan 20, 2020 at 4:21

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.