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.

Filter by
Sorted by
Tagged with
1 vote
1 answer
78 views

Replacement for \xspace with expl3

I have heard more than once that \xspace should not be used and does not work reliable. To find a better solution I have found xpeek and tried to use the example give in the documentation. \...
mrCarnivore's user avatar
  • 1,475
2 votes
1 answer
46 views

How to prevent xspace creating a space between my macro and a trailing single 's' character?

I have defined a macro like that: \newcommand{\code}[1]{\texttt{#1}\xspace} In some situations, I'd like to write the plural of some object and the trailing (plural) 's'-character should not be marked ...
Amos Egel's user avatar
  • 155
2 votes
2 answers
209 views

End-of-sentence space after \dots or \ldots or … with Xetex or Luatex

I do not understand how to type what we call in French points de suspension at the end of a sentence, like this... I would like to create an \endldots command. How could I redefine \ldots so that it ...
Vincent Krebs's user avatar
3 votes
2 answers
161 views

LuaTeX strings and xspace

I am using lua code to automate recording todos that come up during meetings I take minutes of. For this I use \luastringN from the luacode package currently. However, I would like to have all the '...
D Hoekstra's user avatar
2 votes
1 answer
313 views

How to embed \choices in tabular in exam class?

Similar to the question: Exam class multiple choice answers in table format, I'm trying to embed the \choices into a table format and looking like a table. \documentclass[11pt]{exam} \usepackage{...
E.Yu's user avatar
  • 337
3 votes
1 answer
77 views

Using abbreviation commands in glosses

The package xspace allows for the definition of abbreviations like \NOM: \newcommand{\NOM}{\textsc{nom}\xspace} \xspace makes it possible to use \NOMin the text without a {}following the \NOM. ...
Stefan Müller's user avatar
0 votes
0 answers
59 views

Why not using xspace [duplicate]

I often read that one should not use xspace package, but why? Can someone give an example of problems caused?
duke's user avatar
  • 132
2 votes
1 answer
642 views

Adding {} at the end of a command vs xspace

I have read the answers to Space after LaTeX commands but the alternative that I currently use is not mentioned: \newcommand{\arnold}{Arnold Schwarzenegger{}} which of course is less typing and ...
Jan's user avatar
  • 195
0 votes
1 answer
205 views

Naming a section with filename

I am making quite a big document that will be worked on by many paople. We have therefore decided to divide the project by importing every section by it self as shown below. \import{Sections/}{Test} \...
Bjorn's user avatar
  • 1
1 vote
1 answer
64 views

adaptive math newcommand for indices

I have defined a command to add a star as the power to the input variable. It has to be in an adaptive way that if the input has indices, star is added to the main parameter and not the whole input. ...
Mojtaba Masoudinejad's user avatar
0 votes
1 answer
294 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 that ...
Viesturs's user avatar
  • 7,665
10 votes
1 answer
472 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{...
alephzero's user avatar
  • 1,940
5 votes
2 answers
162 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 ...
basseur's user avatar
  • 912
3 votes
2 answers
361 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 ...
voiDnyx's user avatar
  • 209
0 votes
1 answer
109 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!
user avatar
1 vote
1 answer
291 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)...
Andreas's user avatar
  • 945
3 votes
1 answer
219 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 ...
Andreas's user avatar
  • 945
1 vote
1 answer
180 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{...
Daniel's user avatar
  • 155
5 votes
2 answers
238 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 ...
ingli's user avatar
  • 843
1 vote
1 answer
1k 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 \ ...
Nicola Gigante's user avatar
4 votes
1 answer
262 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 --...
fuenfundachtzig's user avatar
8 votes
1 answer
198 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} ...
ThomasH's user avatar
  • 942
0 votes
0 answers
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 ...
einpoklum's user avatar
  • 12.2k
3 votes
2 answers
260 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 ...
Ariel's user avatar
  • 982
2 votes
0 answers
650 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 ...
Jörg's user avatar
  • 7,633
4 votes
1 answer
405 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, ...
matheburg's user avatar
  • 1,279
1 vote
1 answer
274 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 ...
henry's user avatar
  • 6,514
13 votes
1 answer
707 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{...
cslstr's user avatar
  • 6,505
5 votes
0 answers
386 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 ...
Magnus Lie Hetland's user avatar
0 votes
0 answers
69 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 ...
MiB's user avatar
  • 837
5 votes
1 answer
207 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{...
MiB's user avatar
  • 837
4 votes
1 answer
191 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 ...
Raphael's user avatar
  • 5,943
4 votes
1 answer
1k 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 ...
paul's user avatar
  • 231
7 votes
3 answers
894 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\...
GrowMyHair's user avatar
12 votes
1 answer
7k 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 ...
doncherry's user avatar
  • 54.2k
5 votes
1 answer
1k 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 ...
vy32's user avatar
  • 4,730
0 votes
0 answers
77 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 ...
nunos's user avatar
  • 1,019
4 votes
1 answer
689 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? \...
Elrond's user avatar
  • 475
187 votes
2 answers
39k 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 ...
Mohan's user avatar
  • 15.9k
6 votes
1 answer
651 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[...
Wiliam's user avatar
  • 195
6 votes
1 answer
287 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}...
Tobi's user avatar
  • 55.9k
8 votes
2 answers
2k 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{...
Peter Grill's user avatar
5 votes
1 answer
1k 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 ...
StrawberryFieldsForever's user avatar
14 votes
2 answers
296 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 ...
Dave's user avatar
  • 141
16 votes
2 answers
641 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} \...
J. C. Salomon's user avatar
6 votes
2 answers
679 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{\...
DaveBall aka user750378's user avatar
7 votes
2 answers
368 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 ...
Peter Grill's user avatar
42 votes
8 answers
11k 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 ...
user4417's user avatar
  • 1,044
2 votes
2 answers
771 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 ...
MostlyHarmless's user avatar
89 votes
4 answers
18k 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 ...
Ben's user avatar
  • 1,373