![tcolorbox 覆盖应用无法运行](https://linux22.com/image/291617/tcolorbox%20%E8%A6%86%E7%9B%96%E5%BA%94%E7%94%A8%E6%97%A0%E6%B3%95%E8%BF%90%E8%A1%8C.png)
我正在尝试构建这个取自 tcolorbox 手册第 270 页的 mwe(我对其进行了一些简化):
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\tcbset{frogbox/.style={enhanced,colback=green!10,colframe=green!65!black,
enlarge top by=5.5mm,overlay={\foreach \x in {2cm,3.5cm} {
\begin{scope}[shift={([xshift=\x]frame.north west)}]
\path[draw=green!65!black,fill=green!10,line width=1mm] (0,0) arc (0:180:5mm);
\path[fill=black] (-0.2,0) arc (0:180:1mm);
\end{scope}}}]}}
\tcbset{app/.style={overlay app={%
\draw(frame.north)--(frame.south)}}}
\begin{document}
\begin{tcolorbox}[frogbox,title=My title]
This is a \textbf{tcolorbox}.
\end{tcolorbox}
\begin{tcolorbox}[frogbox,app,title=My title]
This is a \textbf{tcolorbox}.\par
Here, we apply a second overlay.
\end{tcolorbox}
\end{document}
构建失败并出现以下错误:
!软件包 pgfkeys 错误:我不知道您传递了“\draw (frame.north)--(frame.south)”的键“/tcb/overlay app”,我将忽略它。也许您拼错了。
我正在使用 TL14 预测试,所有内容都是最新的。这是某个地方的错误吗?
答案1
为了能够使用... app
或... pre
系列键,您需要加载hooks
库:
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins,hooks}
\tcbset{
frogbox/.style={
enhanced,
colback=green!10,
colframe=green!65!black,
enlarge top by=5.5mm,
overlay={
\foreach \x in {2cm,3.5cm} {
\begin{scope}[shift={([xshift=\x]frame.north west)}]
\path[draw=green!65!black,fill=green!10,line width=1mm] (0,0) arc (0:180:5mm);
\path[fill=black] (-0.2,0) arc (0:180:1mm);
\end{scope}
}
}
}
}
\tcbset{
app/.style={
overlay app={%
\draw(frame.north)--(frame.south);
}
}
}
\begin{document}
\begin{tcolorbox}[frogbox,title=My title]
This is a \textbf{tcolorbox}.
\end{tcolorbox}
\begin{tcolorbox}[frogbox,app,title=My title]
This is a \textbf{tcolorbox}.\par
Here, we apply a second overlay.
\end{tcolorbox}
\end{document}