\ifnum 用于 datatool 包

\ifnum 用于 datatool 包

我正在尝试写引号,并且根据所选的“男性”,它需要更改输出。不幸的是,在下面的例子中,它给了我2跳过虽然它应该给我2名男性。 我究竟做错了什么?


\usepackage{datatool}

\begin{filecontents*}{excel.csv}
included,givenname,matriculation,gender,grade
Maier,Hans,12345,m,1.0
Huber,Anna,23456,f,2.3
Weisbaeck,Werner,34567,m,5.0
\end{filecontents*}

\DTLloaddb{CounterO}{excel.csv}

\begin{document}

\begin{tabular}{lccc}
\DTLforeach*[\DTLiseq{\gn}{m}]{CounterO}%
    {\gn=gender}
    {%
        \DTLiffirstrow{}{\\}
    } 
\end{tabular}

\newcommand{\CounterA}{\DTLsavelastrowcount{\CounterI{}}}
\CounterA
\ifnum \CounterA > 1
males
\else
    \ifnum \CounterA = 1
    male
    \else
    skip
    \fi
\fi

\end{document}

答案1

你的测试需要针对\CounterI,而不是\CounterA

% ...
\newcommand{\CounterA}{\DTLsavelastrowcount{\CounterI}}
\CounterA
\CounterI\space
\ifnum\CounterI=0
  skip%
\else
  male\ifnum\CounterI>1 s\fi
\fi

相关内容