Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!spool2.mu.edu!samsung!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!jhunix!jeburke From: jeburke@jhunix.HCF.JHU.EDU (John Burke) Newsgroups: comp.text.tex Subject: Re: Strange result in macros Summary: Not so strange after all Keywords: simple parameters Message-ID: <7403@jhunix.HCF.JHU.EDU> Date: 24 Jan 91 14:43:49 GMT Expires: 31 Jan 91 00:00:00 GMT References: <1991Jan24.095405.8868@uni-paderborn.de> Followup-To: comp.text.tex Organization: The Johns Hopkins University - HCF Lines: 43 In article <1991Jan24.095405.8868@uni-paderborn.de> elmar@pbinfo.UUCP (Elmar Schalueck) writes: >% I discovered a beautiful difference in macros depending >% on the position of the left braces after the macroname. >% Is this a desired effect and how can I make use of it to apply >% macros to whole words that are not surrounded by braces? >% >% Greetings and have some fun with the example below >% >% Elmar Schal\"{u}ck elmar@uni-paderborn.de >% >% >\documentstyle{article} >\begin{document} >\long\def\foo#1 >{Hurrah #1 Hurrah} >\long\def\gnat#1{Yippee #1 Yippee} >Now I test \foo{Why} and \gnat{Why not?} and everything's ok. > >But watch out for the difference to \foo{Me}-too and \gnat{You}-never. >\end{document} From _The TeXbook_, p. 201 (of my copy, anyway, pre-3.0): Caution: When you define a macro with simple parameters, as in these examples, you must be careful not to put blank spaces before the '{' that begins the replacement text. For example, '\def\row #1 #2 {...}' will not give the same result as '\def\row#1#2{...}', becuase the spaces after #1 and #2 tell TeX to look for arguments that are followed by spaces. (Arguments can be "delimited" in a fairly general way, as explained below.) But the space after \row is optional, as usual, becuase TeX always disregards spaces after control words. After you have said '\def\row#1#2{...}', you are allowed to put spaces between the arguments (e.g., '\row x n'), because TeX doesn't use single spaces as undelimited arguments. --- ... in other words, look for answers to all life's trying questions in the Good Book. Blessed be Donald Knuth, and the horse He rode in on. John Burke ---------- jeburke@jhunix.hcf.jhu.edu | Johns Hopkins doesn't Homewood Academic Computing Information Center| want my opinions. Why was The Johns Hokins University | he selling whiskey, though. ---------