LaTeX で tikzpicture を使用しているときに認識されないコマンド

LaTeX で tikzpicture を使用しているときに認識されないコマンド

ピラミッド図をコンパイルしているときに、認識されないコマンドがポップアップ表示されます。原因は何ですか。また、どうすれば解決できますか。

下の写真をご覧ください:

\begin{figure}[!h]
    \centering
\tikzset{tri/.style={%
                        regular polygon,
                        regular polygon sides=3, %% For fun, vary this number at will
                        minimum size=#1,
                        draw,
                        thick,
                        anchor=north
                    },
                    ptext/.style={font=\bfseries,align=center,text width=0.8*\pyrsize}
        }

    \NewDocumentCommand{\pyramid}{sO{}mm}{% #3 size; #4 entries
    \begin{tikzpicture}
        \pgfmathsetmacro{\incrrate}{0.80}% The rate at which the triangles decrease in size
        \coordinate (T) at (0,0);
        \foreach \test/\testi [count=\testnum from 1] in {#4}{\xdef\tot{\testnum}}%
        \pgfmathsetmacro{\incr}{#3/\tot}
        \foreach \step/\col [count=\stepnum from 0] in {#4}{%
            \pgfmathsetlengthmacro{\pyrsize}{#3-\incrrate*\stepnum*\incr}
            \node[tri=\pyrsize,fill=\col] (T\stepnum) at (T) {};
            \ifnum\stepnum=\numexpr\tot-1\relax
            \pgfmathsetlengthmacro{\lift}{0.0*\incr*\incrrate}% raise text in top shape
            \else
            \pgfmathsetlengthmacro{\lift}{0.1*\incr*\incrrate}% raise text in remaining shapes
            \fi
            \node[above=\lift of T\stepnum.south,ptext] {\step\strut};
        }%
    \end{tikzpicture}%
}
    
    \pyramid{3.0in}{Inner control/green, Primery Control/olive, Secondary control/yellow, Tertiary\\control/orange}

\end{figure}

ここに画像の説明を入力してください

関連情報