\documentclass{ctexart}
\usepackage[most]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{calc}
\newtcolorbox{mybox}{
enhanced,
colbacktitle = white,
attach boxed title to top center={ yshift = 0pt},
title = 练习,
coltitle = cyan,
boxrule = 2pt,
frame code={
% 以下代码可实现取中点1
\fill[color = green] (title.north west)--(title.north east)--([xshift = 0.3cm,yshift =-1pt]$(title.north east)!0.5!(title.south east)$)
--(title.south east)--(title.south west)--([xshift = -0.3cm,yshift = -1pt]$(title.south west)!0.5!(title.north west)$)--cycle;
}
}
\begin{document}
\begin{mybox}
1.分别写出“两个三角形全等”和“两个三角形相似”的几个充要条件。\par
\end{mybox}
\end{document}
第一个,用 boxed title style
,见文档 177 页:
\documentclass{ctexart}
\usepackage[most]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{calc}
\newtcolorbox{mybox}{
enhanced,
attach boxed title to top center={ yshift = -\tcboxedtitleheight/2, yshifttext=-2mm},
colbacktitle = white,coltitle=black,title = 练习,
boxrule = 2pt,
boxed title style={
frame code={
% 以下代码可实现取中点1
\fill[color = green] (frame.north west)--(frame.north east)
--([xshift = 0.3cm,yshift =-1pt]$(frame.north east)!0.5!(frame.south east)$)
--(frame.south east)--(frame.south west)
--([xshift = -0.3cm,yshift = -1pt]$(frame.south west)!0.5!(frame.north west)$)
--cycle;
}
}
}
\begin{document}
\begin{mybox}
1.分别写出“两个三角形全等”和“两个三角形相似”的几个充要条件。\par
\end{mybox}
\end{document}
第二个,使用 title code
时,标题还未构建,title node 不可用。
谢谢大佬