[comp.text.tex] Macro argument problem: ^^M^^M != \par

duty@murdu.ucs.unimelb.edu.au (Duty Programmer) (07/18/90)

I have a macro for typesetting references, which has two arguments: the
volume number and page number. Originally, I had the macro defined as

\def\mac #1 #2\par{#1, #2.\par}

and used as:

\mac 10 102

\mac 30 867

and so on. This was fine, except that the second argument was always
followed by a <space> before the trailing period. On reading the
TeXbook carefully, I realised that in fact two returns are NOT the same
as \par: they are translated to <space>\par by TeX. OK fine, so I get
rid of the \par in the definition (making the second parameter
undelimited, so that TeX throws away the <space> for me), only now the
second argument is set to the first digit of the second number!

Now I realise that there are simple ways around this (such as putting
\par at the end of each line, or grouping the second argument in
braces, or even redefining ^^M (yuk!)), but is there a simple way to do this
by modifying the macro definition ONLY?

I'm sure this is a trivial problem, but I cannot immediately see the answer!

Richard

--
Richard Brown                     | E-mail: pbrown@munda.ph.unimelb.EDU.AU
School of Physics                 | Phone : +61 3 344 5081
University of Melbourne           | Fax   : +61 3 344 5104
Parkville Victoria AUSTRALIA 3052 | Telex : AA35185

ef@tools.uucp (Edgar Fuss) (07/19/90)

The problem is that the TeXbook ``lies a little bit'' when explaining that
an empty line (or two CRs in a row) are equivalent to a \par.
What really causes a \par is an end-of-line condition at the beginning of
a line. Since an end-of-line is equivalent to a space, you get both a space
(from the first CR)---which normally disappears because glue at the end of a
paragraph is ignored---and a \par.
I circumvent this by either typing in an explicit \par or by redisigning the
macro such that it ignores the space in the last argument.

geuder@informatik.uni-stuttgart.de (Uwe Geuder) (07/20/90)

In article <1887@murdu.oz> duty@murdu.ucs.unimelb.edu.au (Duty Programmer) writes:

   I have a macro for typesetting references, which has two arguments: the
   volume number and page number. Originally, I had the macro defined as

   \def\mac #1 #2\par{#1, #2.\par}

   and used as:

   \mac 10 102

   \mac 30 867

   and so on. This was fine, except that the second argument was always
   followed by a <space> before the trailing period. On reading the
   TeXbook carefully, I realised that in fact two returns are NOT the same
   as \par: they are translated to <space>\par by TeX. OK fine, so I get
   rid of the \par in the definition (making the second parameter
   undelimited, so that TeX throws away the <space> for me), only now the
   second argument is set to the first digit of the second number!

   [ ... ]

What about \def\mac #1 #2 \par{#1, #2.\par} ? Or did I get it wrong?



   
--
Uwe Geuder, geuder@informatik.uni-stuttgart.de           (SMTP)
            geuder@ipvr.informatik.uni-stuttgart.dbp.de  ("X.400")