这是从一个站点挪来的代码,效果如下;
\documentclass{ctexart}
\usepackage{tcolorbox}
\tcbuselibrary{breakable,theorems,skins}
%\tcbuselibrary{breakable} %%を読み込んでいます。
\newcounter{reidaibangou} %%カウンタの定義
\newtcolorbox{reidai}[1][]{enhanced,boxrule=0.5mm,
top=2pt,left=44pt,right=4pt,bottom=2pt,arc=0mm,
colframe=blue!30!gray,
boxrule=1pt,
underlay={
\node[inner sep=1pt,blue!50!black,fill=blue!10!white]at ([xshift=22pt,yshift=-9pt]interior.north west) {\stepcounter{reidaibangou}\bfseries\sffamily 例題\thereidaibangou};},
segmentation code={%
\draw[dashed] (segmentation.west)--(segmentation.east);
\node[inner sep=1pt,blue!50!black,fill=blue!10!white] at ([xshift=22pt,yshift=-8pt]segmentation.south west) {\bfseries\sffamily 解};},
before upper={\setlength{\parindent}{1\ccwd}},
before lower={\setlength{\parindent}{1\ccwd}},
}
%%%%%ここまでがreidai環境の定義。例えば本文中に以下のように記述してみよう。
\begin{document}
\begin{reidai}
次の問題に答えなさい。
\begin{enumerate}
\item 8人を2つの組に分ける方法は何通りあるか。
\item 6人を3つの部屋A,B,Cに入れる方法は何通りあるか。 {ただし}各部屋に少なくとも1人は入るものとする。
\end{enumerate}
\tcblower
区別があるかどうかを正しく考えます。
\begin{enumerate}
\item なんだかんだで127通り
\item なんだかんだで540通り
\end{enumerate}
\end{reidai}
\end{document}
地址:https://marukunalufd0123.hatenablog.com/entry/2019/03/15/071717
问 如何用tcolorbox实现复杂样式