Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.
share|improve this question
add comment

1 Answer 1

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.

share|improve this answer
    
* Check that you have the last version of tcolorbox.sty in your computer; otherwise, download it at ctan.org/pkg/tcolorbox –  SDrolet Apr 20 at 13:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.