Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

marked as duplicate by David Carlisle, Caramdir, egreg, Torbjørn T., lockstep Dec 6 '12 at 16:36

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.

    
command names have to be all letters –  David Carlisle Dec 6 '12 at 16:33
1  
LaTeX internal macros use the trick of using roman numerals for numbered macros. In your case \si, \sii, \siii, \siv etc –  JLDiaz Dec 6 '12 at 16:35

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer

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