O'Reilly logo

LaTeX Beginners Guide by Stefan Kottwitz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required