參數計數器和 ifnum

參數計數器和 ifnum

為什麼這ifnum總是正確的?\@tempcntb是 5,不應該列印\tmp最後一個參數嗎?另外,我不明白m@ne是什麼,因為這肯定不會使計數器前進 1 (它是從嵌套的外部到內部\tmp

\documentclass{article}
\usepackage{color}

\makeatletter
\newcommand\metafunc[1]{{
\count@\z@
Number of arguments: \the\@tempcntb \par
\@tempcnta\z@\relax
\@tempcntb=\count@
\@for\tmp:=#1\do{\advance\count@\@ne}
\ifnum\@tempcnta=\@tempcntb
    \@for\tmp:=#1\do{%
    \advance\@tempcnta\@ne
    \textcolor[RGB]{\the\numexpr255*\@tempcnta/(\count@)\relax,
                 0,
                 \the\numexpr255-(255*\@tempcnta/(\count@))\relax}%
                {\tmp(}}\relax
    \@tempcnta\count@ 
    \@for\tmp:=#1\do{%
    \textcolor[RGB]{\the\numexpr255*\@tempcnta/(\count@)\relax,
                 0,
                 \the\numexpr255-(255*\@tempcnta/(\count@))\relax}%
                {)}\relax
    \advance\@tempcnta\m@ne
}
\else
\@for\tmp:=#1\do{\tmp}
\fi
}}
\makeatother


\begin{document}

\metafunc{Banana,Stool,Another banana,chair,peanut}

\end{document}

相關內容