[comp.text] Help! I need help with a TeX macro!

mc3i+@andrew.cmu.edu (Martin Costabel) (03/14/89)

> *Excerpts from mail: 13-Mar-89 Re: Help! I need help with ..*
> *lang@PRC.Unisys.COM (1076)*
> In article <MY5OKVy00UiWQ590Y=@andrew.cmu.edu> you write:
> >Direct E-mail bounced, so here is my 0.2 cents worth:
> >
> >> I tried the obvious
> >
> >> \def\Make#1{\xdef\csname r#1\endcsname{  blah blah blah }}
> >
> >What you did was redefine \csname. What you want to do is
> >
> >\def\Make#1{\expandafter\xdef\csname r#1\endcsname{  blah blah blah }}
> >
> I have had the same problem as the original poster,
> and I tried your solution, but I couldn't get it to work either.
> What I'm trying to do is to define a macro called, say, acronym
> such that calling \acronym{usa} will result in the following:
> \def\usa{{\sc usa}}
> What I tried using your method was
> \def\acronym#1{\expandafter\xdef\csname#1\endcsname{{\sc #1 }}}
> but when I do that, TeX complains to me.
> Did I miss something?  Any help will be appreciated.
> --Francois Lang
This is a funny one: I tried your example using LaTeX and got a message: "TeX
xapacity exceeded" and then a bunch of error messages that looked very much like
an infinite loop. I assume that you got the same error messages.
Well, to my relief, it is not my fault. The problem comes from LaTeX's funny
definition of \sc. Try
\xdef\usa{{\sc usa}}
and you will see the same behavior. In lfonts.tex you will see that the
definition of \sc (or rather of \psc) contains a reference to \psc. So when
\xdef tries to expand \sc, it gets into a loop.
But why do you want \xdef anyway? Why don't you just take \def, or if it is to
be global, \gdef instead of \xdef (\xdef is the same as \global\edef, and \edef
gives the above problem)?
I didn't have any problem with \gdef instead of \xdef.
The original poster wanted \xdef for some reason.
(Leslie Lamport would probably say that you shouldn't use any of these in LaTeX.
Just stick to \newcommand or \renewcommand, and nothing can happen.)

--Martin Costabel

dhosek@jarthur.Claremont.EDU (Donald Hosek) (03/17/89)

In article <126@noether.UUCP> jmf@noether.UUCP (Jose M. Figueroa) writes:
>I tried the obvious
>
>\def\Make#1{\xdef\csname r#1\endcsname{  blah blah blah }}
>
Try doing

\def\Make#1{\expandafter\xdef\csname r#1\endcsname{...}}

-dh