5

I am trying to create a color box using tcolorbox package.
source code is like this-

\documentclass[11pt]{article}
\usepackage[top=.5in, bottom=.5in, left=1in, right=1in]{geometry}
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\begin{document}

\tcbset{skin=enhanced,fonttitle=\bfseries,
frame style={upper left=blue,upper right=red,lower left=yellow,lower right=green},
interior style={white,opacity=0.5},
segmentation style={black,solid,opacity=0.2,line width=1pt}}

\begin{tcolorbox}[title=Nice box in rainbow colors]

With the ’enhanced’ skin, it is quite easy to produce fancy looking effects.

\tcblower
Note that this is still a \texttt{tcolorbox}.

\end{tcolorbox}

\end{document}

The error I am having is:

! Package pgfkeys Error: I do not know the key '/tikz/upper left' and I m going to ignore it.
! Package pgfkeys Error: I do not know the key '/tikz/upper right' and I m going to ignore it.
! Package pgfkeys Error: I do not know the key '/tikz/lower left' and I m going to ignore it.
! Package pgfkeys Error: I do not know the key '/tikz/lower right' and I m going to ignore it.
0

1 Answer 1

7

The shading effect needs the TikZ shadings library. tcolorbox doesn't seem to load that by default. Hence you need to load it yourself.

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{shadings}

\tcbset{
    skin=enhanced,
    fonttitle=\bfseries,
    frame style={upper left=blue,upper right=red,lower left=yellow,lower right=green},
    interior style={white,opacity=0.5},
    segmentation style={black,solid,opacity=0.2,line width=1pt}
}

\begin{document}
\begin{tcolorbox}[title=Nice box in rainbow colors]
    With the ’enhanced’ skin, it is quite easy to produce fancy looking effects.
    \tcblower
    Note that this is still a \texttt{tcolorbox}.
\end{tcolorbox}
\end{document}

result

Note that you need to put the \usetikzlibrary call after \tcbuselibrary{skins}, because only that library actually loads TikZ (otherwise only pgf is loaded). Also note that not all PDF viewers render shadings correctly.

1
  • * Check that you have the last version of tcolorbox.sty in your computer; otherwise, download it at ctan.org/pkg/tcolorbox
    – SDrolet
    Apr 20, 2014 at 13:14

You must log in to answer this question.

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