在 tufte-book.cls 中,breakable 选项与将 tcolorbox 置于全宽环境中不兼容

在 tufte-book.cls 中,breakable 选项与将 tcolorbox 置于全宽环境中不兼容

在我的序言中:

\documentclass[twoside,nobib,leqno,ls]{tufte-book}
...
\usepackage[most,breakable]{tcolorbox}
\AtBeginDocument{\tcbset{after={\par\noindent}}}
\newcounter{myBox}
\newtcolorbox[use counter = myBox, number within = chapter]{myBox}[2][]{%
  boxrule = 0.5pt, breakable, colback = gray!5, colbacktitle = gray!10, coltitle = black,
  fonttitle = \sffamily, label type = myBox, sharp corners = all,
  title = Box~\thetcbcounter\secsp\textcolor{gray!80}{|}\secsp #2,#1}

为了让框跨越页面的宽度,我必须将环境放在环境myBoxfullwidth。但这会产生以下错误消息

! Extra \else.
<argument> ...t =\tcb@split@USL \fi \fi \fi \else 
                                                  \tcb@split@upper@box \ifdi...
l.1092 \end{fullwidth}
                      
I'm ignoring this; it doesn't match any \if.

! Argument of \tikzexternal@laTeX@collect@until@end@tikzpicture has an extra }.
<inserted text> 
                \par 
l.1092 \end{fullwidth}
                      
I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.

Runaway argument?
[]\tcb@tikz@begin@hook \tcb@bbdraw \tcb@apply@graph@patches \tcb@extensions@pre
frame \ETC.
! Paragraph ended before \tikzexternal@laTeX@collect@until@end@tikzpicture was 
complete.
<to be read again> 
                   \par 
l.1092 \end{fullwidth}
                      
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.

! Extra }, or forgotten \endgroup.
<recently read> }
                 
l.1092 \end{fullwidth}

显然,fullwidth环境无法经受住分页符的考验。

我想知道是否可以告诉tcolorbox使用fullwidth,或者将其视为浮点数,在推出它之前的所有内容后不会强制出现新页面。

答案1

float该问题可以通过使用以下选项解决tcolorbox

\newtcolorbox[use counter = myBox, number within = chapter]{myBox}[2][]{%
  boxrule = 0.5pt, breakable, colback = gray!5, colbacktitle = gray!10,
coltitle = black, floatplacement = t, float, fonttitle = \sffamily,
label type = myBox, sharp corners = all, title = Box~\thetcbcounter\secsp\textcolor{gray!80}{|}\secsp #2,#1}

相关内容