将“计算器”软件包中的操作应用于条件数值
我正在编写一个类似于电子表格的乳胶模板:一个定义了少量变量,并且整个文档进行了相应的调整。
我有三个变量:<代码>级别,pricitybenus
和CommuniceScore
。这是我的MWE:
\documentclass{article}
\usepackage{ifthen}
\usepackage{calculator}
\begin{document}
\newcommand\Level{3}
\newcommand\ProficiencyBonus{%
\ifthenelse{\Level<5}{2}{3}%
}
\newcommand\AbilityScore{%
\ADD{\ProficiencyBonus}{10}{\TMP}%
\TMP%
}
Level: \Level \\
Proficiency Bonus: \ProficiencyBonus \\
Ability Score: \AbilityScore
\end{document}
此片段在加法过程中产生和错误:
Missing number, treated as zero.
Illegal unit of measure (pt inserted).
我怀疑\ ifthenelse
以某种方式不返回“纯”数字(是否有“无形”附加令牌?)。但是,我不知道如何调试这个问题:我尝试使用ifthenelse
使用\ show> \ show
和\含义<含义< /代码>。
我感谢任何解决此问题的帮助,或者向我展示如何调试这种情况。
(我使用Xelatex,但此错误也出现在正常的乳胶中。)
I'm writing a LaTeX template that works similar to a spreadsheet: One defines a small number of variables and the whole document is adjusted accordingly.
I have three variables: Level
, ProficiencyBonus
and AbilityScore
. Here is my MWE:
\documentclass{article}
\usepackage{ifthen}
\usepackage{calculator}
\begin{document}
\newcommand\Level{3}
\newcommand\ProficiencyBonus{%
\ifthenelse{\Level<5}{2}{3}%
}
\newcommand\AbilityScore{%
\ADD{\ProficiencyBonus}{10}{\TMP}%
\TMP%
}
Level: \Level \\
Proficiency Bonus: \ProficiencyBonus \\
Ability Score: \AbilityScore
\end{document}
This snippet produces and error during the addition:
Missing number, treated as zero.
Illegal unit of measure (pt inserted).
I suspect that \ifthenelse
somehow doesn't return the "pure" number (are there "invisible" additional tokens?). However, I don't know how to debug this problem: I tried unsuccessfully to gain insight in the return value of \ifthenelse
using \show
and \meaning
.
I'd appreciate any help that either solves this problem or shows me how to debug such a situation.
(I use XeLaTeX but this error appears also with normal LaTeX.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
\ ifnum
进行测试:You can use
\ifnum
for your test: