# How to make a rectangle of 3 colors with Tikzstyle and Tcolorbox

I've to write a book in arabic, with a background given by an image with stripes in 2 colours in the margin of the page. I include it in the document without any problem with the package bachground. But the labels of my theorems and examples etc, are written in the margin too, and the result is not very beautiful when it's superimposed on the stripes, because it's color is white. So I want to have the rectangle of the theorem and such in the same color of the background, with the same stripes, blue after white after "yellow" (as if the backgrounds were inversed, the example in background and the image as the document !) . I give the original image (to use as background) and an example of document obtained by putting this image as a background. I want to obtain the Tikz rectangle in the same color of the background, a blue sector, after a white sector, after a yellow.

I give the tex document. Note that the measures given for the boxes are empirical and not very important, because I don't know now the exact position of the stripes. The editor will send it to me later.

\documentclass[14pt,twoside]{book}

\usepackage{extsizes}

\usepackage{amsmath,amssymb}
\usepackage[most]{tcolorbox}

\usepackage{array}

\usepackage[pages=some]{background}

\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\setmonofont{DejaVu Sans Mono}
\let\arabicfonttt\ttfamily

\backgroundsetup{scale=1,opacity=1,angle=0,contents={\includegraphics[width=\paperwidth,height=\paperheight]{R3}}}
\BgThispage

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

\newcounter{example}

\newtcolorbox[auto counter,
number within=section,
number freestyle={\noexpand\arabic{section}\noexpand\alph{\tcbcounter}}]{example}[2][]{%
enhanced,
left=-5pt,
right=-5pt,
colback=gray!40,
colframe=white,
top=1mm,
bottom=8.5mm,
enlarge top by=\baselineskip/2+1mm,
enlarge top at break by=0mm,pad at break=2mm,
fontupper=\normalsize,
label={#2},
overlay unbroken and first={%
\node[whitebox]
at ([xshift=1.5cm,yshift=-.9cm]frame.north east)
{\strut\RL{\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}{c} \hline \rule{0pt}{2ex} \mbox{Ex} \\ \mbox{\large\thetcbcounter} \rule{0pt}{1.5ex} \end{array}$}}};},
breakable,
before=\par\smallskip\centering,
width=\textwidth,       %%% change the width here.
arc=0pt,outer arc=0pt,
extrude right by=5pt,
extrude left by=5pt,
#1}%

\begin{document}

\setcounter{section}{1}

\begin{example}{lab:exam:1}
\LR{The text of the example (labeled here Ex) is usually in arabic, in RightToLeft mode}
\end{example}
\end{document}


The good document.

Updated document to include an even/odd command to insert different backgrounds

It uses the method introduced by Thomas F. Sturm. My aim is to use it only for even pages and, for odd pages, uses the "boxwhite" really white and not in yellow and blue.

I give the result obtained for even/odd.

The Code is

\documentclass[14pt,twoside]{book}

\usepackage{extsizes}

\usepackage{amsmath,amssymb,lipsum}
\usepackage[most]{tcolorbox}

\usepackage{array}

\usepackage[pages=some]{background}

\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\setmonofont{DejaVu Sans Mono}
\let\arabicfonttt\ttfamily

\definecolor{myBlue}{rgb}{0.388235,0.454902,0.525490}
\definecolor{myYellow}{rgb}{0.643137,0.564706,0.388235}

\usepackage{background}
\usepackage{ifthen}
\ifthenelse{\isodd{\value{page}}}%
{
\backgroundsetup{
%position={0,0},
scale=1,
opacity=1,
angle=0,
contents={%
\includegraphics[width=\paperwidth,height=\paperheight]{L3}
}%
}
}%
{
\backgroundsetup{
%position={0,1},
scale=1,
opacity=1,
angle=0,
contents={%
\begin{tikzpicture}
\path (0,0)--(-\textwidth-20mm,0);
\draw[line width=5mm,myBlue](0,0)--++(0,\paperheight);
\draw[line width=5mm,myYellow](0.7,0)--++(0,\paperheight);
\end{tikzpicture}
}%
}
}%
\BgMaterial}

\tikzstyle{whitebox} =
[%draw=white,
thick, scale=.707,%fill=white, fill opacity=0.6,%
line width=0.3pt, text=black, rectangle, inner sep=3mm,
font=\Large,
left, minimum height=.5cm, minimum width=1.9cm]

\newcounter{example}

