Article View: net.text
Article #734Re: Weird TeX behaviour
From: Brendan McKay
Date: Sat, 18 Jan 1986 05:48
Date: Sat, 18 Jan 1986 05:48
38 lines
2262 bytes
2262 bytes
In article <777@lasspvax.UUCP>, garry@lasspvax.UUCP (Garry Wiegand) writes:
>
> A TeXnical question: [ edited by bdm ]
>
> \newskip \A
>
> \A = 8pt \ifdim \A > 2pt \A = 2pt \fi \showthe \A % answer is '8'!!!
> \A = 8pt \ifdim \A > 2pt \A = 2pt \fi \showthe \A % answer is '2'!!!
>
The explanation goes something like this:
When TeX has read the first "\A = 8pt" it doesn't know the assignment has
finished yet (it might continue "plus 3pt" or something). So it has to
expand the \ifdim ... \fi. \A hasn't yet had it's value changed from the
initial 0pt, so the \ifdim ... \fi expands to nothing. TeX now sees the
\showthe, realises the <dimen> has finished, assigns "8pt plus0pt minus0pt"
to \A and processes the \showthe. It DOESN'T reevaluate the \ifdim ... \fi.
On the next line, the \ifdim ... \fi expands to "\A = 2pt " so TeX altogether
sees "\A = 8pt \A = 2pt \showthe \A".
This behaviour may be counter-intuitive, but it's not a bug. Equally weird
behaviour would be possible if the rules were changed to specify re-evaluation
of the \ifdim ... \fi. Consider this one under both possibilitities:
\newskip \X \X = 8pt \ifdim \X > 2pt plus 1pt \fi \relax .
The solution is to insert \relax after the 8pt.
Brendan McKay.
Computer Science Dept., Australian National University, GPO Box 4, Canberra,
ACT 2601, Australia.
ACSnet: bdm@anucsd.anu.oz ARPA: bdm%anucsd.anu.oz@seismo
CSNET: bdm@anucsd.anu.oz@csnet-relay.csnet JANET: anucsd.anu.oz!bdm@ukc
UUCP: {decvax,vax135,pesnta,eagle}!mulga!anucsd.anu.oz!bdm
{seismo,ubc-vision,ukc,mcvax,prlb2}!munnari!anucsd.anu.oz!bdm
[ UUCP routes through munnari prefered ]
Technical Details
Message-ID:
<195@ra.anu.OZ>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!munnari!basser!ra!bdmReferences:
<777@lasspvax.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!munnari!basser!ra!bdm From: bdm@ra.anu.OZ (Brendan McKay) Newsgroups: net.text Subject: Re: Weird TeX behaviour Message-ID: <195@ra.anu.OZ> Date: Sat, 18-Jan-86 00:48:48 EST Article-I.D.: ra.195 Posted: Sat Jan 18 00:48:48 1986 Date-Received: Tue, 21-Jan-86 01:15:13 EST References: <777@lasspvax.UUCP> Organization: Computer Science, Australian National Uni, Canberra Lines: 38 Summary: reason for the problem noted