summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/tools/xspace.dtx
blob: 1d3c2ff16428bb9d50db7a98eabf873c5fa637d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
% \iffalse meta-comment
%
% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003
% The LaTeX3 Project and any individual authors listed elsewhere
% in this file. 
% 
% This file is part of the Standard LaTeX `Tools Bundle'.
% -------------------------------------------------------
% 
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX 
% version 2003/12/01 or later.
% 
% The list of all files belonging to the LaTeX `Tools Bundle' is
% given in the file `manifest.txt'.
% 
% \fi
% \iffalse
%% File: xspace.dtx Copyright (C) 1991-1996 David Carlisle
%
%<*dtx>
          \ProvidesFile{xspace.dtx}
%</dtx>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{xspace}
%<driver>\ProvidesFile{xspace.drv}
% \fi
%         \ProvidesFile{xspace.dtx}
          [1997/10/13 v1.06 Space after command names (DPC)]
%
% \iffalse
%<*driver>
\documentclass{ltxdoc}
\usepackage{xspace}
\begin{document}
\DocInput{xspace.dtx}
\end{document}
%</driver>
% \fi
%
% \GetFileInfo{xspace.dtx}
% \title{The \textsf{xspace} package\thanks{This file
%        has version number \fileversion, last
%        revised \filedate.}}
% \author{David Carlisle}
% \date{\filedate}
% \maketitle
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \CheckSum{87}
%
% \changes{v1.00}{1991/08/30}{Initial version}
% \changes{v1.01}{1992/06/26}{Re-issue for the new doc and docstrip}
% \changes{v1.02}{1994/01/31}{Re-issue for LaTeX2e (no change to code)}
%
% \begin{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.
% \end{abstract}
%
% \section{Introduction}
% After |\newcommand{\gb}{Great Britain\xspace}|\\
% \newcommand{\gb}{Great Britain\xspace}
% |\gb is a very nice place to live.|\\
% \gb is a very nice place to live.\\
% |\gb, a small island off the coast of France.|\\
% \gb, a small island off the coast of France.
%
% |\xspace| saves the user from having to type \verb*+\ + or |{}| after
% most occurrences of a macro name in text. However if either of these
% constructions follows |\xspace|, a space is not added by |\xspace|.
% This means that it is safe to add |\xspace| to the end of an existing
% macro without making too many changes in your document.
%
% Sometimes |\xspace| may make the wrong decision, and add a space when
% it is not required. In these cases follow the macro with |{}|, as this
% has the effect of suppressing the space.
%
% Note that this package must be loaded \emph{after} any language (or
% other) packages that make punctuation characters `active'.
%
% \StopEventually{}
%
% \section{The Macros}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
% \begin{macro}{\xspace}
% |\xspace| just looks ahead, and then calls |\@xspace|.
% \changes{v1.03}{1994/11/15}{Make robust}
%    \begin{macrocode}
\DeclareRobustCommand\xspace{\futurelet\@let@token\@xspace}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@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!)
% \changes{v1.03}{1994/11/15}{Add exclamation mark}
% \changes{v1.04}{1996/05/17}{Add slash}
% \changes{v1.05}{1996/12/06}{Add space for alltt etc. tools/2322}
% \changes{v1.06}{1997/10/13}{Add normal space. tools/2632}
%    \begin{macrocode}
\def\@xspace{%
  \ifx\@let@token\bgroup\else
  \ifx\@let@token\egroup\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)\else
  \ifx\@let@token-\else
  \ifx\@let@token\@xobeysp\else
  \ifx\@let@token\space\else
  \ifx\@let@token\@sptoken\else
   \space
%    \end{macrocode}
% When I first wrote this there were about half a dozen |\fi| here,
% and I thought that was bad enough.
%    \begin{macrocode}
   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
%</package>
%    \end{macrocode}
% \end{macro}
%
% \Finale
%