
Utilizo el paquete tcolorbox para producir cuadros titulados. Puse el nodo del título en la esquina derecha del cuadro pero se superpone al texto del ejemplo. ¿Cómo puedo hacer un cuadro con el nodo de título en la esquina derecha y el texto "envuelto" alrededor de él, de modo que el texto del ejemplo se detenga cuando llegue al nodo y continúe en la nueva línea? Doy un ejemplo mínimo.
\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}
y el resultado obtenido con el compilador xelatex
Actualizar
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}
y es compilacion con xelatex
Respuesta1
Si ejecuto su ejemplo no obtengo la línea superior, pero esto agrega el recorte:
\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}