TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

With a macro such as:


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 bring back the space?

share|improve this question
up vote 28 down vote accepted

The problem of using \naive\ or \naive{}: If you happen to forget the closing backslash/braces, you'll end with gobbled space without noticing it.

The problem of adding \xspace to a macro's definition: This may produce inconsistent spacing if the macro uses \emph. See xspace and italic correction for details.

In the thread linked above, Will Robertson suggested to use "delimited" macros (e.g. with / at the end) as an alternative. The main advantage of \naive/ is that an error message will occur if you happen to forget the closing slash.

(See also the comments to this answer.)


\newcommand{\naive}{}% To make sure that \naive isn't already defined    


the \naive/ approach


enter image description here

share|improve this answer
the \newcommand should be a \providecommand and then you can use a \renewcommand – Herbert Aug 16 '11 at 10:59
@Herbert: a) I want TeX to throw an error, not to silently overwrite an existing definition, so it's \newcommand for me. b) AFAIK, \renewcommand doesn't work for delimited macros. – lockstep Aug 16 '11 at 11:02
no, then it should be \@ifdefinable{...} – Herbert Aug 16 '11 at 11:13
@Herbert: I don't know \@ifdefinable{...}, why is it better? – user4417 Aug 16 '11 at 11:53
then you can out a message in the text, which the user understand! – Herbert Aug 16 '11 at 11:57

Use the package xspace. It

provides a single command that looks at what comes after it in the command stream, and decides whether to insert a space to replace one "eaten" by the TeX command decoder.

For your case it can be used as in the following:





the \naive approach

share|improve this answer
Also, I would suggest using \newcommand instead of \def. See tex.stackexchange.com/questions/1050/… – N.N. Aug 16 '11 at 10:36
Just for reference: Drawbacks of xspace. – Tobi Feb 19 '14 at 19:53

Use braces \naive{} or \naive\ or xspace. See the FAQ: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=xspace

share|improve this answer

The problem is that the follwing space is uses as macro end. Type \navie{} or use the xspace package.



Test \naiv Test.
share|improve this answer
Just for reference: Drawbacks of xspace. – Tobi Feb 19 '14 at 20:03

Quick answer: the \naive\ approach

Better answer: Use the xspace-package

\newcommand{\better\xspace }

the \better approach

Advantage: xspace take a look on the next character. So you have not an obsolete space in:

Macro at sentence end\better.
share|improve this answer
Just for reference: Drawbacks of xspace. – Tobi Feb 19 '14 at 19:58

A dirty trick: Use a special character in the macro name (not working with \newcommand):

the \¶naive approach


Note: Do no start another macro with the same special character, although is possible use again this character in another position.

share|improve this answer

I don't know xspace package but I mean that it does somethig similar to this:

\def\maybespaceB#1{\ifx#1\relax \nexxt \else \ifx#1\next \let\nexxt=\relax\fi

The \naive approach. The approach is \naive.

share|improve this answer

For completeness, you could also define the macro as


which will require that it be followed by {} when ever it is used. For example, the \naive{} approach will work whereas the \naive approach will raise an error which says Use of \naive doesn't match its definition..

See page 204 of The TEXbook for details. Also, this answer may be of interest.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.