\newtcolorbox[auto counter,
number within=section,
number freestyle={\noexpand\arabic{section}\noexpand\alph{\tcbcounter}}]{example}[2][]%
{%
enhanced,
left=-5pt,
right=-5pt,
colback=gray!40,
colframe=white,
top=1mm,
bottom=8.5mm,
enlarge top by=\baselineskip/2+1mm,
fontupper=\normalsize,
label={#2},
overlay unbroken and first={%
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\node[whitebox] (B)
at ([xshift=1.5cm,yshift=-.9cm]frame.north east)
{\strut\RL{\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}{c} \hline \rule{0pt}{2ex} \mbox{Ex} \\ \mbox{\large\thetcbcounter} \rule{0pt}{1.5ex} \end{array}$}}};
\begin{pgfonlayer}{background}
\draw [line width=5mm,myYellow]([xshift=3.5mm]frame.south east|-B.south)--      ([xshift=3.5mm]frame.north east|-B.north);
\draw [line width=5mm,myBlue]([xshift=10.5mm]frame.south east|-B.south)--   ([xshift=10.5mm]frame.north east|-B.north);
\end{pgfonlayer}
},
breakable,
before=\par\smallskip\centering,
width=\textwidth,       %%% change the width here.
arc=0pt,outer arc=0pt,
extrude right by=5pt,
extrude left by=5pt,
enlarge top at break by=0mm,pad at break=2mm,
#1%
}%

\begin{document}

\setcounter{section}{1}

\begin{example}{lab:exam:1}
\LR{The text of the example (labeled here Ex) is usually in arabic, in RightToLeft mode
\lipsum[1]}
\end{example}
\newpage
\begin{example}{lab:exam:2}
\LR{The text of the example (labeled here Ex) is usually in arabic, in RightToLeft mode
\lipsum[1]}
\end{example}
\end{document}


I publish a second update, with the exact dimensions of the page and the images of the background. My question is how to determine exactly the dimensions (found here empirically...) in the underlay (for even pages), for exactly superposing the underlay and the background ?... Find here the .tex file and it's compilation, together with the images of the background. The arabic word, used in the box, (مثال) means Example.

The tex file

\documentclass[12pt]{book}

\usepackage{amsmath,amssymb}
\usepackage[most]{tcolorbox}

\usepackage{changepage}%<----------------- To check even / odd
\strictpagecheck

\usepackage{lipsum}
\usepackage{array}

\usepackage[pages=some]{background}

\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\newfontfamily\englishfont[Scale=1]{Times New Roman}
\setmonofont{DejaVu Sans Mono}
\let\arabicfonttt\ttfamily

\definecolor{myBlue}{rgb}{0.388235,0.454902,0.525490}
\definecolor{myYellow}{rgb}{0.643137,0.564706,0.388235}

\usepackage{background}
\usepackage{ifthen}
\ifthenelse{\isodd{\value{page}}}%
{
\backgroundsetup{
%position={0,0},
scale=1,
opacity=1,
angle=0,
contents={%
\includegraphics[width=\paperwidth,height=\paperheight]{L}
}%
}
}%
{
\backgroundsetup{
%position={0,1},
scale=1,
opacity=1,
angle=0,
contents={%
\includegraphics[width=\paperwidth,height=\paperheight]{R}
}%
}
}%
\BgMaterial}

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

\tikzstyle{yellowbox} =
[fill=myYellow, inner sep=1.5pt,
thick, scale=.74, draw=myBlue,
line width=1pt, text=black, rectangle,
font=\Large,left]

\newcounter{example}

