Time for action – adding intelligent spacing to command output

We will load the package xspace. Its only purpose is to fulfill this need.

  1. Modify the previous example to get the following code:
    \documentclass{article}
    \usepackage{xspace}
    \newcommand{\TUG}{\textsc{TeX Users Group}\xspace}
    \begin{document}
    \section{The \TUG}
    The \TUG is an organization for people who are interested in \TeX\ or \LaTeX.
    \end{document}
  2. Typeset, see that the spacing between the words is correct, even without the backslash:
    Time for action – adding intelligent spacing to command output

What just happened?

\usepackage{xspace} tells LaTeX to load the package called xspace and to read in all of its definitions. From now on we may use all commands ...

Get LaTeX Beginners Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.