“透明” tcolorbox 字幕覆盖父框的框架

“透明” tcolorbox 字幕覆盖父框的框架

在手动定义的皮肤中tcolorbox,我希望为整个框设置一个框架,但没有特定的背景或边框\tcbsubtitle。我不知道是否可以为选择透明度subtitle style,但选择colback = white会导致白色背景略微延伸到框框架中。

如何避免字幕背景跳入框架?也许frame engine=pathmiddle只针对字幕?

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

在此处输入图片描述

答案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}

在此处输入图片描述

相关内容