\newtcolorbox[auto counter,number within=section,number freestyle={\noexpand\arabic{section}\noexpand\alph{\tcbcounter}}]{example}[2][]{%
enhanced,top=0mm,left=-5pt,right=-5pt,enlarge top by=\baselineskip/2+1mm,enlarge top at break by=0mm, pad at break=2mm,fontupper=\normalsize,
check odd page,% <---------------------------------
overlay unbroken and first={%
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\ifoddpage
\node[yellowbox] (B)
at ([xshift=12mm,yshift=-.58cm]frame.north east)
{\strut\RL{\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}{c} \hline \rule{0pt}{2ex} \mbox{\RL{مثال}} \\ \mbox{\Large\thetcbcounter} \rule{0pt}{1.5ex} \end{array}$}}};
\else
\node[whitebox] (B)
at ([xshift=2cm,yshift=-.73cm]frame.north east)
{\strut\RL{\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}{c} \hline \rule{0pt}{2ex} \mbox{\RL{مثال}} \\ \mbox{\Large\thetcbcounter} \rule{0pt}{1.5ex} \end{array}$}}};
\begin{pgfonlayer}{background}
\draw [line width=4.7mm,myYellow]([xshift=10mm,yshift=.5mm]frame.south east|-B.south)--             ([xshift=10mm,yshift=.5mm]frame.north east|-B.north);
\draw [line width=4.7mm,myBlue]([xshift=16mm,yshift=.5mm]frame.south east|-B.south)--                  ([xshift=16mm,yshift=.5mm]frame.north east|-B.north);
\end{pgfonlayer}
\fi%
},
breakable,before=\par\smallskip\vspace{-10pt}\centering,arc=0pt,outer arc=0pt,colframe=white,colback=white,
width=\textwidth, borderline north={2pt}{-3pt}{myBlue},borderline south={2pt}{5pt}{myBlue},
label={#2},
#1}

\begin{document}

\setcounter{section}{1}

\begin{example}{lab:exam:1}
\LR{\lipsum[1]}
\end{example}
\newpage
\begin{example}{lab:exam:2}
\LR{\lipsum[1]}
\end{example}
\end{document}


The pdf file obtained :

The background images..

• Seems, I misunderstood you question. I thought you would like to have inverted color stripes where the example box runs... I found this a not so bad design idea. Maybe, you (or somebody) can use my answer anyway :-) – Thomas F. Sturm Feb 5 '15 at 17:34
• @FaouziBellalouna Just a suggestion: perhaps you should delete your answer and give some time to esdd to turn his/her comment to a proper answer (as I already suggested him/her); it was his/her idea, and even though you credited him/her in your answer, I think he/she deserves the chance to give the answer. Of course, I insist, this is just a suggestion. – Gonzalo Medina Feb 5 '15 at 18:51

As I see now, my answer is a little bit off from the originally intended question. Nevertheless, I find the idea of the inverted colors nice and if you don't mind I keep the answer for a future reader who looks for something like this.

I had to mock up the missing R3 picture for the background. So, you will have to adapt the following length settings to your real application. What I have is the following:

I adapted the whitebox a little bit (I removed the white color) and added an underlay setting to the tcolorbox. The underlay contains the inverted color stripes.

I used the underlay, because it is independent from the overlay which will only be set for the first and unbroken page.

The resulting code is:

\documentclass[14pt,twoside]{book}

\usepackage{extsizes}

\usepackage{amsmath,amssymb}
\usepackage[most]{tcolorbox}

\usepackage{array}

\usepackage[pages=some]{background}

\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\setmonofont{DejaVu Sans Mono}
\let\arabicfonttt\ttfamily

\backgroundsetup{scale=1,opacity=1,angle=0,contents={%
%\includegraphics[width=\paperwidth,height=\paperheight]{R3}}
% Mock up, because I do not have the R3 image
\begin{tikzpicture}
\path (0,0)--(-\textwidth-20mm,0);
\draw[line width=5mm,blue!25!gray](0,0)--++(0,\paperheight);
\draw[line width=5mm,yellow!25!gray](0.7,0)--++(0,\paperheight);
\end{tikzpicture}}%
}
\BgThispage

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

\newcounter{example}

\newtcolorbox[auto counter,
number within=section,
number freestyle={\noexpand\arabic{section}\noexpand\alph{\tcbcounter}}]{example}[2][]%
{%
enhanced,
left=-5pt,
right=-5pt,
colback=gray!40,
colframe=white,
top=1mm,
bottom=8.5mm,
enlarge top by=\baselineskip/2+1mm,
fontupper=\normalsize,
label={#2},
underlay={%
\draw [line width=5mm,yellow!25!gray]([xshift=3.5mm]frame.south east)--([xshift=3.5mm]frame.north east);
\draw [line width=5mm,blue!25!gray]([xshift=10.5mm]frame.south east)--([xshift=10.5mm]frame.north east);
},
overlay unbroken and first={%
\node[whitebox]
at ([xshift=1.5cm,yshift=-.9cm]frame.north east)
{\strut\RL{\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}{c} \hline \rule{0pt}{2ex} \mbox{Ex} \\ \mbox{\large\thetcbcounter} \rule{0pt}{1.5ex} \end{array}$}}};},
breakable,
before=\par\smallskip\centering,
width=\textwidth,       %%% change the width here.
arc=0pt,outer arc=0pt,
extrude right by=5pt,
extrude left by=5pt,
enlarge top at break by=0mm,pad at break=2mm,
#1%
}%

\begin{document}

