可破碎的盒子,带有 tcolorbox 的可破碎盒子

可破碎的盒子,带有 tcolorbox 的可破碎盒子

定义练习并使用一些宏时tcolorbox,我注意到,如果我将宏插入到tcolorbox用 生成的练习中tcolorbox,则该breakable选项不起作用,因此框不会损坏。如何使此选项对这种“框中框”的情况有效?

我给出了我的文件的 MWE .tex,其中可以看到第 1、2、3 页中的盒子破损了,而第 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}

它是用 xelatex 编译的:

在此处输入图片描述 在此处输入图片描述 在此处输入图片描述

在此处输入图片描述

答案1

引用tcolorbox手册(当前版本 4.15 第 365 页):

您可以将一个不可破坏的 tcolorbox 嵌套在另一个 tcolorbox 中,甚至可以嵌套在可破坏的 tcolorbox 中。但您不能将可破坏的框嵌套在可破坏的框中。嵌套框的 /tcb/breakable 键会自动忽略,即内部框始终是不可破坏的。

毕竟,在极少数情况下,您确实希望嵌套框可破坏,请对嵌套框使用 /tcb/enforce breakable。但是,可破坏框套在可破坏框中通常会造成混乱。

所以即使有enforce breakable选择,这也是不可取的。(我在其他场合也尝试过,结果真的很混乱)

更新 2019/02/15

文中仍然保留了(最有可能的)错误措辞“不能不”。

相关内容