我在使用这个练习环境时遇到了一个小问题
\documentclass{article}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\newtcbtheorem{exercice}{Exercice}%
{ % frame stuff
enhanced,frame empty,interior empty,
colframe=blue,
borderline west={1pt}{0pt}{green!25!blue},
left=0.2cm,
% title stuff
attach boxed title to top left={yshift=-2mm,xshift=-2mm},
coltitle=black,
fonttitle=\bfseries,
colbacktitle=white,
boxed title style={boxrule=.4pt,sharp corners}}{exercise}
\begin{document}
\begin{exercice}{title}{ex.mylabel}
\lipsum[1]
\end{exercice}
\end{document}
当空间不足时,它会占用另一页的空间
虽然我希望它从第一页开始,然后继续(如果还有文本)在另一页
答案1
您可以将breakable
选项添加到您的\newtcbtheorem
。但如果框跨页面拆分,仅这样做会导致框的行为有所不同。
Ulrike Fischer 的评论帮助我们解决了这个问题:替换frame empty, interior empty
为frame hidden, interior hidden
:
\documentclass{article}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\newtcbtheorem{exercice}{Exercice}%
{ % frame stuff
breakable,% <<< Here
enhanced,
% frame empty,interior empty, <<< Change this
frame hidden,interior hidden,% <<< By this
colframe=blue,
borderline west={1pt}{0pt}{green!25!blue},
left=0.2cm,
% title stuff
attach boxed title to top left={yshift=-2mm,xshift=-2mm},
coltitle=black,
fonttitle=\bfseries,
colbacktitle=white,
boxed title style={boxrule=.4pt,sharp corners}}{exercise}
\begin{document}
\lipsum[1-4]
\begin{exercice}{title}{ex.mylabel}
\lipsum[1]
\end{exercice}
\end{document}
但盒子坏了就不一样了,我真的不知道怎么修:/