\newcommand and spacing

You can use the package xspace:

\usepackage{xspace} 
\newcommand{\abc}{\textsc{abc}\xspace}

This command decides whether to insert a space or not, usually this works well.


You can use the package xspace. To avoid the known bug you have to use

\usepackage{xspace}[2006/05/08]
\makeatletter
% usually \check@icr is \@empty and therefore
% not appropriate for \xspaceaddexceptions.
\begingroup
  \text@command\relax
  \global\let\xspace@check@icr\check@icr
\endgroup
\xspaceaddexceptions{\xspace@check@icr}
\makeatother 

See latex bug report tools/3895


I think this is worth mentioning here (from Drawbacks of xspace) because you can use def instead of newcommand and place a / after the name.

\def\abc/{\textsc{abc}}

It's not usually recommended to use def if you can avoid it, but for simple commands to change the font of a string (for example), it's very handy.

Now use \abc/ in a sentence, and it won't eat up the trailing white space.

The / is a required part of the command's usage, and the compiler will throw an error if you forget:

Now use \abc incorrectly.

Use of \abc doesn't match its definition

This is great because it will ensure that you never forget the /. Using newcommand and {} on the other hand, does not offer the assurance or peace of mind that you won't forget it, and the compiler won't warn you. Consequently, your final document could be missing spaces if you didn't proofread it carefully.