Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

TeX/if

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Synopsis \if <token-1><token-2> <tex-code-1> [\else <tex-code-2>] \fi Description The \if command denotes the start of an if-then-else control structure. The forms <token-1> and <token-2> must expand to tokens. <token-1> and <token-2> can be either a character or a control sequence. If <token-1> and <token-2> both expand to the same character code then <tex-code-1> is processed; otherwise it is ignored. If the \else section is included and <token-1> and <token-2> expand to different character codes, then <tex-code-2> is processed; otherwise it is ignored. A small LaTeX example Here is a small LaTeX example, demonstrating the use of \if. \documentclass{minimal} \begin{document} \ifx\mycmd\undefined undefined \else \if\mycmd1 defined, 1 \else defined \fi \fi \def\mycmd{1} \ifx\mycmd\undefined undefined \else \if\mycmd1 defined, 1 \else defined \fi \fi \def\mycmd{0} \ifx\mycmd\undefined undefined \else \if\mycmd1 defined, 1 \else defined \fi \fi \end{document} This example generates the output: undefined defined, 1 defined