< TeX
Synopsis
\ifx \Macro1 \Macro2 <tex commands> \else <tex commands> \fi
Description
With the \ifx command you can perform conditional compilation by testing for macro equivalence. It does not expand the given macros. The two macros are considered equal if
- both are macros and
- the first level expansion is equal and
- they have the same state with regards to \long and \outer
See also the command \def.
Examples
For example, let's say we define a new macro just to do conditional compilation:
\def \myMacro {}
Then we can use \ifx to check if this macro is defined or not.
\ifx \myMacro \undefined This will be processed if myMacro is not defined. \else This will be processed if myMacro is defined. \fi
See also on the use of this method for testing whether a macro is defined.
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.