我认为我的问题可能真的很基本,但是我查看了文档并无法弄清楚当标题太长时如何强制文本在 tcolorbox 标题内换行。
\documentclass[a4paper,11pt]{book}
\usepackage{lipsum}
\usepackage{amsmath,amssymb}
\usepackage[most]{tcolorbox}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{lmodern}
\tcbset{
thmbox/.style={
enhanced,
breakable,
sharp corners=all,
fonttitle=\bfseries\normalsize,
fontupper=\normalsize\itshape,
top=0mm,
bottom=0mm,
right=0mm,
colback=white,
colframe=white,
colbacktitle=white,
coltitle=black,
attach boxed title to top left,
boxed title style={empty, size=minimal, bottom=1.5mm},
overlay unbroken ={
\draw (title.south west)--(title.south east);
\draw ([xshift=3.5mm]frame.north west)|-%
(frame.south east)--(frame.north east);},
overlay first={
\draw (title.south west)--(title.south east);
\draw ([xshift=3.5mm]frame.north west)-- ([xshift=3.5mm]frame.south west);
\draw (frame.north east)--(frame.south east);},
overlay middle={
\draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);
\draw (frame.north east)--(frame.south east);},
overlay last={
\draw ([xshift=3.5mm]frame.north west)|-%
(frame.south east)--(frame.north east);},
},
}
\newtcbtheorem[number within=section]{questionbox}{Question}{thmbox}{qst}
\begin{document}
\begin{questionbox}{\lipsum[66]}{qst:1}
\lipsum[1]
\end{questionbox}
\end{document}
答案1
正如 Christian 所解释的那样,tcolorbox 标题没有被包装。它应该是一些单词,而不是完整的练习。但是,如果您想将问题和答案混合到同一个颜色框中,根据您的格式,可能的解决方案可能是使用短标题(或空标题),并将问题放在 tcolorbox 的上部,而解决方案放在下部。类似
\documentclass[a4paper,11pt]{book}
\usepackage{lipsum}
\usepackage{amsmath,amssymb}
\usepackage[most]{tcolorbox}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{lmodern}
\tcbset{
thmbox/.style={
enhanced,
breakable,
sharp corners=all,
fonttitle=\bfseries\normalsize,
fontupper=\normalsize,
fontlower=\normalsize\itshape,
before lower={\itshape Solution:\ },
top=0mm,
bottom=0mm,
right=0mm,
colback=white,
colframe=white,
colbacktitle=white,
coltitle=black,
attach boxed title to top left,
boxed title style={empty, size=minimal, bottom=1.5mm},
overlay unbroken ={
\draw (title.south west)--(title.south east);
\draw ([xshift=3.5mm]frame.north west)|-%
(frame.south east)--(frame.north east);},
overlay first={
\draw (title.south west)--(title.south east);
\draw ([xshift=3.5mm]frame.north west)-- ([xshift=3.5mm]frame.south west);
\draw (frame.north east)--(frame.south east);},
overlay middle={
\draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);
\draw (frame.north east)--(frame.south east);},
overlay last={
\draw ([xshift=3.5mm]frame.north west)|-%
(frame.south east)--(frame.north east);},
},
}
\newtcbtheorem[number within=section]{questionbox}{Question}{thmbox}{qst}
\begin{document}
\begin{questionbox}{A nice question}{qst:1}
\lipsum[1]
\tcblower
\lipsum[2]
\end{questionbox}
\end{document}