4

Defining exercises and using some macros with tcolorbox, I noted that, if I insert the macro including tcolorbox inside the exercise produced with tcolorbox too, the breakable option has not effect so the boxes doesn't break. How can I make this option effective for this case of "box-in-box" ?

I give an MWE, of my .tex file, where one can see that the boxes break, in the pages 1,2,3, and when the box refuses to break, in the page 4:

\documentclass{book}

\usepackage[most]{tcolorbox}
\tcbuselibrary{skins,breakable}

\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\setsansfont{Arial}
\setmonofont{Courier New}
\newfontfamily{\arabicfont}[Script=Arabic,Scale=1.5]{Traditional Arabic}

\usepackage{polyglossia}
\setdefaultlanguage{arabic}

\newcounter{example}[section]
\renewcommand{\theexample}{\arabic{example}}
\newcommand{\examplelabel}{%
{\bfseries\large
Ex.
\LR{\theexample}
}}

\newtcolorbox[use counter=example]{example}[1][]{enhanced jigsaw,breakable,
  colback=white, colframe=red, arc=0mm,
  rightrule=0mm, leftrule=0mm,toprule=0mm,
  top=1mm, bottom=1mm, left=0mm, right=0mm,
  colbacktitle=green, coltitle=black,
  title=#1,
  extrude right by=-5.5mm,
  before upper={\parshape 4
        0pt \dimexpr \hsize-7mm\relax
        0pt \dimexpr \hsize-7mm\relax
        0pt \dimexpr \hsize-7mm\relax
        0pt \hsize},
  code={\ifstrempty{#1}{}{%
    \tcbset{
      before upper={\parshape 3
        0pt \dimexpr \hsize-7mm\relax
        0pt \dimexpr \hsize-7mm\relax
        0pt \hsize},
    }}},
  underlay unbroken and first={%
  \node[fill=yellow, draw=red, line width=1.5pt, below right, minimum height=3em, text width=.8cm, align=center] at ([xshift=-.1mm]frame.north east) {\examplelabel};
  \draw [red,line width=.5mm]([yshift=.25mm]frame.north west)--+(\linewidth,0);
  },
  underlay unbroken and last={%
  \draw [red,line width=.5mm]([yshift=.25mm]frame.south west)--+(\linewidth,0);
  },
}

\tikzstyle{titlewhite} =
    [draw=black, thick, scale=.9, fill=white,% 
        line width=0.3pt, text=black, rectangle,
        font=\normalsize,
        left, minimum height=.5cm]

\newenvironment{blankbox}[2][]{%
\begin{tcolorbox}[enhanced jigsaw,breakable,
colback=white, colframe=white, arc=0mm,
  top=0mm, bottom=0mm, left=2mm, right=2mm,
colframe=black,
top=5mm,
%bottom=6mm,
enlarge top by=\baselineskip/2+1mm,
enlarge top at break by=0mm,pad at break=2mm,
fontupper=\normalsize,
overlay unbroken and first={%
\node[titlewhite]
at ([xshift=-1cm]frame.north east)
{\large \RL{#2}};},
before=\par\smallskip\centering,
coltitle=black, 
  fonttitle=\large,%%fontupper=\large,
rightrule=0mm, 
borderline east={0pt}{0pt}{white},
leftrule=0.2mm,toprule=0.2mm,bottomrule=0.2mm,
]}{%
\end{tcolorbox}}

\begin{document}
\noindent
\LR{
In this document, the text would be written in arabic, a right-to-left language
}

\begin{example}[\hspace*{2.5mm}\LR{A broken example}]
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
%%\vspace*{10cm}
\\
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\end{example}



\begin{blankbox}{\LR{A broken box}}
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
%%\vspace*{10cm}
\\
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\end{blankbox}

\begin{example}[\hspace*{2.5mm}\LR{A non-broken example}]
\vspace*{5mm}
\begin{blankbox}{Title}
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
%%\vspace*{10cm}
\\
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\ 
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\\
\LR{
An example artificially broken
}
\end{blankbox}
\end{example}


\end{document}

and it's compilation with xelatex:

enter image description here enter image description here enter image description here

enter image description here

  • 4
    Also, I have asked you multiple times at other occasions to remove those special font settings since most of us do not have such fonts installed. Neither polyglossia nor xelatex settings are needed here – user31729 Feb 25 '18 at 22:29
  • 3
    The manual of tcolorbox clearly states that nesting a breakable box in a breakable box will be automatically ignored, so the inner box won't be breakable any longer – user31729 Feb 25 '18 at 22:41
  • 1
    @ChristianHupfer That sounds like an answer, doesn't it? 'Can't be done' is perfectly legitimate, if true - indeed, the best answer possible. – cfr Feb 26 '18 at 0:43
  • @cfr: It's would be a very, very, very (repeat 100 times ;-)) disappointing answer, however... – user31729 Feb 26 '18 at 0:48
  • 2
    I agree with @cfr. I think that your comment is an answer for my problem, because it's useful for me, the author of the question, and it solves my problem, even if it seems to be a simple or disappointing answer, because repeated several times. It's the first time that I know this information, and your help is welcome for me. Many thanks – Faouzi Bellalouna Feb 26 '18 at 3:00
6

Citing the tcolorbox manual (page 365 of current version 4.15):

You can nest an unbreakable tcolorbox inside another tcolorbox, even inside a breakable one. But you cannot not nest a breakable box inside a breakable box. The /tcb/breakable key for a nested box is ignored automatically, i. e. inner boxes are always unbreakable.

After all, in the unlikely case you really want to have the nested box to be breakable, use /tcb/enforce breakable for the nested box. But, a breakable box inside a breakable box will usually give a mess.

So even if there is a enforce breakable option, this is not advisable. (I've tried on other occasions and the result is really messy)

Update 2019/02/15

The (most likely) wrong wording 'cannot not' is still in the text.

  • 1
    Is 'cannot not' the manual's mistake or a misquote? – cfr Feb 26 '18 at 1:35
  • Many thanks for your disponibility. I agree with @cfr another time that a synthesis of 'cannot not' ! is useful for the users of a package – Faouzi Bellalouna Feb 26 '18 at 6:01
  • Be nice to have it corrected if it is a misquote. – cfr Feb 26 '18 at 22:15
  • @cfr: I copied the text from the manual... did not catch this mistake in the manual – user31729 Feb 26 '18 at 22:17
  • It's a sic then, I guess. :-) – cfr Feb 26 '18 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.