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 \S
and \P
) eat all spaces after them. (Compile for example \P␣␣,H
.)
What about command names consisting of a single non-letter: which of these eat subsequent spaces? H\$H
and H\$␣H
produce different output (and that's true for e.g. %
and &
too). While the space-producing command \,
does not eat spaces, the space-producing command \␣
does seem to eat all subsequent spaces. (H\␣H
and H\␣␣H
and 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
, A␣\,B
/A\,␣B
, 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 \unskip
.)
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
\!
is a valid command in text mode: its definition is the same in Plain TeX and in LaTeX, that is,\mskip-\thinmuskip
. You probably wanted\,
. – egreg Apr 30 '14 at 20:47\!
, but (thanks to you drawing attention to this, I found out that) in order to have it be a valid text mode command one needs to loadamsmath
(which executes\renewcommand{\!}{\tmspace-\thinmuskip{.1667em}}
and also\let\negthinspace\!
) or use the classmemoir
(which defines\DeclareRobustCommand{\!}{\relax\ifmmode\mskip-\thinmuskip\else\negthinspace\fi}
). Still, I've replaced\!
in the relevant paragraph ("Knowledge of ...") by\,
. – Lover of Structure May 5 '14 at 23:06