如何在 tcolorbox 中制作花式盒子

如何在 tcolorbox 中制作花式盒子

我想复制下面的花式盒子。

在此处输入图片描述

我尝试改编手册第 10.2 节中的某些代码,并进行了如下调整。

\documentclass[openany]{book}
\usepackage{xcolor}
\usepackage[many]{tcolorbox}
\newcommand*\mycirc[1]{%
\begin{tikzpicture}[baseline=(char.base)]
\node[shape=circle,fill=white,inner sep=1pt,minimum size=2ex](char) {#1}; 
\end{tikzpicture}}
\newtcolorbox[auto counter]{myex}[2]{ 
colback=white,
enhanced,
colframe=white,fonttitle=\Large\bfseries,
colbacktitle=purple,enhanced,
attach boxed title to top left={yshift=-2mm}, 
boxed title style={% 
enhanced,
colframe=purple,
colback=purple,
arc=12pt,
sharp corners, 
varwidth boxed title*=-3cm, 
rounded corners=west 
},
title= Example \mycirc{\textcolor{black}{\thetcbcounter}}, 
}
\begin{document}
\begin{myex}{SKILLS}{Problem-Solving}
The diameters of a metal pin produced by a 
\end{myex}
\end{document}

导致

在此处输入图片描述

非常欢迎任何形式的帮助。

答案1

关于如何创建带有计数器的自定义标题的快速入门。可以做得更好,但您明白我的意思了。

标题模型

\documentclass[12pt]{article}
\usepackage{tikz,lipsum}
\usetikzlibrary{shapes.symbols,positioning}

\newcounter{examp}
\setcounter{examp}{0}

\newcommand{\mytitle}[2]%
    {%
    \stepcounter{examp}
    \begin{tikzpicture}[font=\sffamily]
        \def\cola{pink!50!purple}
        \def\colb{cyan!80!blue}
        \node[circle,fill=\cola,minimum size=8mm] at (0,0) {};
        \node[fill=\cola,anchor=west,minimum height=8mm,minimum width=2cm] at (0,0) {};
        \node[fill=white,line width=2pt,circle,draw=\cola,minimum size=1cm] at (2.1,0) {\theexamp};
        \node[text=white,anchor=west] at (-0.2,0) {Example};
        \node[fill=\colb,signal,signal to=east,text=white,minimum height=8mm] (arg1) at (4,0) {#1};
        \node[right=2mm of arg1,\colb] (arg2) {#2};
    \end{tikzpicture}
    }

\begin{document}
    \mytitle{SKILLS}{PROBLEM-SOLVING}
    
    \lipsum[1]
    \medskip
    
    \mytitle{OTHER}{WHAT YOU NEED}
    
    \lipsum[2-3]
\end{document}

相关内容