I use tcolorbox in arabic document with polyglossia for theorems examples, and so. I put the titles of environments in tikz boxes what I put in the margin (in the right margin, the arabic is written in Right to Left mode) I want (essentially for "small" examples but for others too...) to obtain good alignments of the boxes and for the nodes. Say a box and a node of the same height. I do it by hand, because I don't understand how tcolorbox decide where to put exactly the node... I give an ECM..
The tex file
\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=0pt,right=0pt,enlarge top by=\baselineskip/2+1mm,enlarge top at break by=0mm,pad at break=2mm,fontupper=\normalsize,
overlay unbroken and first={%
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\node[titlenode] (B)
at ([xshift=5mm,yshift=-6.3mm]frame.north east)
{\strut\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}{c}
\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=white,colback=white,
width=\textwidth,
borderline north={2pt}{-3pt}{yellow},borderline south={2pt}{4.6pt}{blue},
before upper={\parshape 4
0pt \dimexpr \hsize-2.5cm\relax
0pt \dimexpr \hsize-2.5cm\relax
0pt \dimexpr \hsize-2.5cm\relax
0pt \hsize},
#1}
\newtcolorbox[use counter from=example]{texample}[2][]{
enhanced,boxrule=0pt,minipage boxed title=140mm,left=0pt,right=0pt,top=5mm,
attach boxed title to top right={xshift=-5mm,yshift=-3.8mm,yshifttext=-1mm},
coltitle=black,
boxed title style={
left=5pt,
right=5pt,
enhanced,
arc=0pt,outer arc=0pt,
colframe=blue,
colback=yellow,
colbacktitle=black,
},
enlarge top by=\baselineskip/2+1mm,enlarge top at break by=0mm,pad at break=2mm,fontupper=\normalsize,
overlay unbroken and first={%
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\node[titlenode] (B)
at ([xshift=5mm,yshift=-2.6mm]frame.north east)
{\strut\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}{c}
\hline
\rule{0pt}{2ex}
\mbox{Example}
\\
\mbox{\Large\thetcbcounter}
\rule{0pt}{1.5ex}
\end{array}$}};
},
breakable,before=\par\smallskip\centering,arc=0pt,colframe=white,colback=white,width=\textwidth,borderline south={2pt}{5pt}{blue},
before upper={\parshape 2
0pt \dimexpr \hsize-2.5cm\relax
0pt \hsize},
title={\strut\textbf{#2}\strut},
#1}
\begin{document}
\setcounter{section}{1}
\begin{example}
A first example
\end{example}
\vspace*{1cm}
\begin{example}
A first example. Aligned bottom
\vspace*{.57cm}
\end{example}
\begin{texample}{Titled example}
By the same, I want that the title node rectangle will be exactly aligned with the box of title.
\end{texample}
\end{document}
and its compilation with xelatex
I want that the title node rectangle will be exactly superposed on the borderline north (in yellow). One can see in the example 1a that the box is too small, and I want to arrange it in the bottom too, so that the borderline south will be exactly superposed under the title box. I arrange it by hand in the example 1b, in the text of the box by the command \vspace*{.57cm}. I want to do this automatically, i.e. to obtain box and node with the same height. How can I do this ?
By the same, I want to obtain good alignments of the title node rectangle and the box of the title. Many thanks