0

In my preamble:

\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}

In order to have the box span the width of the page I have to put the myBox environment within a fullwidth environment. But that produces the following error messages

! 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}

Clearly the fullwidth environment doesn't survive a page break.

I wonder if it's possible to tell tcolorbox to use fullwidth or, alternatively to treat it as a float that doesn't force a new page after pushing out all the content that precedes it.

1
  • Interesting! fullwidth is implemented using adjustwidth, which is implemented using list, \leftmargin and \rightmargin. However, with twoside you need to keep switching the two. Commented Sep 24, 2020 at 1:01

1 Answer 1

1

The problem is solved by using the float option of 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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .