2
我有問題使用自動生成的Tex字符串在需要數字值的參數中(例如在ifthenelse比較中)。下面是一個示例最少的代碼:轉換TEX字符串中的Tex字符串
\newcommand\testC{123}
\ifthenelse{\testC<0}{negative}{positive} % works fine !
\newcommand{\testD}{\luaexec{tex.write("123")}} % write to avoid the print carriage return - produces also 123 as \testC
\testD % prompt 132 just as \testC "apparently"
\ifthenelse{\testD<0}{negative}{positive} % error "! Missing number, treated as zero"
\newcounter{compteur}
\setcounter{compteur}{\testD} % error "! Missing number, treated as zero"
\ifthenelse{\thecompteur<0}{negative}{positive}
我不能找到一種方法,從字符串轉換爲接受的算術比較(等操作)的數字。