[texhax] macro help

Philip TAYLOR P.Taylor at Rhul.Ac.Uk
Wed Aug 9 23:05:21 CEST 2006

Tom Sgouros wrote:

> I have two questions.  

I can't comment on the 1st; it is too LaTeX-y for me to have
any real insight into the problem.

> Second, I have a list of XML tags that I'm documenting and I want to
> define a list of macros for each entry on the list, so that I can do 
> something like this:
>   \newcommand{\tagentry}[1]{#1 & \csname #1\endcsname}
> So this is an entry in a big table of XML tag definitions if the macro
> \TAG contains the definition of TAG.
> The problem I have is that in a huge list of XML tags, there are a
> few whose names have digits: STREET1 and STREET2, for example.  The
> only digits in use are 1 and 2, and they only occur at the end of the
> tags.  I haven't quite been able to come up with a macro definition that
> could translate STREET1 into \STREETONE or \STREETA, and I wonder if
> anyone here could lend a hand, or tell me definitely that I'm wasting

But this one is more interesting, in that I can't see wherein
the problem lies !   \csname STREET1\endcsname is perfectly
valid TeX, and will yield either \relax (if \csname STREET1\endcsname
was undefined) or the pre-defined expansion of \csname STREET1\endcsname
(assuming that you use it in a context in which expansion is not inhibited).

If your only problem is that you don't know to define
\csname STREET1\endcsname, then the following should
suffice :

	\expandafter \def \csname STREET1\endcsname {<whatever>}

and if you /really/ want \csname STREET1\endcsname to be
equivalent to \STREETONE (or \STREETA), of which I'm
less than convinced, then

	\expandafter \let \csname STREET1\endcsname = \STREETONE
	\expandafter \let \csname STREET1\endcsname = \STREETA

should also suffice.

Philip Taylor

More information about the texhax mailing list