home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / text / tex / 14559 < prev    next >
Encoding:
Internet Message Format  |  1993-01-02  |  1.8 KB

  1. Path: sparky!uunet!wupost!emory!cs.utk.edu!cs.utk.edu!eijkhout
  2. From: eijkhout@cupid.cs.utk.edu (Victor Eijkhout)
  3. Newsgroups: comp.text.tex
  4. Subject: Re: Embedding \if's in TeX.  How?
  5. Date: 2 Jan 93 14:18:57
  6. Organization: /pearl/homes/eijkhout/.organization
  7. Lines: 43
  8. Message-ID: <EIJKHOUT.93Jan2141857@cupid.cs.utk.edu>
  9. References: <1992Dec27.161533.11392@wam.umd.edu>
  10. NNTP-Posting-Host: cupid.cs.utk.edu
  11. In-reply-to: joel@wam.umd.edu's message of Sun, 27 Dec 1992 16:15:33 GMT
  12.  
  13. In article <1992Dec27.161533.11392@wam.umd.edu> joel@wam.umd.edu (Joel M. Hoffman) writes:
  14.  
  15.    I'd like to embed several \if\else\fi groups, but it doesn't seem to
  16.    work.  For example
  17.  
  18.    \iftesta ...
  19.        \else ...
  20.        \iftestb
  21.            \iftestc ...
  22.            \fi
  23.        \else ...
  24.    \fi
  25.  
  26.    I keep getting error messages about extra \else's.  I'm sure the
  27.    \if's, \else's and \fi's are matches.
  28.  
  29.    I think what's might be happening is that TeX is ignoring the embedded
  30.    \if's if the first test fails, and then seeing the embedding \fi, and
  31.    thinking it matches the matrix \fi.  Is this so?  Is there a
  32.    workaround?
  33.  
  34. This depends on what your \iftest.. are. Did you declare
  35. them with \newif\iftesta? In that case TeX does keep track
  36. of nesting just like you expect it would.
  37.  
  38. However, if you have defined
  39. \def\iftesta#1#2{....... \ifx .....}
  40. or something like that, TeX does not recognize your macro
  41. as a conditional. Is there a work-around for this case? Yes!
  42. In the next Tugboat I was going to mention a trick, devised
  43. by the big K, and which I found in the TeX in Practice book
  44. by Stephan von Bechtolsheim:
  45.     \def\testa{00\fi ..... \ifx ..... }
  46. to be used as
  47.     \if\testa .....
  48. Now TeX will skip such macros, while counting them as conditionals.
  49.  
  50.    -Joel
  51.  
  52. Victor.
  53. --
  54. Victor
  55. ``I have seen this funny quote, if only I could find it back.''
  56.