Command names consist of a sequence of letters (until and excluding the first non-letter) or of a single non-letter.
Command names ending in a letter (including of course those consisting of a single letter, such as
\P) eat all spaces after them. (Compile for example
What about command names consisting of a single non-letter: which of these eat subsequent spaces?
H\$␣H produce different output (and that's true for e.g.
& too). While the space-producing command
\, does not eat spaces, the space-producing command
\␣ does seem to eat all subsequent spaces. (
H\␣␣␣H all produce the same output.
H \␣H is different; see next paragraph.)
Knowledge of TeX's behavior will explain why for example
A␣\,␣B produce different results (in text mode); if a user is not aware of what happens and naively (but understandably) assumes that such spacing commands eat all spaces around them, he or she might run into surprises. (Actually only few commands seem to eat preceding spaces, though such behavior is possible: have your macro start with
Guide to the answers:
- most concise summary (≈ "only
\␣"): Joseph Wright's answer [if it weren't for Heiko's answer, I would have accepted this one]
- all the details (with an interesting detail about empty (!) command names): Heiko Oberdiek's answer
- apparent exceptions (the 7 standard one-letter, accent-producing commands and
\\): Mico's answer