tcolorbox incompatibe with color package?
xcolor
is an enhanced version of color
but the real trick here is simply to load it first:
\documentclass{article}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tcolorbox}
\usepackage{lipsum}
\begin{document}
\begin{tcolorbox}[colback=green!5,colframe=green!40!black,title=A nice heading]
\lipsum[2]
\end{tcolorbox}
\end{document}
tcolorbox
loads pgf
which loads xcolor
without options. If you want to pass some options to xcolor
(which completely integrates color
functionality) you can use cfr solution \usepackage[]{xcolor}
with specific options before loading tcolorbox
, but you also have two more options.
The first one would be to use \PassOptionsToPackage{usenames,dvipsnames}{xcolor}
which passes options usenames
and dvipsnames
whenever xcolor
is loaded.
\PassOptionsToPackage{usenames,dvipsnames}{xcolor}
\documentclass{article}
\usepackage{tcolorbox}
\usepackage{lipsum}
\begin{document}
\begin{tcolorbox}[colback=JungleGreen!5, colframe=JungleGreen!40!black, title=A nice heading]
\lipsum[2]
\end{tcolorbox}
\end{document}
And a second one consists in passing these options through \documentclass
because from
page 17 in LaTeX Companion, 2ed:
All options to
\documentclass
(both declared and global ones) are automatically passed as class options to all\usepackage
declarations. Thus, if a package file loaded with a\usepackage
declaration recognizes (i.e. declares) some of the class options, it can take appropriate actions. If not, the class options will be ignores while processing that package.
As a simple test, I've changed green
to JungleGreen
(in dvipsnames
list) in your example and tried with
\documentclass[dvipsnames]{article} %<--- usenames is an obsolete option. deleted.
\usepackage{tcolorbox}
\usepackage{lipsum}
\begin{document}
\begin{tcolorbox}[colback=JungleGreen!5, colframe=JungleGreen!40!black, title=A nice heading]
\lipsum[2]
\end{tcolorbox}
\end{document}
which works without problems: