![在 tufte-book.cls 中,breakable 选项与将 tcolorbox 置于全宽环境中不兼容](https://linux22.com/image/421287/%E5%9C%A8%20tufte-book.cls%20%E4%B8%AD%EF%BC%8Cbreakable%20%E9%80%89%E9%A1%B9%E4%B8%8E%E5%B0%86%20tcolorbox%20%E7%BD%AE%E4%BA%8E%E5%85%A8%E5%AE%BD%E7%8E%AF%E5%A2%83%E4%B8%AD%E4%B8%8D%E5%85%BC%E5%AE%B9.png)
在我的序言中:
\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}
为了让框跨越页面的宽度,我必须将环境放在环境myBox
中fullwidth
。但这会产生以下错误消息
! 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}