\setcounter{section}{1}

\begin{example}{lab:exam:1}
\LR{The text of the example (labeled here Ex) is usually in arabic, in RightToLeft mode}
\end{example}
\end{document}


As a variant, one could add some semit-transparent white to the Ex box. This gives:

And the code is:

\documentclass[14pt,twoside]{book}

\usepackage{extsizes}

\usepackage{amsmath,amssymb,lipsum}
\usepackage[most]{tcolorbox}

\usepackage{array}

\usepackage[pages=some]{background}

\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\setmonofont{DejaVu Sans Mono}
\let\arabicfonttt\ttfamily

\backgroundsetup{scale=1,opacity=1,angle=0,contents={%
%\includegraphics[width=\paperwidth,height=\paperheight]{R3}}
% Mock up, because I do not have the R3 image
\begin{tikzpicture}
\path (0,0)--(-\textwidth-20mm,0);
\draw[line width=5mm,blue!25!gray](0,0)--++(0,\paperheight);
\draw[line width=5mm,yellow!25!gray](0.7,0)--++(0,\paperheight);
\end{tikzpicture}}%
}
\BgThispage

\tikzstyle{whitebox} =
[%draw=white,
thick, scale=.707,fill=white, fill opacity=0.6,%
line width=0.3pt, text=black, rectangle, inner sep=3mm,
font=\Large,
left, minimum height=.5cm, minimum width=1.9cm]

\newcounter{example}

\newtcolorbox[auto counter,
number within=section,
number freestyle={\noexpand\arabic{section}\noexpand\alph{\tcbcounter}}]{example}[2][]%
{%
enhanced,
left=-5pt,
right=-5pt,
colback=gray!40,
colframe=white,
top=1mm,
bottom=8.5mm,
enlarge top by=\baselineskip/2+1mm,
fontupper=\normalsize,
label={#2},
underlay={%
\draw [line width=5mm,yellow!25!gray]([xshift=3.5mm]frame.south east)--([xshift=3.5mm]frame.north east);
\draw [line width=5mm,blue!25!gray]([xshift=10.5mm]frame.south east)--([xshift=10.5mm]frame.north east);
},
overlay unbroken and first={%
\node[whitebox]
at ([xshift=1.5cm,yshift=-.9cm]frame.north east)
{\strut\RL{\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}{c} \hline \rule{0pt}{2ex} \mbox{Ex} \\ \mbox{\large\thetcbcounter} \rule{0pt}{1.5ex} \end{array}$}}};},
breakable,
before=\par\smallskip\centering,
width=\textwidth,       %%% change the width here.
arc=0pt,outer arc=0pt,
extrude right by=5pt,
extrude left by=5pt,
enlarge top at break by=0mm,pad at break=2mm,
#1%
}%

\begin{document}

\setcounter{section}{1}

\begin{example}{lab:exam:1}
\LR{The text of the example (labeled here Ex) is usually in arabic, in RightToLeft mode
\lipsum[1]}
\end{example}
\end{document}


Update:

As requested by the OP, here is a modification which inverts the colors only below the whitebox. Here, the underlay is not needed.

The code is:

\documentclass[14pt,twoside]{book}

\usepackage{extsizes}

\usepackage{amsmath,amssymb,lipsum}
\usepackage[most]{tcolorbox}

\usepackage{array}

\usepackage[pages=some]{background}

\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\setmonofont{DejaVu Sans Mono}
\let\arabicfonttt\ttfamily

\definecolor{myBlue}{rgb}{0.388235,0.454902,0.525490}
\definecolor{myYellow}{rgb}{0.643137,0.564706,0.388235}

\backgroundsetup{scale=1,opacity=1,angle=0,contents={%
%\includegraphics[width=\paperwidth,height=\paperheight]{R3}}
% Mock up, because I do not have the R3 image
\begin{tikzpicture}
\path (0,0)--(-\textwidth-20mm,0);
\draw[line width=5mm,myBlue](0,0)--++(0,\paperheight);
\draw[line width=5mm,myYellow](0.7,0)--++(0,\paperheight);
\end{tikzpicture}}%
}
\BgThispage

\tikzstyle{whitebox} =
[%draw=white,
thick, scale=.707,%fill=white, fill opacity=0.6,%
line width=0.3pt, text=black, rectangle, inner sep=3mm,
font=\Large,
left, minimum height=.5cm, minimum width=1.9cm]

\newcounter{example}

