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:
polyglossia
norxelatex
settings are needed heretcolorbox
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