home *** CD-ROM | disk | FTP | other *** search
- 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
- From: hsg@cs.bham.ac.uk (Howard S. Goodman)
- Newsgroups: comp.text.tex
- Subject: Plain TeX: tab characters within macro definitions
- Message-ID: <BxnFFt.6Gy@cs.bham.ac.uk>
- Date: 13 Nov 92 09:52:41 GMT
- Sender: news@cs.bham.ac.uk
- Organization: School of Computer Science, University of Birmingham, England
- Lines: 66
- Originator: hsg@mopsy
- Nntp-Posting-Host: mopsy
-
- In comp.text.tex I wrote:
-
- > A question: why does this work
- >
- > \let\\=\cr
- > \def\by #1\\{\hbox{by #1}\noexpand\cr}
- > $$\eqalignno{[1] &\Rightarrow x < z &\by transitivity of $<$ \\
- > &\Rightarrow (x:xs) \leq (z:zs) &\by definition \\}$$
- >
- > when this doesn't
- >
- > \let\\=\cr
- > \def\by #1\\{&\hbox{by #1}\noexpand\cr}
- > $$\eqalignno{[1] &\Rightarrow x < z \by transitivity of $<$ \\
- > &\Rightarrow (x:xs) \leq (z:zs) \by definition \\}$$
- >
- > ?
-
- Thank you to <nakasima@kuis.kyoto-u.ac.jp> for the following reply:
-
- > Huh, this is a very hard question. First of all, \noexpand
- > in \by seems to has no effect. Without \noexpand, the first
- > example works and the second doesn't with same error, and
- > the trace of the first one shows that TeX found \cr in \by
- > normally.
- >
- > Well, the difference between two cases is that \by in the
- > first is invoked just after &, while is not in the second
- > case. As you probably know, TeX's macro expansion mechanism
- > in a row for alignment is affected by the condition whether
- > a macro directly follows & or not. If a macro appears just
- > after &, TeX expands it until a non-blank non-expandable
- > token is found, in order to check whether the token is
- > \omit. Otherwise, TeX expands macro normally.
- >
- > The argument reading process is also different. As you
- > know, & and \cr act as }{ in some sense. In the latter
- > (normal) case, TeX reads the argument of \by and finds \\
- > (\let equal to \cr) and complains;
- >
- > ! Argument of \by has an extra }.
- >
- > because it looks like;
- >
- > \by transitivity of $x$}{
- >
- > for TeX. In the former case (just after &), TeX seems to
- > read the argument as if it is not in alignment. Thus, \\ is
- > not assumed as }{, and \by works well.
- >
- > Then, what is the solution to make \by with & work well?
- > The solution is;
- >
- > \def\by{&\BY}
- > \def\BY#1\\{\hbox{by #1}\cr}
- >
- > O.K.?
- > -----------------------------------------------------------------
- > Hiroshi Nakashima (nakasima@kuis.kyoto-u.ac.jp)
- > Dept. of Information Science, Faculty of Engineering, Kyoto Univ.
- > Yoshida Hon-Machi, Kyoto, 606-01 Japan. phone:+75-753-5383
-
- +--------------------+--------------------------------------------------------+
- | howard s goodman | school of computer science - university of birmingham |
- | hsg@cs.bham.ac.uk | - BIRMINGHAM - B15 2TT - england |
- +--------------------+--------------------------------------------------------+
-