1

I want to find a method for breaking boxes of my environments of examples (in arabic, with polyglossia.. see ECM below) I saw that mdframed do something like this, but I'm using my own package "myboiboites" induced from boiboites, for arabization. I post the file and the package... in arabic for the file... you can see that it has 2 very "poor pages" because the box-example refuse to write in a half-page...

\documentclass[14pt,a4paper]{extbook}
%\usepackage{extsizes}




\usepackage[dvips]{graphicx}
\usepackage{boxedminipage}
\usepackage{slashbox} 


\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{framed}

\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{enumitem}

\usepackage{minitoc} 

\usepackage{rotating}

\usepackage{fmultico}
\setlength{\columnseprule}{0.1pt}

\usepackage{fancyhdr}
\pagestyle{fancy}

\usepackage{pdflscape}

\usepackage{myboiboites}


\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}


\newfontfamily\arabicfont[Script=Arabic, AutoFakeSlant=-0.02]{Amiri}







\usepackage{minitoc} 

\newboxedtheorem[boxcolor=gray!20, background=white, titlebackground=white,titleboxcolor = gray]{example}{مثال}{example}
\newenvironment{solution}{\begin{otherlanguage}{arabic}{\bf\textarabic{الحل \hspace{0.5em}}}\end{otherlanguage}\hspace{-0.7em}}{}




\begin{document}
\begin{example}[مبرهنة كثيرات الحدود]
\rm
كم هناك من معامل في تحليل كثيرات الحدود ل 
 $(x_{1} +
x_{2} + \cdots + x_{r})^{n}$؟
\end{example}
\begin{solution}
\[
(x_{1} + x_{2} + \cdots + x_{r})^{n} = \sum \left(\begin{array}{c}n\\
n_{1}, \ldots, n_{r}
\end{array}\right) x_{1}^{n_{1}} \cdots x_{r}^{n_{r}}
\]
حيث هذا الجمع هو على كل القيم الغير سالبة 
 $(n_{1}, \ldots, n_{r})$ 
 التي تحقق 
  $n_{1} + \cdots + n_{r} = n$. 
  وإذا، حسب النظرية~$6.2$،
   هناك 
    $\left(\begin{array}{c}n + r - 1\\
r - 1
\end{array}\right)$ 
معامل كهذا.
\hfill $\blacksquare$
\end{solution}


\begin{example}
\rm
لنعتبر مرة أخرى المثال ، 
أين لنا 
 $n$ 
 عنصر، 
 منها 
  $m$ 
 معيبة  
  (و لا يمكن تمييزها)
   و ال 
    $n - m$ 
    المتبقية 
     (و دائما لا يمكن تمييزها)
     غير معيبة.
 و نريد إيجاد عدد الترتيبات الخطية لهذه العناصر، حيث ليس هناك عنصران معيبان متتاليين. 
لإيجاد  عدد الترتيبات، تصور أن العناصر المعيبة مصففة على خط ما و أنه يجب وضع العناصر الغير معيبة في مواضع ما. لنرمز ب       
$x_{1}$ 
عدد العناصر الغير معيبة على يسار المعيب الأول، 
 $x_{2}$ 
 عدد العناصر الغير معيبة بين الأول و الثاني، و هكذا. 
 أي أنه لنا 
\[
x_{1}\ 0\ x_{2}\ 0 \cdots x_{m}\ 0\ x_{m + 1}
\]
الآن، سيكون على الأقل عنصر غير معيب بين كل زوج من العناصر المعيبة طالما 
 $x_{i} > 0$، $i = 2, \ldots, m$. 
و إذا، عدد المنتجات المحققة لهذه الشروط هو عدد المتجهات  
$x_{1}, \ldots, x_{m + 1}$ 
التي تحقق المعادلة
\[
x_{1} + \cdots + x_{m + 1} = n - m \quad x_{1} \geq 0,\; x_{m + 1}
\geq 0, \;x_{i} > 0, \; i = 2, \ldots,~m
\]
%\hfill$\blacksquare$
\noindent 
لكن، بوضع 
 $y_{1} = x_{1} + 1$، $y_{i} = x_{i}$، $i = 2,
\ldots, m$، $y_{m + 1} = x_{m + 1} + 1$، 
 نرى أن هذا العدد  يساوي عدد المتجهات بإحداثيات موجبة
 $(y_{1}, \ldots, y_{m + 1})$
التي تحقق المعادلة
\[
y_{1} + y_{2} + \cdots + y_{m + 1} = n - m +~2
\]

و ذاك، حسب النظرية...،
 هناك 
  $\left(\begin{array}{c}n - m + 1\\
m
\end{array}\right)$ 
منتجات كهذه، بتوافق مع نتيجة المثال. 

