# Drawbacks of xspace

I'm certain I have read that xspace can cause more problems than it solves. But I cannot find anything to that effect either on this site or the web. Are there any drawbacks or risks associated with it?

-
The example @lockstep refers to is \newcommand{\test}{\emph{test}\xspace} and still the problem exists: the italic correction is inserted in situations such as \test,, which is wrong. I never recommend (nor use myself) xspace. :) – egreg Dec 11 '12 at 17:59
agreed, @egreg I don't think it was one of my better ideas. – David Carlisle Dec 11 '12 at 18:57
@egreg: so you always insert spaces manually, or you do something clever? – Mohan Dec 11 '12 at 19:09
\newcommand{\newentity}[3][/]{\@ifdefinable{#2}{\def#2#1{#3}}} and then \newentity{\foo}{\emph{foo}} will define \foo to require / after it; or \newentity[|]{\bar}{\textbf{bar}} would require \bar|. As usual \makeatletter and \makeatother are necessary around the definition of \newentity; \newentity will throw an error if the command is already defined. – egreg Dec 11 '12 at 22:54
I originally implemented xspace a long time ago (for LaTeX 2.09) as, like most LaTeX beginners, I'd had a document where I had omitted a {} or \ and so had a missing space in the final document.
The rule in TeX is really quite simple, after a command name that uses letters (as opposed to single character command names using non-letters such as \\$) white space is ignored. It is easy to forget to use \ or {} but the result of forgetting is very predictable, you lose white space in the result. Conversely with xspace the macro will get the correct space most of the time, but it isn't easy to predict when it will get it wrong, and so it's much harder to learn to enter the markup in a way that is always correct rather than having to always visually check for missing space, which rather negates the purpose of the command.