TeX/ifnum
Appearance
< TeX
Synopsis
[edit | edit source]\ifnum <integer-1><R><integer-2> <tex-code-1> [\else <tex-code-2>] \fi
With values:
%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...
Description
[edit | edit source]The \ifnum command denotes the start of an if-then-else control structure. The forms <integer-1> and <integer-2> must expand to integers while <R> must be one of the characters '=', '<', or '>'. If <integer-1><R><integer-2> expands to a true expression then <tex-code-1> is processed; otherwise it is ignored. If the \else section is included and <integer-1><R><integer-2> expands to a false expression, then <tex-code-2> is processed; otherwise it is ignored.