我正在尝试使用包创建一个颜色框tcolorbox
。
源代码如下-
\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}
我遇到的错误是:
! 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.
答案1
阴影效果需要 TikZshadings
库。tcolorbox
默认情况下似乎没有加载该库。因此您需要自行加载。
\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}
请注意,您需要将\usetikzlibrary
调用放在 之后\tcbuselibrary{skins}
,因为只有该库才会真正加载 TikZ(否则只会pgf
加载 )。另请注意,并非所有 PDF 查看器都能正确呈现阴影。