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: TeX and marks Keywords: mark Message-ID: <1990Oct22.075424.22214@nntp-server.caltech.edu> Date: 22 Oct 90 07:54:24 GMT References: <41700@eerie.acsu.Buffalo.EDU> Sender: news@nntp-server.caltech.edu Reply-To: marcel@cs.caltech.edu Organization: California Institute of Technology (CS dept) Lines: 41 Nntp-Posting-Host: stun3b.caltech.edu In <41700@eerie.acsu.Buffalo.EDU> Mary Deck (mdeck@sybil.cs.Buffalo.EDU) writes > ... It *really* surprised me to find out that \if\topmark\topmark, > \if\firstmark\firstmark, and \if\botmark\botmark are rarely true. > (What?!?! Something doesn't equal itself?!?!) ... The answer is actually simpler than the question suggests, no trickery with marks is involved. As an experiment, try to run the following through TeX: \def\a{xxyz} \def\b{pqr} \message{*\if\a\b\else false\fi*} You'll see that the message that is printed is "*yzpqr*", although certainly \a and \b are different. The reason is that \if expands tokens until two unexpandable tokens are found. In this case, \a is expanded which gives the two unexpandable tokens "x" and "x", which compare equal. The of the \if is then "yz\b" (TeX book, p. 209). \topmark etc. expand just like macros (p. 213), so if you use \if to compare them you are actually comparing something entirely different. To test things without expanding them, you usually use \ifx instead of \if. That would work for the above example with \a and \b, but not with \botmark etc., because the latter are primitives, not macros (hence, \ifx\firstmark\botmark is always false, regardless of the marks). The solution is to first assign the expansion to a macro, using \edef: \edef\first{\firstmark} \edef\bot{\botmark} \ifx\first\bot % \firstmark and \botmark have equal values \else % \firstmark and \botmark have different values \fi Marcel van der Goot marcel@vlsi.cs.caltech.edu