LaTeX Macro Spacing Tool
LaTeX Macro Spacing Tool
David Carlisle
1997/10/13
Abstract
\xspace should be used at the end of a macro designed to be used mainly
in text. It adds a space unless the macro is followed by certain punctuation
characters.
Introduction
2
1
\xspace
hpackagei
\@xspace
The Macros
\DeclareRobustCommand\xspace{\futurelet\@let@token\@xspace}
If the next token is one of a specified list of characters, do nothing, otherwise add
a space. If you often use a different punctuation character, add the appropriate
line (do not forget the \fi at the end!)
3
4
5
6
\def\@xspace{%
\ifx\@let@token\bgroup\else
\ifx\@let@token\egroup\else
\ifx\@let@token\/\else
This
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
\ifx\@let@token\ \else
\ifx\@let@token~\else
\ifx\@let@token.\else
\ifx\@let@token!\else
\ifx\@let@token,\else
\ifx\@let@token:\else
\ifx\@let@token;\else
\ifx\@let@token?\else
\ifx\@let@token/\else
\ifx\@let@token\else
\ifx\@let@token)\else
\ifx\@let@token-\else
\ifx\@let@token\@xobeysp\else
\ifx\@let@token\space\else
\ifx\@let@token\@sptoken\else
\space
When I first wrote this there were about half a dozen \fi here, and I thought that
was bad enough.
23
24
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
h/packagei