Article View: comp.text.tex
Article #9635Re: Embedding \if's in TeX. How?
From: Victor Eijkhout
Date: Sat, 02 Jan 1993 14:18
Date: Sat, 02 Jan 1993 14:18
43 lines
1871 bytes
1871 bytes
In article <1992Dec27.161533.11392@wam.umd.edu> joel@wam.umd.edu (Joel M. Hoffman) writes:
I'd like to embed several \if\else\fi groups, but it doesn't seem to
work. For example
\iftesta ...
\else ...
\iftestb
\iftestc ...
\fi
\else ...
\fi
I keep getting error messages about extra \else's. I'm sure the
\if's, \else's and \fi's are matches.
I think what's might be happening is that TeX is ignoring the embedded
\if's if the first test fails, and then seeing the embedding \fi, and
thinking it matches the matrix \fi. Is this so? Is there a
workaround?
This depends on what your \iftest.. are. Did you declare
them with \newif\iftesta? In that case TeX does keep track
of nesting just like you expect it would.
However, if you have defined
\def\iftesta#1#2{....... \ifx .....}
or something like that, TeX does not recognize your macro
as a conditional. Is there a work-around for this case? Yes!
In the next Tugboat I was going to mention a trick, devised
by the big K, and which I found in the TeX in Practice book
by Stephan von Bechtolsheim:
\def\testa{00\fi ..... \ifx ..... }
to be used as
\if\testa .....
Now TeX will skip such macros, while counting them as conditionals.
-Joel
Victor.
--
Victor
``I have seen this funny quote, if only I could find it back.''
Technical Details
Message-ID:
<EIJKHOUT.93Jan2141857@cupid.cs.utk.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!wupost!emory!cs.utk.edu!cs.utk.edu!eijkhoutReferences:
<1992Dec27.161533.11392@wam.umd.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!emory!cs.utk.edu!cs.utk.edu!eijkhout From: eijkhout@cupid.cs.utk.edu (Victor Eijkhout) Newsgroups: comp.text.tex Subject: Re: Embedding \if's in TeX. How? Date: 2 Jan 93 14:18:57 Organization: /pearl/homes/eijkhout/.organization Lines: 43 Message-ID: <EIJKHOUT.93Jan2141857@cupid.cs.utk.edu> References: <1992Dec27.161533.11392@wam.umd.edu> NNTP-Posting-Host: cupid.cs.utk.edu In-reply-to: joel@wam.umd.edu's message of Sun, 27 Dec 1992 16:15:33 GMT