step and label={tcbthm}{#3}
改成 step={tcbthm}, IfBlankF={#3}{label={#3}}
。
你这个代码问题太多了,为什么要先定义 wwtheorem,再定义一个 theorem 呢,直接用 \NewTColorBox
就行了,再加上 before pre=\smallskip, after app=\smallskip
,或者用环境钩子。
还有,应该这么写 \begin{wwtheorem}[#1]{#2}{#3}
。
还有 wwtheorem
的定义里,#1
前面没有加上逗号。
MWE:
\documentclass{ctexart}
\usepackage{xcolor}
\colorlet{nuanbai}{gray!1}
\usepackage{ninecolors}
\usepackage{tikz}
\usetikzlibrary{calc,shadows}
\usepackage[many]{tcolorbox}
\tcbuselibrary{breakable,xparse} % 旧版本要 xparse
\newcounter{tcbthm}
\def\tcbthmautorefname{\bf 定理}
\newcommand{\Theorem}{定理}
\NewTColorBox{theorem}{O{} O{} o}
{arc=3pt,breakable,enhanced,colback=nuanbai,boxrule=0pt,top=8mm,
fuzzy shadow={-0.6mm}{0.6mm}{0mm}{0.3mm}{white!50!gray},% 上
fuzzy shadow={0.6mm}{-0.6mm}{0mm}{0.3mm}{fill=white!40!gray},%下
opacityframe=0, opacityback=0.98,
fontupper=\itshape, step={tcbthm}, IfNoValueF={#3}{label={#3}},
before pre=\smallskip, after app=\smallskip,
overlay unbroken = {
\fill[black!60] ([xshift=1cm,yshift=5pt]frame.north west)-- ([xshift=0.8cm,yshift=0cm]frame.north west)--([xshift=1.2cm,yshift=0cm]frame.north west)--cycle;
%标题 %更改有效
\node[rectangle,
text=white, drop shadow={opacity=.3, shadow xshift=0.1cm},
inner sep=1.5mm,fill=purple5,
anchor=west,rounded corners=3pt,
font=\normalsize] at ([xshift=0cm,yshift=-3.mm]frame.north west)%
{\phantom{\rule{1.2em}{0pt}}\bf \Theorem\ \thetcbthm.~#2};
\fill[color=purple5,drop shadow={opacity=0.3,shadow xshift=.3pt}]
([xshift=1cm,yshift=5pt]frame.north west) {[rounded corners=3pt]--++(-1cm-5pt,0)}--++(0,-1cm-5pt)--cycle;
\fill[color=black!60] ([xshift=-5pt,yshift=-1cm]frame.north west)--([xshift=0cm,yshift=-0.8cm]frame.north west)-- ([xshift=0cm,yshift=-1.2cm]frame.north west)--cycle;
%%============================%% End
\fill[purple5,drop shadow={opacity=0.3,shadow xshift=-0.008\linewidth,shadow yshift=0.0016\linewidth}]
([xshift=-0.05\linewidth,yshift=-5pt]frame.south east) {[rounded corners=3pt]--++(0.05\linewidth+5pt,0)}--++(0,0.05\linewidth+5pt)--cycle;
\fill[black!60] ([xshift=-0.05\linewidth,yshift=-5pt]frame.south east) -- ([xshift=-0.04\linewidth,yshift=0pt]frame.south east)-- ([xshift=-0.06\linewidth,yshift=0pt]frame.south east)--cycle;
\fill[black!60] ([xshift=5pt,yshift=0.05\linewidth]frame.south east)-- ([yshift=0.04\linewidth]frame.south east) -- ([yshift=0.06\linewidth]frame.south east)--cycle;
},%上面是实际控制代码,下面的代码仅在跨页分割时生效
overlay first = {%跨页时生效
\fill[black!60] ([xshift=1cm,yshift=5pt]frame.north west)-- ([xshift=0.8cm,yshift=0cm]frame.north west)--([xshift=1.2cm,yshift=0cm]frame.north west)--cycle;
%标题 %跨页时生效
\node[rectangle,
text=white, drop shadow={opacity=.3, shadow xshift=0.1cm},
inner sep=1.5mm,fill=purple5,
anchor=west,rounded corners=3pt,
font=\normalsize] at ([xshift=0cm,yshift=-3.mm]frame.north west)%
{\phantom{\rule{1.2em}{0pt}}\bf \Theorem\ \thetcbthm.~#2};
\fill[color=purple5,drop shadow={opacity=0.3,shadow xshift=.3pt}]
([xshift=1cm,yshift=5pt]frame.north west) {[rounded corners=3pt]--++(-1cm-5pt,0)}--++(0,-1cm-5pt)--cycle;
\fill[color=black!60] ([xshift=-5pt,yshift=-1cm]frame.north west)--([xshift=0cm,yshift=-0.8cm]frame.north west)-- ([xshift=0cm,yshift=-1.2cm]frame.north west)--cycle;
},%保持边缘的变化
overlay last = {%跨页时生效
%%============================%% End
\fill[purple5,drop shadow={opacity=0.3,shadow xshift=-0.008\linewidth,shadow yshift=0.0016\linewidth}]
([xshift=-0.05\linewidth,yshift=-5pt]frame.south east) {[rounded corners=3pt]--++(0.05\linewidth+5pt,0)}--++(0,0.05\linewidth+5pt)--cycle;
\fill[black!60] ([xshift=-0.05\linewidth,yshift=-5pt]frame.south east) -- ([xshift=-0.04\linewidth,yshift=0pt]frame.south east)-- ([xshift=-0.06\linewidth,yshift=0pt]frame.south east)--cycle;
\fill[black!60] ([xshift=5pt,yshift=0.05\linewidth]frame.south east)-- ([yshift=0.04\linewidth]frame.south east) -- ([yshift=0.06\linewidth]frame.south east)--cycle;
},
#1}
\begin{document}
\begin{theorem}%[][][],三个可选参数,第一个是键值,第二个是标题,第三个是 label
测试1
\end{theorem}
\begin{theorem}
测试2
\end{theorem}
\end{document}
问 请问如何修改代码来避免下图中的警告?