Path: utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!cs.utexas.edu!uwm.edu!rpi!dali.cs.montana.edu!uakari.primate.wisc.edu!unmvax!pprg.unm.edu!topgun!mustang!nntp-server.caltech.edu!news From: marcel@cs.caltech.edu (Marcel van der Goot) Newsgroups: comp.text.tex Subject: Re: #ifdef equivalent of selective inclusion for TeX/LaTeX??? Message-ID: <1990Oct22.081716.22423@nntp-server.caltech.edu> Date: 22 Oct 90 08:17:16 GMT References: <1990Oct18.021309.22918@cs.umn.edu> <40303@shemp.CS.UCLA.EDU> Sender: news@nntp-server.caltech.edu Reply-To: marcel@cs.caltech.edu Organization: California Institute of Technology (CS dept) Lines: 30 Nntp-Posting-Host: stun3b.caltech.edu In <40303@shemp.CS.UCLA.EDU> Paul Kirkaas (kirkaas@ewa.cs.ucla.edu) wonders > I wonder if there is an equivalent to C's "#ifdef" for TeX --- > that is, if there is something like: > ... Testing whether a control sequence \cs is defined is quite easy: \ifx\cs\undefined % \cs is not defined \else % \cs is defined \fi where you should make sure that \undefined is never defined. This works because both \cs and \undefined are macros (at least, according to TeX they cannot be anything else), and, if \cs is not defined, they both have the same top-level "expansion" (namely, none), so that \ifx tests true. The only thing you need to worry about is that if you insert commands in the place of the comments above, they must have properly nested \if ... \fi pairs. This method (trick?) comes straight from the TeX-book, the last paragraph of section 4: selective loading of macros, in appendix D (p. 384). Marcel van der Goot marcel@vlsi.cs.caltech.edu