tcbset 错误,带有可选颜色参数和“附加盒装标题”

tcbset 错误,带有可选颜色参数和“附加盒装标题”

tcolorbox我在涉及tcbsetnewtcbtheorem可选颜色参数和时遇到问题attach boxed title to ...。错误如下:

Package xcolor Error: Undefined color `visible'.

以下是示例代码:

\documentclass[a4paper, 11pt]{report}
\usepackage[many]{tcolorbox}

\tcbset{
    titlebox/.style={
        colframe=#1!50!white,
        attach boxed title to top left,
    }
}

\newtcbtheorem[number within=section]%
{theo}
{Théorème}
{titlebox=red}
{theo}

\begin{document}

\begin{theo}{Test}{}
Test.
\end{theo}

\end{document}

我不知道为什么会发生这种情况。如果有人知道,请告诉我。提前谢谢 :)

答案1

titlebox 是 tcolorbox 的已知键。通过覆盖它,您会混淆代码。您还缺少增强键。

\documentclass[a4paper, 11pt]{report}
\usepackage[many]{tcolorbox}

\tcbset{
    mytitlebox/.style={
        enhanced,
        colframe=#1!50!white,
        attach boxed title to top left,
    }
}

\newtcbtheorem[number within=section]%
{theo}
{Théorème}
{mytitlebox=red}
{theo}

\begin{document}

\begin{theo}[title=Title]{Test}{xxx}
Test.
\end{theo}

\end{document}

相关内容