# tcolorbox custom title box style

could anyone write the code to obtain a similar shape for the title of the box? the awkwardly drew line is to show a shape with no angular points. The title box must look like a rounded box inside the big box, slightly pushed upward. The big box is kind of rubber protected all around. They both must look like one piece only. The background color of the box could be white. A little bit like the title style of the bottom example, p. 165 of the tcolorbox manual 4.30.

Update here is another example. Actually filling colours are often used to hide things.

More or less:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{varwidth}
\usepackage{lipsum}

\newtcolorbox{mybox}[2][]{enhanced, interior hidden,
colframe=cyan!30, colback=cyan!30, coltitle=blue!70!black,
fonttitle=\bfseries\sffamily,
attach boxed title to top left,
boxed title style={empty, boxrule=0.5mm},
varwidth boxed title=0.5\linewidth,
underlay boxed title={
\path[draw=cyan!30, line width=0.5mm, rounded corners, fill=cyan!30]
([xshift=.25mm]frame.west) |- ([xshift=-2.5mm]title.north east) to[out=0, in=180] ([xshift=7.5mm, yshift=-.25mm]title.south east);
},
title={#2},#1}
\begin{document}

\begin{mybox}{My title}
\lipsum[2]
\end{mybox}

\begin{mybox}{A longer title}
\lipsum[2]
\end{mybox}

\end{document}


Update: white background and lower title

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{varwidth}
\usepackage{lipsum}

\newtcolorbox{mybox}[2][]{empty,
coltitle=black,
fonttitle=\bfseries\sffamily,
attach boxed title to top left={yshift=-2.5mm},
boxed title style={empty, size=small, top=1mm, bottom=0pt},
varwidth boxed title=0.5\linewidth,
frame code={
\path (title.east|-frame.north) coordinate (aux);
\path[draw=black, line width=0.5mm, rounded corners]
(frame.west) |- ([xshift=-2.5mm]title.north east) to[out=0, in=180] ([xshift=7.5mm]aux)-|(frame.east)|-(frame.south)-|cycle;
},
title={#2},#1}
\begin{document}

\begin{mybox}{My title}
\lipsum[2]
\end{mybox}

\begin{mybox}{A longer title}
\lipsum[2]
\end{mybox}

\end{document}


• looks good, i will try tuning a little bit. Do you think you could decrease slightly the height of the tab and the title together? I guess modifying this code to do the same but at the right end or the boxes might not be very difficult. Mar 18, 2021 at 14:35
• can you make it with colback=white and black stroke colour. I tried but actually the contour of the main text box is still visible. Mar 18, 2021 at 16:58
• @user1850133 Take a look at updated answer. By the way, tcolorbox is already in v4.42 Mar 18, 2021 at 18:51
• I think more more...and not less. Mar 18, 2021 at 22:13
• i just saw your update, i uploaded a drawing made with inkscape just a few seconds before. Mar 19, 2021 at 14:32