\newtcolorbox[auto counter,
number within=section,
number freestyle={\noexpand\arabic{section}\noexpand\alph{\tcbcounter}}]{example}[2][]%
{%
enhanced,
left=-5pt,
right=-5pt,
colback=gray!40,
colframe=white,
top=1mm,
bottom=8.5mm,
enlarge top by=\baselineskip/2+1mm,
fontupper=\normalsize,
label={#2},
overlay unbroken and first={%
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\node[whitebox] (B)
at ([xshift=1.5cm,yshift=-.9cm]frame.north east)
{\strut\RL{\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}{c} \hline \rule{0pt}{2ex} \mbox{Ex} \\ \mbox{\large\thetcbcounter} \rule{0pt}{1.5ex} \end{array}$}}};
\begin{pgfonlayer}{background}
\draw [line width=5mm,myYellow]([xshift=3.5mm]frame.south east|-B.south)--([xshift=3.5mm]frame.north east|-B.north);
\draw [line width=5mm,myBlue]([xshift=10.5mm]frame.south east|-B.south)--([xshift=10.5mm]frame.north east|-B.north);
\end{pgfonlayer}
},
breakable,
before=\par\smallskip\centering,
width=\textwidth,       %%% change the width here.
arc=0pt,outer arc=0pt,
extrude right by=5pt,
extrude left by=5pt,
enlarge top at break by=0mm,pad at break=2mm,
#1%
}%

\begin{document}

\setcounter{section}{1}

\begin{example}{lab:exam:1}
\LR{The text of the example (labeled here Ex) is usually in arabic, in RightToLeft mode
\lipsum[1]}
\end{example}
\end{document}


Update 2:

A further request of the OP asks for setting the color switch only for even pages. Therefore, I added the changepage package and the check odd page key. All changes are marked in the following code, which changes color for even pages and keeps the label box background white for odd pages:

\documentclass[14pt,twoside]{book}

\usepackage{changepage}%<----------------- To check even / odd
\strictpagecheck

\usepackage{extsizes}

\usepackage{amsmath,amssymb,lipsum}
\usepackage[most]{tcolorbox}

\usepackage{array}

\usepackage[pages=some]{background}

\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\setmonofont{DejaVu Sans Mono}
\let\arabicfonttt\ttfamily

\definecolor{myBlue}{rgb}{0.388235,0.454902,0.525490}
\definecolor{myYellow}{rgb}{0.643137,0.564706,0.388235}

\usepackage{background}
\usepackage{ifthen}
\ifthenelse{\isodd{\value{page}}}%
{
\backgroundsetup{
%position={0,0},
scale=1,
opacity=1,
angle=0,
contents={%
\includegraphics[width=\paperwidth,height=\paperheight]{L3}
}%
}
}%
{
\backgroundsetup{
%position={0,1},
scale=1,
opacity=1,
angle=0,
contents={%
\begin{tikzpicture}
\path (0,0)--(-\textwidth-20mm,0);
\draw[line width=5mm,myBlue](0,0)--++(0,\paperheight);
\draw[line width=5mm,myYellow](0.7,0)--++(0,\paperheight);
\end{tikzpicture}
}%
}
}%
\BgMaterial}

\tikzstyle{whitebox} =
[%draw=white,
thick, scale=.707,%fill=white, fill opacity=0.6,%
line width=0.3pt, text=black, rectangle, inner sep=3mm,
font=\Large,
left, minimum height=.5cm, minimum width=1.9cm]

\newcounter{example}

\newtcolorbox[auto counter,
number within=section,
number freestyle={\noexpand\arabic{section}\noexpand\alph{\tcbcounter}}]{example}[2][]%
{%
enhanced,
left=-5pt,
right=-5pt,
colback=gray!40,
colframe=white,
top=1mm,
bottom=8.5mm,
enlarge top by=\baselineskip/2+1mm,
fontupper=\normalsize,
label={#2},
check odd page,% <---------------------------------
overlay unbroken and first={%
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\node[whitebox] (B)
at ([xshift=1.5cm,yshift=-.9cm]frame.north east)
{\strut\RL{\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}{c} \hline \rule{0pt}{2ex} \mbox{Ex} \\ \mbox{\large\thetcbcounter} \rule{0pt}{1.5ex} \end{array}$}}};
\ifoddpage\else% <---------------------------------
\begin{pgfonlayer}{background}
\draw [line width=5mm,myYellow]([xshift=3.5mm]frame.south east|-B.south)--      ([xshift=3.5mm]frame.north east|-B.north);
\draw [line width=5mm,myBlue]([xshift=10.5mm]frame.south east|-B.south)--   ([xshift=10.5mm]frame.north east|-B.north);
\end{pgfonlayer}
\fi%
},
breakable,
before=\par\smallskip\centering,
width=\textwidth,       %%% change the width here.
arc=0pt,outer arc=0pt,
extrude right by=5pt,
extrude left by=5pt,
enlarge top at break by=0mm,pad at break=2mm,
#1%
}%

