前几日仿照你的做法封装的\ex
命令,下面是一个可能的mwe和效果图.
\documentclass[b5paper, openany]{ctexbook}
\usepackage[left=12mm,right=12mm,top=20mm,bottom=30mm]{geometry}
\usepackage{xcolor}
\usepackage{lipsum,zhlipsum}
\usepackage[many]{tcolorbox}
\NewTotalTColorBox{\ex}{O{问题} o m}{
enhanced,breakable,
colframe = cyan!75!black,
fonttitle = \bfseries,
skin=bicolor,
colbacktitle=cyan!85!black,
colbacklower=cyan!85!black,
sharp corners=all,
boxed title style = {sharp corners},
attach boxed title to top left={xshift=0mm,yshift=0mm},
title=#1,
IfNoValueF={#2}{%
space to upper,
halign lower=flush right,
bottom=1mm,
height=2.8cm,
collower=red,
}
}{
#3
\IfNoValueF{#2}{%
\tcblower
#2
}
}
\begin{document}
\section{测试}
\ex{
\lipsum[1]
}
\ex[一个问题]{
\zhlipsum[2]
}
\ex[另一个问题][来源:\LaTeX\ Studio(2024)]{
\zhlipsum[8-10]
}
\end{document}
问 完善自定义命令增加标题