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
2 answers
66 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 ...
user avatar
3 votes
2 answers
119 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 '...
user avatar
2 votes
1 answer
138 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{...
user avatar
  • 195
2 votes
0 answers
43 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. ...
user avatar
0 votes
0 answers
46 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?
user avatar
  • 132
1 vote
1 answer
338 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 ...
user avatar
  • 155
0 votes
1 answer
121 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} \...
user avatar
1 vote
1 answer
60 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. ...
user avatar
0 votes
1 answer
172 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 ...
user avatar
  • 6,803
10 votes
1 answer
353 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{...
user avatar
  • 1,904
5 votes
2 answers
126 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 ...
user avatar
  • 912
3 votes
2 answers
226 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 ...
user avatar
  • 209
0 votes
1 answer
89 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
216 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)...
user avatar
  • 905
3 votes
1 answer
165 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 ...
user avatar
  • 905
1 vote
1 answer
163 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{...
user avatar
  • 125
5 votes
2 answers
202 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 ...
user avatar
  • 799
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 \ ...
user avatar
  • 3,251
4 votes
1 answer
233 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 --...
user avatar
8 votes
1 answer
164 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} ...
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 ...
user avatar
  • 11.3k
3 votes
2 answers
246 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 ...
user avatar
  • 974
2 votes
0 answers
564 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 ...
user avatar
  • 7,363
4 votes
1 answer
388 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, ...
user avatar
  • 1,197
1 vote
1 answer
249 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 ...
user avatar
  • 6,260
13 votes
1 answer
557 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{...
user avatar
  • 6,285
5 votes
0 answers
340 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 ...
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 ...
user avatar
  • 837
5 votes
1 answer
199 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{...
user avatar
  • 837
4 votes
1 answer
183 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 ...
user avatar
  • 5,553
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 ...
user avatar
  • 231
7 votes
3 answers
729 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\...
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 ...
user avatar
  • 51.8k
5 votes
1 answer
836 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 ...
user avatar
  • 4,420
0 votes
0 answers
76 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 ...
user avatar
  • 1,009
4 votes
1 answer
616 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? \...
user avatar
  • 465
175 votes
2 answers
33k 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 ...
user avatar
  • 15.2k
6 votes
1 answer
609 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[...
user avatar
  • 195
6 votes
1 answer
254 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}...
user avatar
  • 53.3k
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{...
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 ...
user avatar
14 votes
2 answers
290 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 ...
user avatar
  • 141
16 votes
2 answers
555 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} \...
user avatar
6 votes
2 answers
648 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{\...
user avatar
7 votes
2 answers
360 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 ...
user avatar
42 votes
8 answers
10k 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 ...
user avatar
  • 1,015
2 votes
2 answers
729 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 ...
user avatar
83 votes
4 answers
17k 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 ...
user avatar
  • 1,303
33 votes
2 answers
3k 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} \...
user avatar
  • 35.7k
56 votes
3 answers
13k 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 (...
user avatar
  • 2,401