\begin{document}

\setcounter{section}{1}

\begin{example}{lab:exam:1}
\LR{The text of the example (labeled here Ex) is usually in arabic, in RightToLeft mode
\lipsum[1]}
\end{example}
\newpage
\begin{example}{lab:exam:2}
\LR{The text of the example (labeled here Ex) is usually in arabic, in RightToLeft mode
\lipsum[1]}
\end{example}
\end{document}

• Your method is more beautiful when you inverse the colors. Question : If you have the image what must be the command ? Is there's any method to upload this image on the site that I can watch what must be made ? – Faouzi Bellalouna Feb 5 '15 at 17:35
• @FaouziBellalouna You have to find the correct color codes for the two colors (can be done by picking with some drawing program). And you have to play with the length values inside the underlay code to match the stripes of the original picture. – Thomas F. Sturm Feb 5 '15 at 17:43
• @FaouziBellalouna Scanning from this web page, the RGB values of the colors should be Gray 0.388235, 0.454902, 0.525490 and Yellow 0.643137, 0.564706, 0.388235 – Thomas F. Sturm Feb 5 '15 at 17:49
• Ok I'll do this.. "play with colors and lengths".. immediately when I'll have the exact dimensions from my editor. Your code is excellent and gives good ways of think. Thank you – Faouzi Bellalouna Feb 5 '15 at 17:49
• Please what means "Gray 0.388235, 0.454902, 0.525490" ? Where do I must enter this dimensions ? – Faouzi Bellalouna Feb 5 '15 at 17:55

As already mentioned in my comment, you can use \node[whitebox,draw=none,fill=none]... or you can change the draw=white and fill=white options of the whitebox style to draw=none and fill=none.

Note, that the up to date syntax for setting styles is

\tikzset{whitebox/.style={...}}


Additionally the option thick will be overwritten by the later option line width=0.3pt.

So I suggest to use

\tikzset{
whitebox/.style={
rectangle,
draw=none, fill=none,
scale=.707, line width=.3pt,
text=black, font=\Large, left,
minimum height=.5cm, minimum width=1.9cm
}
}


Code:

\documentclass[14pt,twoside]{book}
\usepackage{extsizes}

\usepackage{amsmath,amssymb}
\usepackage[most]{tcolorbox}

\usepackage{array}

\usepackage[pages=some]{background}

\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\setmonofont{DejaVu Sans Mono}
\let\arabicfonttt\ttfamily

\backgroundsetup{scale=1,opacity=1,angle=0,contents={\includegraphics[width=\paperwidth,height=\paperheight]{R3}}}
\BgThispage

\tikzset{
whitebox/.style={
rectangle,
draw=none, fill=none,
scale=.707, line width=.3pt,
text=black, font=\Large, left,
minimum height=.5cm, minimum width=1.9cm
}
}

\newcounter{example}

\newtcolorbox[auto counter,
number within=section,
number freestyle={\noexpand\arabic{section}\noexpand\alph{\tcbcounter}}]{example}[2][]{%
enhanced,
left=-5pt,
right=-5pt,
colback=gray!40,
colframe=white,
top=1mm,
bottom=8.5mm,
enlarge top by=\baselineskip/2+1mm,
enlarge top at break by=0mm,pad at break=2mm,
fontupper=\normalsize,
label={#2},
overlay unbroken and first={%
\node[whitebox]
at ([xshift=1.5cm,yshift=-.9cm]frame.north east)
{\strut\RL{\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}{c} \hline \rule{0pt}{2ex} \mbox{Ex} \\ \mbox{\large\thetcbcounter} \rule{0pt}{1.5ex} \end{array}$}}};},
breakable,
before=\par\smallskip\centering,
width=\textwidth,       %%% change the width here.
arc=0pt,outer arc=0pt,
extrude right by=5pt,
extrude left by=5pt,
#1}%

\begin{document}
\pagecolor{green}
\setcounter{section}{1}

\begin{example}{lab:exam:1}
\LR{The text of the example (labeled here Ex) is usually in arabic, in RightToLeft mode}
\end{example}
\end{document}