{xspace} is a command (provided by the package of the same name) that inserts a space if and only if the space is followed by punctuation. This is one of several techniques to deal with TeX's habit to "eat" spaces after macros without arguments.

learn more… | top users | synonyms

6
votes
1answer
24 views

xspace inserts a space when used inside \enquote

Am I wrong in thinking that \xspace should not introduce a space when used inside an \enquote command as used in the following MWE? And how can I get the two to work together? \documentclass{article} ...
0
votes
0answers
21 views

Trying to get the spacing right after an expanded sequence [duplicate]

I've defined \newcommand{\foo}[1]{\textbf{#1}} \newcommand{\bar}{\foo{Bar}} Now, when I compile \bar tender --- tend your \bar. I would like to get Bar tender - tend your Bar. but what I ...
3
votes
2answers
54 views

Using user defined commands in linguex without gobbling space

I use linguex together with own defined commands to get grammatical categories typeset in small-caps. For instance, I have \newcommand{\sg}{\textsc{sg}} to typeset the SG (=singular) gloss. This is ...
2
votes
0answers
92 views

soul for text highlighting, microtype for letterspacing, and xspace: incompatibility

I am trying to use soul for highlighting text and microtype for letter spacing (and other things). But I cannot get the two to work together nicely when I include xspace (I use this mainly for ...
5
votes
1answer
110 views

xspace leaves space in front of comment

I am confused by the behaviour of \xspace in combination with the \todo command. I didn't expect \xspace to leave a space when I cut off all spaces by a comment sign %. Usually this works as expected, ...
0
votes
0answers
41 views

xspace's spacing with siunitx macro does not work in math mode

To make life with LaTeX easier and faster (especially faster), I defined some macros in the preamble with the help of xspace. They work as intended in text mode, but fail in math mode. How could I ...
9
votes
1answer
184 views

Acceptable use cases for xspace; When will it fail?

I have used xspace for a long time to take care of adding space after usage of some macros. Usually, it is with a macro to format a word consistently, as in: \documentclass[]{article} ...
3
votes
0answers
78 views

Proper spacing with ellipsis and xspace

Really a simple enough question, but I haven't found an answer, so … is there any straightforward way of making the spacing adjustments of ellipsis.sty work with xspace? The package itself has an ...
0
votes
0answers
53 views

\AtBeginDocument breaks csquotes nesting - or \xspace won't add space

A couple of months ago, I asked this question because xspace wasn't adding whitespace before an active quote. The apparent solution was to add \AtBeginDocument. However, this breaks csquotes nesting ...
6
votes
1answer
109 views

\xspace doesn't add whitespace before quotes if they are active

I'm trying to get \xspace to add a whitespace before “ if it is an auto quote using csquotes. Here is an MWE: \documentclass{minimal} \usepackage[autostyle,german=guillemets]{csquotes} ...
4
votes
1answer
99 views

Combining dashes from babel with xspace

Assume we have some mathematical object that is used in formulae as well as in "natural" language (in my case, complexity classes). When defining a macro for such an object, I like to use \xspace so ...
3
votes
1answer
268 views

How to leave a space after an em-dash with xspace

I wish to have a space between and after my em-dashes as I do not like the english tradition to collate them to the nearest words. xspace permits to leave spaces for macros but does not handle well ...
5
votes
2answers
161 views

How to properly define NOx

I'm writing a document containg NOx a lot. It appears in section titles, regular text and tables, in sans serif, roman, bold and medium. Therefore I defined a command: \newcommand \nox ...
7
votes
1answer
2k views

Where does TeXstudio store the .cwl files for hyperref and xspace?

TeXstudio uses .cwl files for storing information about which macros are defined by which packages, one file per package. This information is used for autocompletion suggestions and highlighting of ...
2
votes
1answer
146 views

How to prevent \xspace from adding a full space after a period?

I have a little macro that I use for doing adding an e.g. in my writing: \newcommand{\eg}{\emph{e.g.}\xspace} The problem I have is that LaTeX is treating the g. as the end of a sentence and is ...
0
votes
0answers
60 views

How to avoid having to use the tilde with every macro? [duplicate]

I am relatively new to LaTeX, so please bear with me. I have just started using macros and finding them quite useful. However, I find myself having to use the tilde (~) a lot of times to get a space ...
4
votes
1answer
234 views

\xspace and hyphenation

I was considering to use xspace for some common standard terms in my document, like: \newcommand{\ring}{my secret ring\xspace} I am now wondering, if hyphenation gets it right, when I do this? ...
66
votes
2answers
4k views

Drawbacks of xspace

I'm certain I have read that xspace can cause more problems than it solves. But I cannot find anything to that effect either on this site or the web. Are there any drawbacks or risks associated with ...
4
votes
1answer
243 views

Extra space after new command using xparse

I was trying to write a macro that could take either one of two arguments and produce different outputs for both cases. For that, I used to package xparse. Here is the macro I wrote: ...
6
votes
1answer
110 views

xspace doesn’t handle \,

When using a macro ending with an \xspace followed by a small space \, xspace inserts an extra (normal) space. \documentclass[parskip=half]{scrartcl} \usepackage{xspace} ...
8
votes
2answers
482 views

Abbreviations in math mode

I am trying to adapt Martin Scharrer's solution from Macros for common abbreviations to be able to use them in math mode. Yes I realize I am about to incur some criticism that I should just use ...
2
votes
1answer
424 views

How to prevent getting a space after an abbreviation using the abbrevs package?

If I use the abbrevs package and define a \newabbrev using the following code \newabbrev\gb{Great Britain} and use it in the following example (taken from the xspace package documentation): \gb, a ...
14
votes
2answers
239 views

How do I get microtype's “outer spacing” to work with the xspace package?

Microtype adds extra space to the start and end of letterspaced text, configured via the \SetTracking command's "outer spacing" option. Unfortunately, xspace breaks this. For example, I define a few ...
16
votes
2answers
367 views

Defining \xthinspace: Thin space only if not followed by certain characters

Following this 2005 thread from the XeTeX list, I’ve defined a \spaceddash command and assigned it to the Unicode em-dash character U+2014 “—”: \documentclass{minimal} \usepackage[utf8]{inputenc} ...
6
votes
2answers
378 views

\xspace in combination with ifmmode

Sometimes I want a special font for the word "true", use it in mathmode as well as outside, and have a correct space afterwords if I am not in mathmode. Using \newcommand{\tru}{\ifmmode ...
7
votes
2answers
308 views

Nested use of \xspace to not leave extra space

I have a feeling this is another of my questions that is going to be a "Duh!!" kind of answer, but I can't seem to figure out how to do this properly: I want to put a wrapper around a macro that uses ...
23
votes
7answers
3k views

No space following macro without argument

With a macro such as: \def\naive{na\"{\i}ve} I find that the space which I would hope to follow it, is absent. So, with the \naive approach I get the naïveapproach in the output. How do I ...
2
votes
2answers
368 views

Problem with macro definition spaces of index and superscript

I have defined a command FZ for defining mathematical symbols: \newcommand{\FZ}[1]{\textcolor{blue}{\ensuremath{#1}}\xspace} I want to define a Symbol CV first and then create some variants with ...
49
votes
3answers
5k views

\newcommand and spacing

How can I define my own shorthand command, but making sure that the spacing afterwards is correct? \newcommand{\abc}{\textsc{abc}} produces 'ABC,' but has the problem 'ABCmoretexthere' (i.e. no space ...
20
votes
2answers
1k views

Why does \xspace behave differently for parenthesis vs. braces/brackets?

Consider: \documentclass{article} \usepackage{xspace} \begin{document} (something\xspace) [something\xspace] \{something\xspace\} \end{document} Or more to the point: \documentclass{article} ...
37
votes
2answers
4k views

Macros for common abbreviations

Common abbreviations are surprisingly tricky to format correctly. I'd like some simple macros for them, to be used like so: You should eat more fruit, \eg apples, bananas, oranges, \etc. There are ...
14
votes
1answer
2k views

Abbreviations and spacing

I'm sure this is a pretty standard questions that's been asked (and answered!) a hundered times before, so apologies for boring people. In LaTeX, I'd like to write a macro for abbreviations, such as, ...
189
votes
5answers
35k views

Space after LaTeX commands

I have a definition \newcommand{\arnold}{Arnold Schwarzenegger} when I refer to it by \arnold is a it is rendered as Arnold Schwarzeneggeris a In order to have a space in front of "is" I ...