TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Definining commands/abbreviations that contain numbers

I wanted to know if it was possible to define a new command with a name that contains numbers?

e.g. \newcommand{\agent1}{agent~1}

Or even \ag1ent if having a number at the end is problematic.

I couldn't find the answer in the FAQ.

share|improve this question

marked as duplicate by Alan Munn, Joseph Wright Sep 19 '11 at 14:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Duplicate of Defining commands/abbreviations that contain numbers. The simple answer is that it's marginally possible in some cases, but not recommended. – Alan Munn Sep 19 '11 at 14:17
up vote 9 down vote accepted

From lshort, section 1.3.3:

[Commands] start with a backslash \ and then have a name consisting of letters only. Command names are terminated by a space, a number or any other ‘non-letter.’

Numbers are thus not allowed as part of a command name.

share|improve this answer

You can always use:

\expandafter\def\csname agent1 \endcsname{agent 1}

and use it as

\csname agent1 \endcsname

Both LaTeX and ConText provide wrappers around this. LaTeX uses \@namedef and \@nameuse as wrappers, while ConTeXt uses \setvalue and \getvalue as wrappers.

share|improve this answer

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