1

I added thesubsection to the frame header but was not. I want to subsection the subsection in the image below as an automatic, not manually!

enter image description here

enter image description here

enter image description here

Here is my declaration

\newtcolorbox{boxtb}[2][]{enhanced,
before skip=2mm,after skip=2mm,
colframe=blue!75!black,colback=yellow!30!white,colbacktitle=red!10!white,breakable,
fonttitle=\bfseries,coltitle=black,attach boxed title to top left=
{yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=2mm-\tcboxedtitleheight/3},
boxed title style={boxrule=0.5mm,
frame code={ \path[tcb fill frame] ([xshift=-0mm]frame.west)
-- (frame.north west) -- (frame.north east) -- ([xshift=4mm]frame.east)
-- (frame.south east) -- (frame.south west) -- cycle; },
interior code={ \path[tcb fill interior] ([xshift=-0mm]interior.west)
-- (interior.north west) -- (interior.north east)
-- ([xshift=2mm]interior.east) -- (interior.south east) -- (interior.south west)
-- cycle;},
},
fonttitle=\bfseries,title={\thesubsection #2},#1}
1

If I understand you correctly, you want to use the tcolorbox for subsections. This can be done with the titlesec package, see e.g. here. UPDATE: Tried to match your updated question.

\documentclass{article}
\usepackage{xcolor}
\usepackage[explicit]{titlesec}
\usepackage[many]{tcolorbox}

\newtcolorbox{boxtb}[2][]{enhanced,
before skip=2mm,after skip=2mm,
colframe=blue!75!black,colback=yellow!30!white,colbacktitle=red!10!white,breakable,
fonttitle=\bfseries,coltitle=black,attach boxed title to top left=
{yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=2mm-\tcboxedtitleheight/3},
boxed title style={boxrule=0.5mm,
frame code={ \path[tcb fill frame] ([xshift=-0mm]frame.west)
-- (frame.north west) -- (frame.north east) -- ([xshift=4mm]frame.east)
-- (frame.south east) -- (frame.south west) -- cycle; },
interior code={ \path[tcb fill interior] ([xshift=-0mm]interior.west)
-- (interior.north west) -- (interior.north east)
-- ([xshift=2mm]interior.east) -- (interior.south east) -- (interior.south west)
-- cycle;} ,
},
fonttitle=\bfseries,title={\thesubsection #2},#1}

\renewcommand{\thesubsection}{\Roman{subsection}.}

% adapted from https://tex.stackexchange.com/a/226751/121799
\titleformat{\subsection}
  {}
  {}{0pt}
  {\begin{boxtb}{\hskip0.7em#1}\end{boxtb}}


\begin{document}

\section{A test section}

\subsection{A test subsection}

\subsection{Another test subsection}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.