1

Possible Duplicate:
\newcommand name cannot include numbers, e.g., \Mycomand123

I'm trying something that I thought would be simple

\def\test{Hello}
\def\test2{Hello again}
\test
\test2

Since I cannot control the naming I need to do some hacks.

\catcode30 = 11
\catcode31 = 11
\catcode32 = 11

which works for 0 and 1 but not for 2

I have also tried the \catcode´1 etc with the same result.

I get a missing number treated as zero.

If anybody has any ideas on why or another solution to include numbers in the naming of defines it would be much appreciated

  • 1
    It would be useful to know a bit more about the use case here: it's possible to make numerals into 'letters', but will always be very awkward. – Joseph Wright Jan 2 '13 at 13:21
  • 2
    \def\testA{...} \def\testB{...} \def\testC{...} – Nicholas Hamilton Jan 2 '13 at 13:54
  • my plan is to change em back. at the end of the def page, and also convert when needed. – Rasmus Jan 2 '13 at 14:28
2

For the original question:

  1. Number 0, 1, 2 are 48, 49, 50 (decimal) in ASCII, not 30, 31, 32 (hexadecimal).

  2. \catcode`1 should work, but not \catcode´1.

  3. Save number 11 for later use, or use other tricks to access origin numbers. e.g. \def\x{\catcode...} \x

Anyway, it's usually not a good idea to change the catcodes of numbers.

  • I know its no a good idea, but it is the only solution that i can find since i cannot change the name! – Rasmus Jan 2 '13 at 14:25
  • \catcode`1 works but not for 2 or 3 etc – Rasmus Jan 2 '13 at 14:28
  • 3
    the assignments for 2 3 etc don't work as having made 1 a letter it is no longer a number so can not be used to generate 11. – David Carlisle Jan 2 '13 at 16:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.