home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / text / tex / 13255 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  2.9 KB

  1. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!doc.ic.ac.uk!uknet!news.cs.bham.ac.uk!hsg
  2. From: hsg@cs.bham.ac.uk (Howard S. Goodman)
  3. Newsgroups: comp.text.tex
  4. Subject: Plain TeX: tab characters within macro definitions
  5. Message-ID: <BxnFFt.6Gy@cs.bham.ac.uk>
  6. Date: 13 Nov 92 09:52:41 GMT
  7. Sender: news@cs.bham.ac.uk
  8. Organization: School of Computer Science, University of Birmingham, England
  9. Lines: 66
  10. Originator: hsg@mopsy
  11. Nntp-Posting-Host: mopsy
  12.  
  13. In comp.text.tex I wrote:
  14.  
  15. > A question: why does this work
  16. >     \let\\=\cr
  17. >     \def\by #1\\{\hbox{by #1}\noexpand\cr}
  18. >     $$\eqalignno{[1] &\Rightarrow x < z    &\by transitivity of $<$ \\
  19. >       &\Rightarrow (x:xs) \leq (z:zs)    &\by definition \\}$$
  20. > when this doesn't
  21. >     \let\\=\cr
  22. >     \def\by #1\\{&\hbox{by #1}\noexpand\cr}
  23. >     $$\eqalignno{[1] &\Rightarrow x < z    \by transitivity of $<$ \\
  24. >       &\Rightarrow (x:xs) \leq (z:zs)    \by definition \\}$$
  25. > ?
  26.  
  27. Thank you to <nakasima@kuis.kyoto-u.ac.jp> for the following reply:
  28.  
  29. > Huh, this is a very hard question.  First of all, \noexpand
  30. > in \by seems to has no effect.  Without \noexpand, the first
  31. > example works and the second doesn't with same error, and
  32. > the trace of the first one shows that TeX found \cr in \by
  33. > normally.
  34. > Well, the difference between two cases is that \by in the
  35. > first is invoked just after &, while is not in the second
  36. > case.  As you probably know, TeX's macro expansion mechanism
  37. > in a row for alignment is affected by the condition whether
  38. > a macro directly follows & or not.  If a macro appears just
  39. > after &, TeX expands it until a non-blank non-expandable
  40. > token is found, in order to check whether the token is
  41. > \omit.  Otherwise, TeX expands macro normally.
  42. > The argument reading process is also different.  As you
  43. > know, & and \cr act as }{ in some sense. In the latter
  44. > (normal) case, TeX reads the argument of \by and finds \\
  45. > (\let equal to \cr) and complains;
  46. >     ! Argument of \by has an extra }.
  47. > because it looks like;
  48. >     \by transitivity of $x$}{
  49. > for TeX.  In the former case (just after &), TeX seems to
  50. > read the argument as if it is not in alignment.  Thus, \\ is
  51. > not assumed as }{, and \by works well.
  52. > Then, what is the solution to make \by with & work well?
  53. > The solution is;
  54. >     \def\by{&\BY}
  55. >     \def\BY#1\\{\hbox{by #1}\cr}
  56. > O.K.?
  57. > -----------------------------------------------------------------
  58. > Hiroshi Nakashima (nakasima@kuis.kyoto-u.ac.jp)
  59. > Dept. of Information Science, Faculty of Engineering, Kyoto Univ.
  60. > Yoshida Hon-Machi, Kyoto, 606-01 Japan.        phone:+75-753-5383
  61.  
  62. +--------------------+--------------------------------------------------------+
  63. | howard s goodman   |  school of computer science - university of birmingham |
  64. | hsg@cs.bham.ac.uk  |                 - BIRMINGHAM - B15 2TT - england |
  65. +--------------------+--------------------------------------------------------+
  66.