افترض الأن أننا نهتم بعدد المنتجات حيث  أن  هناك على الأقل عنصرين سليمين بين كل زوج من العناصر المعيبة. بنفس المنطق السابق، سيساوي هذا العدد عدد المتجهات المحققة للمعادلة 
\[
x_{1} + \cdots + x_{m + 1} = n - m \quad x_{1} \geq 0, \; x_{m + 1}
\geq 0, \; x_{i} \geq 2, \; i = 2, \ldots,~m
\]
بوضع 
 $y_{1} = x_{1} + 1$, $y_{i} = x_{i} - 1$, $i = 2, \ldots,
m$, $y_{m+1} = x_{m+1} + 1$, 
نرى أن هذا العدد يساوي عدد الحلول الموجبة للمعادلة
\[
y_{1} + \cdots + y_{m + 1} = n - 2m +~3
\]
و إذا.....،
 هناك
  $\left(\begin{array}{c}n - 2m + 2\\
m
\end{array}\right)$
 منتجات كهذه. 
\hfill$\blacksquare$
\end{example}
 \end{document}

myboiboites.sty

\RequirePackage{xkeyval} \RequirePackage{tikz}
\RequirePackage{amssymb}

\define@key{boxedtheorem}{titlecolor}{\def\titlecolor{#1}}
\define@key{boxedtheorem}{titlebackground}{\def\titlebackground{#1}}
\define@key{boxedtheorem}{background}{\def\background{#1}}
\define@key{boxedtheorem}{titleboxcolor}{\def\titleboxcolor{#1}}
\define@key{boxedtheorem}{boxcolor}{\def\boxcolor{#1}}
\define@key{boxedtheorem}{thcounter}{\def\thcounter{#1}}
\define@key{boxedtheorem}{size}{\def\size{#1}}
\presetkeys{boxedtheorem}{titlecolor = black, titlebackground = white, background = white, 
                         titleboxcolor = black, boxcolor = black, thcounter=, size = .98\textwidth}{}

\newcommand{\couleurs}[1][]{
    \setkeys{boxedtheorem}{#1}
    \tikzstyle{fancytitle} =[draw=\titleboxcolor,  fill=\titlebackground,
                            text= \titlecolor]
    \tikzstyle{mybox} = [draw=\boxcolor, fill=\background, very thick,line width=0.1pt,
                        rectangle,  inner sep=10pt, inner ysep=20pt]
}



\newsavebox{\boiboite}
\newcommand{\titre}{Titre}
\newenvironment{boite}[2][]
    {
    \renewcommand{\titre}{#2}
    \couleurs[#1]
    \begin{lrbox}{\boiboite}
     \begin{minipage}[!h]{\size}
    }
    {
     \end{minipage}
    \end{lrbox}
    \begin{center}
    \begin{tikzpicture}
    \node [mybox] (box){\usebox{\boiboite}};
    \node[fancytitle, left=10pt] at (box.north east) {\titre};
    \end{tikzpicture}
    \end{center}
    }




\newcommand{\newboxedtheorem}[4][]{
    \couleurs[#1]
    \@ifnotempty{#4}{
      \@ifundefined{the#4}{\@ifundefined{\thcounter}{\newcounter{#4}}{
      \newcounter{#4}[\thcounter ] } } { }
    }
    \newenvironment{#2}[1][]{
    \@ifnotempty{#4}{\refstepcounter{#4}}
    \begin{boite}[#1]{\RL{\textbf{#3\@ifnotempty{#4}{ \csname the#4\endcsname.}}\@ifnotempty{##1}{
    ##1}}}
    }
    {
    \end{boite}
    }
}

Any solution please with my packages... Many thanks Faouzi

1

Have you tried this ? Breaking Page with Boiboites Package TikZ

If it doesn't suit your need, you can use the framed package as seen here: http://www.texample.net/tikz/examples/framed-tikz/

A contact of mine did it some time ago and here is what he came up with (not sure it's optimal but it works):

\RequirePackage{xkeyval}
\RequirePackage{tikz}
\RequirePackage{amssymb}
\RequirePackage{framed}
\usetikzlibrary{decorations.pathmorphing,calc}
\pgfmathsetseed{1} % To have predictable results
% Define a background layer, in which the parchment shape is drawn
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

% define styles for the normal border and the torn border
\tikzset{  fond/.style={blue!5,rounded corners=5pt,decorate}}%,
\tikzset{  bordure/.style={orange,very thick,-,rounded corners=5pt}} 
\tikzset{  titre/.style={draw,rectangle,rounded corners=5pt,fill=blue!20}}

% Macro to draw the shape behind the text, when it fits completly in the
% page
\def\parchmentframe#1{
\tikz{
  \node[inner sep=5pt] (A) {#1};  % Draw the text of the node
  \noindent
  \begin{pgfonlayer}{background}  % Draw the shape behind
  \fill[fond] 
        (A.south east) -- (A.south west) -- 
        (A.north west) -- (A.north east) -- cycle;
  \draw[bordure]
        (A.south east) -- (A.south west) -- 
        (A.north west) -- (A.north east) -- cycle;      
  \end{pgfonlayer}}}

% Macro to draw the shape, when the text will continue in next page
\def\parchmentframetop#1{
\tikz{
  \node[inner sep=5pt] (A) {#1};    % Draw the text of the node
  \begin{pgfonlayer}{background}    
  \fill[fond]              % Draw the ``complete shape'' behind
        (A.south east) -- (A.south west) -- 
        (A.north west) -- (A.north east) -- cycle;
  \draw[bordure]
        (A.south east) -- (A.south west) -- 
        (A.north west) -- (A.north east) -- cycle;   
  \end{pgfonlayer}}}

% Macro to draw the shape, when the text continues from previous page
\def\parchmentframebottom#1{
\tikz{
  \node[inner sep=5pt] (A) {#1};   % Draw the text of the node
  \begin{pgfonlayer}{background}   
  \fill[fond]             % Draw the ``complete shape'' behind
        (A.south east) -- (A.south west) -- 
        (A.north west) -- (A.north east) -- cycle;
  \draw[bordure]
        (A.south east) -- (A.south west) -- 
        (A.north west) -- (A.north east) -- cycle;   
  \end{pgfonlayer}}}

% Macro to draw the shape, when both the text continues from previous page
% and it will continue in next page
\def\parchmentframemiddle#1{
\tikz{
  \node[inner sep=5pt] (A) {#1};   % Draw the text of the node
  \begin{pgfonlayer}{background}   
  \fill[fond]             % Draw the ``complete shape'' behind
        (A.south east) -- (A.south west) -- 
        (A.north west) -- (A.north east) -- cycle;
  \draw[bordure]
        (A.south east) -- (A.south west) -- 
        (A.north west) -- (A.north east) -- cycle;   
  \end{pgfonlayer}}}

% Define the environment which puts the frame
% In this case, the environment also accepts an argument with an optional
% title (which defaults to ``Th\'eor\`eme'', which is typeset in a box     overlaid
% on the top border
\newcounter{ctheo}[chapter]%définition d'un compteur
\newenvironment{theo}[1][Th\'eor\`eme.]{%
  \noindent
  \stepcounter{ctheo}
  \def\FrameCommand{\parchmentframe}%
  \def\FirstFrameCommand{\parchmentframetop}%
  \def\LastFrameCommand{\parchmentframebottom}%
  \def\MidFrameCommand{\parchmentframemiddle}%
  \vskip\baselineskip
  \MakeFramed {\FrameRestore}
  \noindent  \tikz  \node[inner sep=1ex,titre,anchor=west, overlay] at (0pt,     8pt) {\sffamily#1 \thectheo .}; \par \noindent}%
{\endMakeFramed}

The main problem with this solution is that you have to define every environment this way, you can't use the \newboxedtheorem macro to generate your environments.

  • Hello Alexis, I have the problem of writing right-to-left which induces several problem... for example, there's problems of compatibility of the package Tcolorbox and graphics...etc... at all, even when I don't use the package graphicx, I have the message " Package pgfkeys Error: I do not know the key '/tcb/library/breakable' " – Faouzi Bellalouna Mar 10 '14 at 10:07
  • I don't know anything about writing from right to left but your pgfkeys error is discussed here: tex.stackexchange.com/questions/121518/… Also, if you managed to modify the code of boiboites you should be able to modify the above code using the same solution(s). – Alexis Mar 10 '14 at 20:41
  • I will try to do, and inform you about it. Thank you – Faouzi Bellalouna Mar 10 '14 at 21:33
  • Hello Alexis,Je viens de me rendre compte que vous êtes l'auteur du package boiboites, et je vous en remercie car ce package est le meilleur qu'il y a sur la place, je trouve... Auriez-vous des idées pour le rendre breakable, i.e. pouvant aller sur plusieurs pages? Ce serait vraiment super, car je pourrais l'adapter à polyglossia après. Merci – Faouzi Bellalouna Mar 13 '14 at 17:42
  • Don't know if we're supposed to speak French here so I'll answer in English. Although I understand why you would like the boxes to be breakable I don't really like it when they are spanned on multiple pages. That's one reason why I didn't make it possible. The main reason is I'm lazy and not very qualified. Still, I gave you a workaround which was made by someone else and which seems to work just fine, give it a try! – Alexis Mar 14 '14 at 15:49

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.