TransWikia.com

where, how, and when to load xcolor options

TeX - LaTeX Asked on December 4, 2020

Here I load xcolor options (dvipsnames) at the very top, so all the xcolor friends don’t have to sweat it, but options are like politics at Thanksgiving: s*** hits the fan no matter what:

documentclass[10pt,usenames,dvipsnames]{beamer}
usepackage[dvipsnames]{xcolor}
usepackage{pgfpages}

Apologies, I tried to select the text in overleaf but when I let go of the mouse the selection disappears (it’s that been kind of day):

enter image description here

2 Answers

The document class beamer load (among others also) package xcolor, so you not need to load it again. If you do, as you show in your question, you get clash between xcolor options. So, in your case just remove second line (with xcolor) in the code:

documentclass[10pt,dvipsnames]{beamer}  
usepackage{pgfpages}
usepackage{tikz}

begin{document}
begin{frame}
    begin{tikzpicture}
      node[font=Huge, text=Cyan] {Hello!};
    end{tikzpicture}
end{frame}
end{document}

Please note, that the usenames option is obsolete according to documentation of the xcolor, so I omit this option in above MWE.

As stated in the @Skillmon comment: "If you don't want to specify global options (that's what options to the verb+documentclass+ are), you can also use PassOptionsToPackage{usenames,dvipsnames}{xcolor} before xcolor gets loaded, i.e.:"

PassOptionsToPackage{dvipsnames}{xcolor}
documentclass[10pt]{beamer}
usepackage{xcolor} % now option(s) doesn't clash,
                    % however you not need to load it again! 
usepackage{tikz}
usepackage{pgfpages}

begin{document}
begin{frame}
    begin{tikzpicture}
      node[font=Huge, text=Cyan] {Hello!};
    end{tikzpicture}
end{frame}
end{document}

In both cases, the result is the same:

enter image description here

Correct answer by Zarko on December 4, 2020

On page 20 of the manual for beamer, you find

enter image description here

documentclass[
  10pt,
  xcolor={usenames,dvipsnames},
]{beamer}

I recommend this way of typing long list of options to classes, so one has all of them in view and commenting/uncommenting them is easier.

Answered by egreg on December 4, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP