软件包 pgfkeys:我不知道密钥“/tcb/O”,我将忽略它

软件包 pgfkeys:我不知道密钥“/tcb/O”,我将忽略它

当我编译此代码时:

\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{tcolorbox,tikz}
\usepackage{lipsum,lmodern}
\usetikzlibrary{calc}
\tcbuselibrary{skins,listings,breakable,poster}


\newtcolorbox[auto counter]{example}[2]{%
    enhanced,
    left skip=1cm,attach boxed title to top text left={yshift=-\tcboxedtitleheight/2,yshifttext=-2mm},
    boxed title style={colframe=#1!40!white,arc=3mm},
    colback=#1!10!white,colframe=#1!10!white,coltitle=black,colbacktitle=#1!10!white,
    fonttitle=\bfseries,
    title=Example,
    underlay boxed title={
        \node [circle,fill=#1!10!white,draw=#1!40!white,inner sep=1pt] (A) at ($(title.west) + (-8mm,0)$){\thetcbcounter};
        \draw[#1!40!white,-{stealth}] (title.west) -- (A) --  (frame.south west-|A);},
        #2
}


\newtcolorbox[auto counter]{sol}[2]
{%
    enhanced,
    left skip=1cm,attach boxed title to top text left={yshift=-\tcboxedtitleheight/2,yshifttext=-2mm},
    boxed title style={colframe=#1!40!white,arc=3mm},
    colback=#1!10!white,colframe=#1!10!white,coltitle=black,colbacktitle=#1!10!white,
    fonttitle=\bfseries,
    title=Solution,
    underlay boxed title={
        \node [circle,fill=#1!10!white,draw=#1!40!white,inner sep=1pt] (A) at ($(title.west) + (-8mm,0)$){\thetcbcounter};
        \draw[#1!40!white,-{stealth}] (title.west) -- (A) --  (frame.south west-|A);},
        #2
}



\begin{document}


\begin{example}{blue}
    Our Example
\end{example}


\begin{sol}{red}
    here is the solution
\end{sol}

\end{document}

抛出此错误:

Package pgfkeys: I do not know the key '/tcb/O' and I am going to ignore it. Perhaps you misspelled it.

Package pgfkeys: I do not know the key '/tcb/h' and I am going to ignore it. Perhaps you misspelled it.

答案1

如果你想使用

\begin{example}{blue}
    Our Example
\end{example}

您的定义应该有一个强制性参数,而不是两个:

\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{tcolorbox,tikz}
\usepackage{lipsum,lmodern}
\usetikzlibrary{calc}
\tcbuselibrary{skins,listings,breakable,poster}


\newtcolorbox[auto counter]{example}[1]{%
    enhanced,
    left skip=1cm,attach boxed title to top text left={yshift=-\tcboxedtitleheight/2,yshifttext=-2mm},
    boxed title style={colframe=#1!40!white,arc=3mm},
    colback=#1!10!white,colframe=#1!10!white,coltitle=black,colbacktitle=#1!10!white,
    fonttitle=\bfseries,
    title=Example,
    underlay boxed title={
        \node [circle,fill=#1!10!white,draw=#1!40!white,inner sep=1pt] (A) at ($(title.west) + (-8mm,0)$){\thetcbcounter};
        \draw[#1!40!white,-{stealth}] (title.west) -- (A) --  (frame.south west-|A);},
%        #2
}


\newtcolorbox[auto counter]{sol}[1]
{%
    enhanced,
    left skip=1cm,attach boxed title to top text left={yshift=-\tcboxedtitleheight/2,yshifttext=-2mm},
    boxed title style={colframe=#1!40!white,arc=3mm},
    colback=#1!10!white,colframe=#1!10!white,coltitle=black,colbacktitle=#1!10!white,
    fonttitle=\bfseries,
    title=Solution,
    underlay boxed title={
        \node [circle,fill=#1!10!white,draw=#1!40!white,inner sep=1pt] (A) at ($(title.west) + (-8mm,0)$){\thetcbcounter};
        \draw[#1!40!white,-{stealth}] (title.west) -- (A) --  (frame.south west-|A);},
%        #2
}



\begin{document}


\begin{example}{blue}
    Our Example
\end{example}


\begin{sol}{red}
    here is the solution
\end{sol}

\end{document}

答案2

根据您编写的代码,您正在使用两个参数定义环境,第二个参数应该是一组附加选项。

但是,该调用在括号中只有一个参数,但 TeX 会寻找另一个参数(忽略空格或结束行),因此它会找到O

解决方案:

\begin{example}{blue}{}
...
\end{example}
\begin{sol}{red}{}
...
\end{sol}

或者从定义中完全删除第二个参数。

相关内容