TeX/ifnum
外观
< TeX
\ifnum <integer-1><R><integer-2> <tex-code-1> [\else <tex-code-2>] \fi
带有值
%A TeX primitive counter: \newcount\countA% \countA=5% %A LaTeX counter: \newcounter{counterB}% \setcounter{counterB}{5}% Lorem ipsum... \makeatletter% c@<countername> can access the integer value of the counter. To use it, @ must be a letter \ifnum\countA=\c@counterB\relax% Text tells you, that both counters are the same.\newpage \else% No new page here. The counters are not the same. \fi% Lorem ipsum...
\ifnum 命令表示一个if-then-else 控制结构的开始。<integer-1> 和 <integer-2> 必须扩展为整数,而 <R> 必须是字符 '=', '<' 或 '>' 之一。如果 <integer-1><R><integer-2> 扩展为真表达式,则处理 <tex-code-1>;否则忽略。如果包含 \else 部分,并且 <integer-1><R><integer-2> 扩展为假表达式,则处理 <tex-code-2>;否则忽略。