🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #10057

Re: Math mode in LaTeX

#10057
From: Alan Jeffrey
Date: Mon, 03 Jun 1991 13:04
48 lines
2131 bytes
In article <1991Jun1.193841.1@hmcvax.claremont.edu> dhosek@hmcvax.claremont.edu (Don Hosek) writes:
>
>Alternatively, assign ! a mathcode of "8000. See p.155 of the
>TeXbook for details (so am I the only one who knew about this
>feature?)

Ooops, sorry about that...

>Hmm, I don't think I've ever seen this use of \expandafter
>before. I've more typically said:
>
>\ifwhatever \let\next=\a\else\let\next=\b\fi \next

The problem with doing that is that it doesn't expand in the mouth, so
if you put it inside an \edef (or whatever) you get very weird results
indeed...  I needed this for implementing lists in TeX's mouth
(Tugboat 11(3)) although the technique is someone elses.
Unfortunately I can't remember who's, so if you were that mysterious
TeX hacker in black, please mail me for more credit.

I've been using this technique a lot for coding up boolean expressions
in TeX---define a test to be a macro that expands out to \iftrue or
\iffalse.  Then \truetest and \falsetest are easy:

   \def\truetest{\iftrue}
   \def\falsetest{\iffalse}

negation uses the \expandafter trick:

   \def\nottest#1{#1\expandafter\falsetest\else\expandafter\truetest\fi}

and and or are hacks:

   \def\andtest#1#2{#1\@fi#2}
   \def\@fi{\fi}

   \def\ortest#1{#1\expandafter\K@true\else\expandafter\@identity\fi}
   \def\K@true#1{\iftrue}
   \def\@identity#1{#1}

All improvements welcome...

Alan.


-- 
Alan Jeffrey         Tel: +46 31 72 10 98         jeffrey@cs.chalmers.se
Department of Computer Sciences, Chalmers University, Gothenburg, Sweden
Technical Details
Message-ID: <4650@undis.cs.chalmers.se>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!sunic!chalmers.se!cs.chalmers.se!jeffrey
References: <1991May15.205919.12393@serval.net.wsu.edu> <JEFFT.91May16102428@tailgunner.mit.edu> <1991May28.070140.16324@neon.Stanford.EDU> <4648@undis.cs.chalmers.se> <1991Jun1.193841.1@hmcvax.claremont.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!sunic!chalmers.se!cs.chalmers.se!jeffrey
From: jeffrey@cs.chalmers.se (Alan Jeffrey)
Newsgroups: comp.text.tex
Subject: Re: Math mode in LaTeX
Message-ID: <4650@undis.cs.chalmers.se>
Date: 3 Jun 91 13:04:21 GMT
References: <1991May15.205919.12393@serval.net.wsu.edu> <JEFFT.91May16102428@tailgunner.mit.edu> <1991May28.070140.16324@neon.Stanford.EDU> <4648@undis.cs.chalmers.se> <1991Jun1.193841.1@hmcvax.claremont.edu>
Organization: Dept. of CS, Chalmers, Sweden
Lines: 48