带有 tcolorbox 包的框架中的子部分

带有 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}

答案1

如果我理解正确的话,你想使用tcolorboxfor subsections。这可以通过包来完成titlesec,例如这里更新:尝试匹配您更新后的问题。

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

在此处输入图片描述

相关内容