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>;否則忽略。