Knoten in der Ecke der Farbbox mit darum „gewickeltem“ Text

Knoten in der Ecke der Farbbox mit darum „gewickeltem“ Text

Ich verwende das Paket tcolorbox, um betitelte Boxen zu erstellen. Ich platziere den Knoten des Titels in der rechten Ecke der Box, aber er überlagert den Text des Beispiels. Wie kann ich eine Box mit dem Titelknoten in der rechten Ecke und dem Text „umwickelt“ darum erstellen, sodass der Text des Beispiels anhält, wenn er den Knoten erreicht, und in die neue Zeile eingefügt wird? Ich gebe ein minimales Beispiel

\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}

und das mit dem xelatex-Compiler erzielte Ergebnis

Bildbeschreibung hier eingeben

Aktualisieren

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}

und seine Kompilierung mit xelatex Bildbeschreibung hier eingeben

Antwort1

Wenn ich Ihr Beispiel ausführe, erhalte ich keine obere Zeile, aber dies fügt den Ausschnitt hinzu:

\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}

Ausgabe

verwandte Informationen