\documentclass{article}
\usepackage[UTF8]{ctex}
\usepackage[most]{tcolorbox}
\usetikzlibrary{patterns}
\usepackage{zhlipsum}
\begin{document}
\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}
}
}
},
ribbon/.style={
overlay app={
\path[
fill=blue!75!white,
draw=blue,
double=white!85!blue,
preaction={fill=blue!75!white},
line width=0.1mm,
double distance=0.2mm,
pattern=fivepointed stars,
pattern color=white!75!blue
]
([xshift=-1cm, yshift=-2cm]frame.north east)
-- ++(-1,1)
-- ++(-0.5,0)
-- ++(1.5,-1.5)
-- cycle;
}
}
}
\begin{tcolorbox}[frogbox, title=My title]
This is a \textbf{tcolorbox}.
\end{tcolorbox}
\begin{tcolorbox}[frogbox, ribbon, title=My title]
\zhlipsum[1-3]
\end{tcolorbox}
\end{document}
请教老师们,如何完全遮住文字?
改用finish
而不是overlay app
即可。
\documentclass{article}
\usepackage[UTF8]{ctex}
\usepackage[most]{tcolorbox}
\usetikzlibrary{patterns}
\usepackage{zhlipsum}
\begin{document}
\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}
}
}
},
ribbon/.style={
finish={
\path[
fill=blue!75!white,
draw=blue,
double=white!85!blue,
preaction={fill=blue!75!white},
line width=0.1mm,
double distance=0.2mm,
pattern=fivepointed stars,
pattern color=white!75!blue
]
([xshift=-0.2mm, yshift=-2.02cm]frame.north east)
-- ++(-2,2)
-- ++(-0.5,0)
-- ++(2.5,-2.5)
-- cycle;
}
}
}
\begin{tcolorbox}[frogbox, ribbon, title=My title]
\zhlipsum[1]
\end{tcolorbox}
\end{document}
谢谢老师,我一下子没留意,我的目的是想画图形完全挡住文本,如果文本在tcolorbox之前就可以,但文本在tcolorbox之后就不行,都是有透明度