# Node in the corner of tcolorbox with text “wrapped” around it

I use the tcolorbox package to produce titled boxes. I put the node of the title on the right- corner of the box but it overlays the text of the example. How can I make a box with the title- node on the right-corner and the text "wrapped" around it, so the text of the example stops when it arrives to the node and goes on the newline. I give a minimal example

\documentclass[14pt]{extbook}%
\usepackage[most]{tcolorbox}

\usepackage{array}

\tikzstyle{titlenode} =
[draw=black, thick, scale=.7, fill=red,%
line width=0.1pt, text=black, rectangle,
font=\Large,
left, minimum height=1cm]

\newtcolorbox{boxexample}[2][]{%
enhanced,
%oversize,
colback=white,
boxrule=.5pt,
colframe=black,
top=6mm,
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[titlenode] (B)
at ([xshift=0cm,yshift=-.7cm]frame.north east)
{\strut\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}{c} \hline \rule{0pt}{2ex} \mbox{Example} \\ \mbox{#2} \rule{0pt}{1.5ex} \end{array}$}};},
breakable,
arc=0pt,outer arc=0pt,
#1}%

\begin{document}

\begin{boxexample}{One}
The text of the example is overlayed by the node of the title in the right-corner...
The text of the example is overlayed by the node of the title in the right-corner
\end{boxexample}

\end{document}


and the result obtained with the xelatex compiler

Update

Thanks to @David Carlisle, I obtain boxed examples, with text wrapped around the title node,
with the command "0pt \dimexpr \hsize-3cm\relax", which is not very far from my aim. Clearly,
I doesn'nt want to write the commands...
"\parshape 4
0pt \dimexpr \hsize-3cm\relax
0pt \dimexpr \hsize-3cm\relax
0pt \dimexpr \hsize-3cm\relax
0pt \hsize"
at every beginning of example.
How can I write a macro which inserts automatically the command \parshape 4,
and 3 lines with the command "0pt \dimexpr \hsize-3cm\relax" at the beginning of each
example ?...

I give the tex file I use

\documentclass[14pt]{extbook}%
\usepackage[most]{tcolorbox}

\usepackage{array}

\tikzstyle{titlenode} =
[draw=blue, thick, scale=.7, fill=red,%
line width=1pt, text=black, rectangle,
font=\Large,
left, minimum height=1cm]

\newcounter{example}

\newtcolorbox[auto counter,
number within=section,
number freestyle={\noexpand\arabic{section}\noexpand\alph{\tcbcounter}}]{example}[1][]{%
enhanced,top=0mm,left=2pt,right=2pt,
enlarge top by=\baselineskip/2+1mm,enlarge top at break by=0mm,pad at break=2mm,fontupper=\normalsize,
overlay unbroken and first={%
at ([xshift=-6pt,yshift=-27pt]frame.north east)
{\strut\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}} \hline \rule{0pt}{2ex} \mbox{Example} \\ \mbox{\Large\thetcbcounter} \rule{0pt}{1.5ex} \end{array}$}};
},
breakable,before=\par\smallskip\vspace{-10pt}\centering,arc=0pt,
outer arc=0pt,colframe=green,colback=white,
width=\textwidth,
#1}

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

\begin{example}
\parshape 4
0pt \dimexpr \hsize-3cm\relax
0pt \dimexpr \hsize-3cm\relax
0pt \dimexpr \hsize-3cm\relax
0pt \hsize
The text of the example is not overlayed by the node of the title   in      the right-corner...
The text of the example is not overlayed by the node of the title in the right-corner...
The text of the example is not overlayed by the node of the title in the right-corner
\end{example}

\end{document}


and it's compilation with xelatex

If I run your example I get no top line, but this adds the cutout:

\documentclass[14pt]{extbook}%
\usepackage[most]{tcolorbox}

\usepackage{array}

\tikzstyle{titlenode} =
[draw=black, thick, scale=.7, fill=red,%
line width=0.1pt, text=black, rectangle,
font=\Large,
left, minimum height=1cm]

\newtcolorbox{boxexample}[2][]{%
enhanced,
%oversize,
colback=white,
boxrule=.5pt,
colframe=black,
top=6mm,
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[titlenode] (B)
at ([xshift=0cm,yshift=-.7cm]frame.north east)
{\strut\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}{c} \hline \rule{0pt}{2ex} \mbox{Example} \\ \mbox{#2} \rule{0pt}{1.5ex} \end{array}$}};},
breakable,
arc=0pt,outer arc=0pt,
#1}%

\begin{document}

\begin{boxexample}{One}
\parshape 3
0pt \dimexpr \hsize-3cm\relax
0pt \dimexpr \hsize-3cm\relax
0pt \hsize
The text of the example is overlayed by the node of the title in the right-corner...
The text of the example is overlayed by the node of the title in the right-corner
\end{boxexample}

\end{document}


• The result is well, for this example. But I have a lot of box environments, theorems, titled theorems, bi-titled (in Arabic and in English...) Do you think that this method will always work fine ?... can you explain me what make exactly the command "0pt \dimexpr \hsize-3cm\relax" ? can I integrate it in the commands definition of the box ?...writing these commands in every box will be very problematic for me... I have thousands environments like this... – Faouzi Bellalouna Apr 21 '15 at 20:36
• I'll try this kind of commands and let you know if any problem. Many thanks for this first and important step – Faouzi Bellalouna Apr 21 '15 at 20:52
• Please see my update – Faouzi Bellalouna Apr 22 '15 at 7:55
• @FaouziBellalouna you can use the wrapfig package to make the cutout and add the coloured box insert. – David Carlisle Apr 22 '15 at 8:14
• I'll read the doc and tell you about. Thanks. – Faouzi Bellalouna Apr 22 '15 at 8:24