0

How can I include an option in a latex document that selects between

\usepackage{xcolor}
\usepackage[dvipsnames]{xcolor}
\usepackage[svgnames]{xcolor}
\usepackage[x11names]{xcolor}

Perhaps I can put the capability in a style file.

4
  • 1
    Why select? Why not just \usepackage[dvipsnames,svgnames,x11names]{xcolor} and enjoy access to all named colors?
    – Mico
    Sep 21, 2022 at 23:29
  • Would any colour names conflict?
    – Veak
    Sep 21, 2022 at 23:46
  • See xcolor documentation. All three sets are listed. It seems some names from dvipsnames and svgnames overlap. I read somewhere dvipsnames is based on CMYK model while svgnames and x11names are based on RGB. I am not sure how important it is for PDFs for reading on screen but you should be careful if you create PDFs for printing, and probably which CMYK should be used.
    – Celdor
    Sep 22, 2022 at 0:08
  • What happens if I call a color with same name, one would override the other?
    – Veak
    Sep 22, 2022 at 0:30

2 Answers 2

2

Too long for a comment. From the xcolor documentation:

2.15.1 Name clashes between dvipsnames and svgnames Due to the fixed option processing order (which does not depend on the order how the options were specified in the \usepackage command), the svgnames colors will always overrule dvipsnames colors with identical names. This can lead to undesired results if both options are used together. For instance, Fuchsia yields enter image description here under the regime of dvipsnames and enter image description here with respect to svgnames. However, there is a simple trick — based on deferred color definition — that allows us to use colors from both sets in the desired way:

\usepackage[dvipsnames*,svgnames]{xcolor}
\definecolors{Fuchsia}

Now all colors from the SVG set are available (except Fuchsia) plus Fuchsia from the other set.

2
  • Understood. Because svgnames always overrule dvipsnames you can defer Fuchsia from dvipsnames, which will then be made to overrule svgnames with the command \definecolors{Fuchsia}.
    – Veak
    Sep 22, 2022 at 1:13
  • Seems that the only overlap in between dvipsnames and svgnames.
    – Veak
    Sep 22, 2022 at 1:29
1

There is no need to select if one uses

\usepackage[dvipsnames,svgnames,x11names]{xcolor}

One can also defer the colour names from dvipsnames so they will not be overruled by the svgnames set.

\usepackage[dvipsnames*,svgnames,x11names]{xcolor}
\definecolors{Fuchsia}

You must log in to answer this question.

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