帮助重现带有装饰的 tcolorbox

帮助重现带有装饰的 tcolorbox

我正在尝试复制这个盒子,但菱形位于椭圆形盒子的右侧。

在此处输入图片描述

我不知道如何创建菱形以及如何以那种方式放置它。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tikz,tikzpagenodes}
\usepackage[most]{tcolorbox}
\usetikzlibrary{calc}
\usetikzlibrary{intersections, patterns}
\tcbuselibrary{skins}
\usepackage{lipsum}
\usepackage{xcolor,etoolbox}



\definecolor{boxcolor}{RGB}{50,232,250}

\newtcbox{\exobox}{on line,
arc=7pt,colback=white!10!white,colframe=boxcolor,
before upper={\rule[-3pt]{0pt}{10pt}},boxrule=2pt,
boxsep=0pt,left=12pt,right=12pt,top=2pt,bottom=2pt}


\begin{document}
\exobox{ See exercise 3}

\end{document}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End:

答案1

您可以使用该形状diamond绘制菱形并将overlay其添加到您的tcolorbox

感谢 Ignasi 指出菱形应该位于右侧。

我已经创建了一些替代方案,请选择您喜欢的那个。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tikz,tikzpagenodes}
\usetikzlibrary{intersections, patterns}
\usetikzlibrary{calc, shapes.geometric}

\usepackage[most]{tcolorbox}
\tcbuselibrary{skins}

\usepackage{lipsum}
\usepackage{etoolbox}

\definecolor{boxcolor}{RGB}{50,232,250}

\newtcbox{\exoboxright}{
    on line,
    arc=7pt,
    colback=white!10!white,
    colframe=boxcolor,
    before upper={\rule[-3pt]{0pt}{10pt}},
    boxrule=2pt,
    boxsep=0pt,
    left=12pt,
    right=12pt,
    top=2pt,
    bottom=2pt,
    enhanced,    
    left skip=10pt,
    overlay={%
     \node[draw, boxcolor, diamond, minimum height=18pt, minimum width=18pt, line width=2pt, fill=white, rounded corners] (mynode) at ([xshift=-2pt]frame.west) {};
     \path[rounded corners, fill=boxcolor] (mynode.north) -- (mynode.west) -- (mynode.south) -- cycle;
     \node[circle, fill=white, inner sep=1.4pt] at ([xshift=6pt]mynode.west) {};
    }
}

\newtcbox{\exoboxleft}{
    on line,
    arc=7pt,
    colback=white!10!white,
    colframe=boxcolor,
    before upper={\rule[-3pt]{0pt}{10pt}},
    boxrule=2pt,
    boxsep=0pt,
    left=12pt,
    right=12pt,
    top=2pt,
    bottom=2pt,
    enhanced,    
    right skip=10pt,
    overlay={%
     \node[draw, boxcolor, diamond, minimum height=18pt, minimum width=18pt, line width=2pt, fill=white, rounded corners] (mynode) at ([xshift=2pt]frame.east) {};
     \path[rounded corners, fill=boxcolor] (mynode.north) -- (mynode.west) -- (mynode.south) -- cycle;
     \node[circle, fill=white, inner sep=1.4pt] at ([xshift=6pt]mynode.west) {};
    }
}

\newtcbox{\exobox}{
    on line,
    arc=7pt,
    colback=white!10!white,
    colframe=boxcolor,
    before upper={\rule[-3pt]{0pt}{10pt}},
    boxrule=2pt,
    boxsep=0pt,
    left=12pt,
    right=12pt,
    top=2pt,
    bottom=2pt,
    enhanced,    
    right skip=10pt,
    overlay={%
     \node[draw, boxcolor, diamond, minimum height=18pt, minimum width=18pt, line width=2pt, fill=white, rounded corners] (mynode) at ([xshift=2pt]frame.east) {};
     \path[rounded corners, fill=boxcolor] (mynode.north) -- (mynode.east) -- (mynode.south) -- cycle;
     \node[circle, fill=white, inner sep=1.4pt] at ([xshift=-6pt]mynode.east) {};
    }
}


\begin{document}
Box with rhombus on the right and decoration mirrored \exobox{See exercise 3}

Box with rhombus on the right \exoboxleft{See exercise 3}

Box with rhombus on the left \exoboxright{See exercise 3}
\end{document}

在此处输入图片描述

相关内容