0

In a manually defined skin for tcolorbox, I'd like to have a frame for the complete box, but no particular background or borderings for \tcbsubtitle. I don't know if one can select transparency for the subtitle style, but selecting colback = white leads to a white background that reaches into the boxes frame by just a bit.

How can I avoid that the subtitle background leaps over into the frame? Maybe something like frame engine=pathmiddle just for the subtitle?

\documentclass{article}

\usepackage{tcolorbox, xcolor}
\tcbuselibrary{breakable, skins, xparse}

\tcbset
  {
    skin = empty,
    width = \linewidth,
    breakable = true,
    fonttitle = \sffamily\bfseries\Large,
    coltitle = black,
    graphical environment = tikzpicture,
    sharp corners = all,
    no shadow
  }

\DeclareTColorBox{framed}{m O{1mm} O{blue}}
  {
    graphical environment = tikzpicture,
    title = {#1},
    boxsep = 0pt,
    toptitle = 5mm,
    top = 5mm,
    bottom = 5mm,
    left = 5mm,
    right = 5mm,
    borderline = {#2}{0pt}{#3},
    beforeafter skip balanced = \baselineskip,
    subtitle style = 
      {
        top = 3.25ex,
        boxrule = 0pt,
        colback = white,
        fontupper = \normalfont\sffamily\bfseries\large
      } 
  }

\begin{document}
    \begin{framed}{My title}
        content...
        \tcbsubtitle{My subtitle}
    \end{framed}
\end{document}

enter image description here

1 Answer 1

1
\documentclass{article}

\usepackage{tcolorbox, xcolor}
\tcbuselibrary{breakable, skins, xparse}

\tcbset
  {
    skin = empty,
    width = \linewidth,
    breakable = true,
    fonttitle = \sffamily\bfseries\Large,
    coltitle = black,
    graphical environment = tikzpicture,
    sharp corners = all,
    no shadow
  }

\DeclareTColorBox{framed}{m O{1mm} O{blue}}
  {
    graphical environment = tikzpicture,
    title = {#1},
    boxsep = 0pt,
    toptitle = 5mm,
    top = 5mm,
    bottom = 5mm,
    left = 5mm,
    right = 5mm,
    borderline = {#2}{0pt}{#3},
    beforeafter skip balanced = \baselineskip,
    subtitle style =
      {
        top = 3.25ex,
        boxrule = 0pt,
        enhanced,
        interior hidden,
        frame hidden,
        fontupper = \normalfont\sffamily\bfseries\large
      }
  }

\begin{document}
    \begin{framed}{My title}
        content...
        \tcbsubtitle{My subtitle}
    \end{framed}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .