Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [xspace]

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

0
votes
1answer
51 views

xspace appearing where it shouldn't be

In this example \documentclass{article} \newcommand{\Tt}{\ensuremath{t}} \begin{document} We study \Tt as single items. \end{document} I have defined a \newcommand \Tt where I use \ensuremath so ...
10
votes
1answer
244 views

Why doesn't \xspace always insert a following space when that is expected?

In the MWE, \xspace correctly inserts a space in the first test of \foo, but not in the second test when it is followed by an en-dash. Is there a fix for this? \documentclass{article} \usepackage{...
5
votes
2answers
54 views

How to use \xspace with chemmacros Latin phrases

I would like to add \xspace to the Latin phrases of the chemmacros package because I don't want to use \ or {} at the end of commands without arguments. However, when I try to define a new Latin ...
3
votes
2answers
92 views

Custom command with space and following punctuation?

I want to write a custom command to produce a species name but I am having trouble getting it to work with punctuations. The specifications for my desired output are: Text in italic font No ...
0
votes
1answer
43 views

Add space before \to iff preceding “[” [duplicate]

How can I automatically have a space added before \to iff there is a [ before it? It's just that $f\colon]a;b[\to[c;d]$ looks awfully bad... Thanks!
1
vote
1answer
103 views

Prevent xspace from inserting white space at beginning of line

Short: Is there a way to prevent \xspace from inserting white space if it is at the beginning of a line? Long: I have defined several formatting macros for use in normal text. One of these (\indoubt)...
4
votes
1answer
66 views

Spacing in unusual `csquotes` style

I am currently transcribing and editing some old letters by an ancestor. In some letters he used quotation marks for quotes or titles (books, poems, songs etc.), but occasionally he forgot to set a ...
1
vote
1answer
91 views

\newline command like \xspace [closed]

i wanted to ask if there is in any package a \newline command that works like \xspace, to avoid the "there is no line to end here." error. In fact i have a \NewDocumentCommand{\Teo}{gmm}{\textbf{...
5
votes
2answers
136 views

How to specify a context-sensitive command that decides whether to insert a blank after a '.'?

I like a command that typesets i.e. with a half blank after the i. - i.e. i.\,e. Now the tricky issue is what to include after the e.. The MWE contains a few commands that i would like to see ...
1
vote
1answer
99 views

Can I inject \xspace in all commands from the complexity package?

The complexity package is a very useful one for a Computer Scientist. Recently, I've discovered the xspace package, which provides the \xspace macro that helps defining macros that do not need the \ ...
4
votes
1answer
161 views

xspace failing with long hyphen (---)?

The xspace package fails when used together with ---: \documentclass{minimal} \usepackage{xspace} \begin{document} \newcommand{\twosslvbf}{2 SS l (VBF)\xspace} \twosslvbf is OK. \twosslvbf --...
8
votes
1answer
118 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
23 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
183 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
429 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 ...
4
votes
1answer
300 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, ...
1
vote
1answer
111 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 ...
11
votes
1answer
434 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} \usepackage{...
4
votes
0answers
241 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
68 views

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

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 ...
5
votes
1answer
162 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} \usepackage{...
4
votes
1answer
156 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 ...
4
votes
1answer
924 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 ...
7
votes
3answers
437 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 {NO\...
8
votes
1answer
5k 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 ...
5
votes
1answer
448 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
69 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
370 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? \...
132
votes
2answers
19k 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 ...
5
votes
1answer
435 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: \documentclass[...
6
votes
1answer
206 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} \newcommand{\USB}{USB\xspace}...
8
votes
2answers
966 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 \text{...
2
votes
1answer
795 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
277 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
441 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
576 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 {\text{\...
7
votes
2answers
344 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 \...
38
votes
8answers
8k views

No space following macro without argument [duplicate]

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
566 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 ...
69
votes
4answers
13k 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 ...
27
votes
2answers
2k 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} \...
51
votes
3answers
9k 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
3k 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, ...