可破坏的 tcolorbox 改变背景颜色

可破坏的 tcolorbox 改变背景颜色

我正在tcolorbox用该选项设计一些 es breakable,以前我用过几次,但是现在它似乎不能像往常一样工作(breakable选项会更改背景颜色并禁用drop fuzzy shadow选项)

正常使用:

在此处输入图片描述

关于新的分页符:

在此处输入图片描述

梅威瑟:

\documentclass[a4paper, oneside]{book}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[spanish,activeacute]{babel}
\usepackage[usenames,dvipsnames]{xcolor}

\usepackage{tcolorbox}
\tcbuselibrary{theorems, skins, breakable}
\colorlet{naranja}{Peach!70!}
\newcounter{ejemplo}

\tcbset{
    base/.style={
        empty, breakable,
        fonttitle=\bfseries\sffamily,
        fontupper=\normalsize\slshape,
        theorem style=standard,
        separator sign={},
        frame engine=path,
        colframe=yellow!10,
        drop fuzzy shadow,
        sharp corners,
        attach boxed title to top left={yshift*=-\tcboxedtitleheight},
        boxed title style={size=minimal, top=4pt, left=4pt},
        after skip=0.5cm, before skip balanced=0.5cm
    }
}

\newtcbtheorem[number within=chapter]{ejem}{Ejemplo}{
    base, coltitle=black,
    attach boxed title to top left={xshift=-3mm, yshift*=-\tcboxedtitleheight/2},
    boxed title style={right=3pt, bottom=3pt, overlay={
            \draw[draw=naranja, fill=naranja, line join=round]
            (frame.south west) -- (frame.north west) -- (frame.north east) --
            (frame.south east) -- cycle;
    }},
    overlay unbroken={
        \scoped \shade[left color=naranja!10!black, right color=naranja]
        ([yshift=-0.2pt]title.south west) -- ([xshift=-1.5pt, yshift=-0.2pt]title.south-|frame.west) -- ++(0, -6pt) -- cycle;
    }
}{ejem}

\usepackage{lipsum}
\begin{document}
    
\lipsum[1]

\begin{ejem}{}{}
    \lipsum[1] \\\\
    \lipsum[2]\\\\
    \lipsum[1]
\end{ejem}

\end{document}

我曾尝试使用选项+colback来代替(我认为这是错误的根源),但没有效果。frame engine=pathcolframe

答案1

您需要的extras={frame engine=path}不仅仅是frame engine=path

绘图引擎选项很特殊。它们会根据指定的皮肤(在您的示例中,皮肤为empty)针对每个破损的破损序列框进行(重新)设置。因此,frame engine=path只有当框未破损时,您的设置才会生效。要更改破损序列的每个框的绘图引擎,无论破损与否,您都需要extras={<options>}

tcolorbox请参阅软件包手册 (v5.1.1) 第 19.5 节“部分盒子的额外选项”中的更多信息。

\documentclass[a4paper, oneside]{book}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[spanish,activeacute]{babel}
\usepackage[usenames,dvipsnames]{xcolor}

\usepackage{tcolorbox}
\tcbuselibrary{theorems, skins, breakable}
\colorlet{naranja}{Peach!70!}
\newcounter{ejemplo}

\tcbset{
    base/.style={
        empty, breakable,
        fonttitle=\bfseries\sffamily,
        fontupper=\normalsize\slshape,
        theorem style=standard,
        separator sign={},
        extras={frame engine=path},
        colframe=yellow!10,
        drop fuzzy shadow,
        sharp corners,
        attach boxed title to top left={yshift*=-\tcboxedtitleheight},
        boxed title style={size=minimal, top=4pt, left=4pt},
        after skip=0.5cm, before skip balanced=0.5cm
    }
}

\newtcbtheorem[number within=chapter]{ejem}{Ejemplo}{
    base, coltitle=black,
    attach boxed title to top left={xshift=-3mm, yshift*=-\tcboxedtitleheight/2},
    boxed title style={right=3pt, bottom=3pt, overlay={
            \draw[draw=naranja, fill=naranja, line join=round]
            (frame.south west) -- (frame.north west) -- (frame.north east) --
            (frame.south east) -- cycle;
    }},
    overlay unbroken={
        \scoped \shade[left color=naranja!10!black, right color=naranja]
        ([yshift=-0.2pt]title.south west) -- ([xshift=-1.5pt, yshift=-0.2pt]title.south-|frame.west) -- ++(0, -6pt) -- cycle;
    }
}{ejem}

\usepackage{lipsum}
\begin{document}
    
\lipsum[1]

\begin{ejem}{}{}
    \lipsum[1]
\end{ejem}

\begin{ejem}{}{}
    \lipsum[2]\\\\
    \lipsum[1]
\end{ejem}

\end{document}

在此处输入图片描述

相关内容