5

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

I am trying to define commands \s1, \s2, etc. Right now the the substitution is very simple but the idea would be to replace it for something that would make for sense later.

This is what I have now

\newcommand{\s1}{s1}

and I get the following error:

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.52 \newcommand{\s1}{s1}

If I comment the line with the newcommand definition it works fine. (And I other other newcommands defined in the same location, and I do have a \begin{document})

Any idea of what I am doing wrong?

skeept
  • 335

1 Answers1

6

Only letters (and @ in some cases) can be parts of names of commands defined by \newcommand. You have to use the lower-level macro \@namedef:

\makeatletter % to make \@namedef accessible
\@namedef{s1}{s1}
\makeatoter % to revert \makeatletter

However, you wouldn't be able to use such command as \s1, you would have to always write \csname s1\endcsname. I don't think it is of any use for you, just stick to letters.

Remark: I made several simplifications in the answer. I know I did. But this is the basic idea.

yo'
  • 51,322