[texhax] macro help
Aditya Mahajan
adityam at umich.edu
Wed Aug 9 23:14:13 CEST 2006
On Wed, 9 Aug 2006, John R. Culleton wrote:
> On Wednesday 09 August 2006 10:35, Tom Sgouros wrote:
>> Hello all:
>>
>>>
>> 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
>> time.
>>
>> Many thanks all,
>>
>> -tom
>
> I can only confirm that TeX treats a numeric at the end of a tag
> not as part of the tag but as a parameter. This is primitive TeX,
> not LaTeX or Context or even plain. So I don't know a way aorund
> it.
I was testing whether it is possible to have macro name with numbers
and came across something surprising. The following works in plain tex
\def\csname street1\endcsname{First street}
\def\tagentry#1{#1 \quad \csname #1\endcsname}
\tagentry{street1}
\bye
But the corresponding latex code
\documentclass{minimal}
\def\csname street1\endcsname{First street}
\def\tagentry#1{#1 \quad \csname #1\endcsname}
\begin{document}
\tagentry{street1}
\end{document}
gives
! Use of \csname doesn't match its definition.
<argument> d
ocument
l.6 \begin{document}
?
The corresponding context code
\def{\csname street1\endcsname}{First street}
\def\tagentry#1{#1 \quad \csname #1\endcsname}
\starttext
\tagentry{street1}
\stoptext
gives
! Use of \csname doesn't match its definition.
\doprocesscommalist ...after \def \csname \s!next
\the \commalevel
\endcsnam...
\loadtwopassdata ...passlists ]\doloadtwopassdata
\globallet
\alltwopassdata...
<inserted text> \loadtwopassdata
\resetutilities \globallet
\ignorerestoftex...
\doateverystarttext ->\the \everystarttext
\global \everystarttext
\emptytoks
\starttext ->\doateverystarttext
\ifnum \textlevel =\zerocount
\registerfile...
l.4 \starttext
Do latex and context redefine the meaning of \def or \csname?
Aditya
More information about the texhax
mailing list