如何创建带有精美标题框以及左边框和下边框的 tcolorbox

如何创建带有精美标题框以及左边框和下边框的 tcolorbox

我想使用下面的 tcolorbox 为我的学生做练习。 在此处输入图片描述 我尝试使用以下代码进行重现:

\documentclass[12pt,a4paper]{article} 
\usepackage{tcolorbox} 
\usepackage{amsmath,amssymb}
 \xdefinecolor{myblue}{RGB}{102, 53, 153} 
\tcbuselibrary{skins} 
\newtcolorbox[auto counter]{myfan}{% empty,
    sharp corners, enhanced, attach boxed title to top left, boxed title style={% empty, left=0pt, right=0pt, frame code ={\draw[line width=.5mm,myblue]([xshift=13mm]frame.north east)--([xshift=15mm]frame.east)-
    -([xshift=13mm]frame.south east);
    \draw[line width=.5mm,myblue]([xshift=14mm]frame.north east)-- ([xshift=16mm]frame.east)--([xshift=14mm]frame.south east); \draw[line width=.5mm,myblue]([xshift=10mm]frame.north east)-- ([xshift=12mm]frame.east)--([xshift=10mm]frame.south east); \draw[line width=.5mm,myblue]([xshift=11mm]frame.north east)-- ([xshift=13mm]frame.east)--([xshift=11mm]frame.south east); }
    }, 
underlay boxed title={%
    \draw[myblue] (title.south east) -- (title.north east)-- ([xshift=4.3ex]title.north east)--([xshift=4.3ex]title.south east)-- (title.south west);
    \path([xshift=2.25ex]title.east)node[inner sep=0pt,text=black]{{\LARGE\fontfamily{bch}\selectfont\thetcbcounter}};
    \fill[fill=myblue](title.south west)--(title.north west)--(title.north east)--(title.south east); },
    frame hidden,
    borderline west={1.5pt}{0pt}{myblue}, 
borderline south={1.5pt}{0pt}{myblue}, colback=white, coltitle=white, title={Exercise}, } 
\begin{document}
    \begin{myfan}
 \begin{enumerate} 
\item Competition at the workplace can be a double-edged sword. \item It definitely keeps us motivated to perform better and to achieve our goals.
    \item However, it can also lead to several negative consequences if not managed correctly. 
\end{enumerate} 
\end{myfan} 
\end{document}

由此我得到了下面的图片:

在此处输入图片描述

答案1

您的问题不清楚,但我认为您想要的是这样的:

在此处输入图片描述

\documentclass[12pt,a4paper]{article} 
\usepackage{tcolorbox} 
\usepackage{amsmath,amssymb}
\xdefinecolor{myblue}{RGB}{102, 53, 153} 
\tcbuselibrary{skins} 

\newtcolorbox[auto counter]{myfan}{% empty,
    sharp corners, enhanced, attach boxed title to top left, 
    boxed title style={% 
        empty, left=0pt, right=0pt, 
        frame code ={
            \foreach \i [evaluate=\i as \ni using \i+2,
                count=\xi from 0, evaluate=\xi as \op using 1-2*\xi/10] in {10,11,12,13}{ 
                \draw[line width=.5mm,myblue, opacity=\op]([xshift=\i mm]frame.north east)--([xshift=\ni mm]frame.east)
                --([xshift=\i mm]frame.south east);}
        }
    }, 
    underlay boxed title={%
        \path([xshift=2.25ex]title.east) node[inner sep=0pt,text=black, font=\Large\fontfamily{bch}] (number) {\thetcbcounter};
        \fill[fill=myblue](title.south west)--(title.north west)--(title.north east)--(title.south east); 
        \draw[myblue, rounded corners=1mm] ([yshift=-.5\pgflinewidth]title.north east) -| ([xshift=2mm]number.east) [sharp corners]|- (title.south west);
},
    frame hidden,
    borderline west={1.5pt}{0pt}{myblue}, 
    borderline south={1.5pt}{0pt}{myblue}, colback=white, coltitle=white, title={Exercise}, 
    overlay={\draw[line width=1.5pt, myblue] (frame.south east)--++(90:5mm);}
    } 

\begin{document}
\begin{myfan}
 \begin{enumerate} 
\item Competition at the workplace can be a double-edged sword. \item It definitely keeps us motivated to perform better and to achieve our goals.
    \item However, it can also lead to several negative consequences if not managed correctly. 
\end{enumerate} 
\end{myfan} 
\end{document}

相关内容