\
fred{}
for almost all macro invocations, regardless
of whether the following space is required: however, this FAQ
is written by highly dedicated (and, some would say, eccentric)
people. Many users find all those braces become very tedious very
quickly, and would really rather not type them all.
An alternative structure, that doesn’t violate the design of LaTeX,
is to say \
fred
\
— the \
command is “self
terminating” (like \
\
) and you don’t need braces after
it. Thus one can reduce to one the extra characters one needs
to type.
If even that one character is too many, the package xspace
defines a command \
xspace
that guesses whether there should have
been a space after it, and if so introduces that space. So
“fred\
xspace
jim
” produces “fred jim”, while
“fred\
xspace
. jim
” produces “fred. jim”. Which
usage would of course be completely pointless; but you can incorporate
\
xspace
in your own macros:
\usepackage{xspace} ... \newcommand{\restenergy}{\ensuremath{mc^2}\xspace} ... and we find \restenergy available to us...
The \
xspace
command must be the last thing in your macro
definition (as in the example); it’s not completely foolproof, but it
copes with most obvious situations in running text.
\
xspace
— it changes your input syntax,
which can be confusing, notably to a collaborating author
(particularly if you create some commands which use it and some which
don’t). Of course, no command built into LaTeX or into any
“standard” class or package will use \
xspace
.
This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=xspace