Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 would need to write

\arnold\ is a

Is there some other shorter way?

share|improve this question

migrated from Oct 10 '11 at 10:16

This question came from our site for professional and enthusiast programmers.

5 Answers 5

up vote 173 down vote accepted

If you create a macro without arguments you should always invoke it with an empty statement after it: \arnold{}

The reason behind this is that LaTeX expects an argument directly after the macro (it's still in scanning mode for that macro). You need to break that using either a protected space (as you already wrote) or an empty statement {}. I'd recommend using an empty statement, as using a protected space can generate nasty effects -- for example, if that protected space is directly followed by a line break. In that case LaTeX might print two spaces instead which looks ugly and isn't wanted. Using an empty statement prevents this.

How you can add the space directly to the macro has already been answered, but do you really want this? You'd get into trouble as soon as the macro is to be followed by a punctuation mark (or if the macro is followed by a \footnote, etc.):

Arnold Schwarzenegger ,

I'd recommend going for the empty statement option -- one gets used to that quite fast.

share|improve this answer
"xspace" is a tiny package which basically just contains a list of punctuation marks, making it not insert the space if there is a punctuation mark. – Kaarel Feb 4 '09 at 19:17
Thanks for this. I have been creating two of each \newcommand, one with a space and one without, but I knew there had to be a way to make it smarter. Also, apparently you have to do this with some built in stuff, like \LaTeX{}, or you will get the same problem. – asmeurer Dec 9 '10 at 3:11
{\command} works as \command{} and looks nicer IMHO. – Trylks Sep 10 '13 at 13:15
That's a nice explanation, but why is it the accepted answer? Writing \arnold{} is one character longer than \arnold\ , so it doesn't quite satisfy the requirement for a "shorter way". (The \ approach is also Donald Knuth's recommendation, by the way.) – alexis Mar 3 '14 at 17:52
There are many mistakes in this answer. "LaTeX expects an argument" -> TeX ignores the space after multiletter control sequence during its tokenization. What does mean "scanning mode for the macro"? The {} isn't empty statement but it processes \bgroup\egroup. And the \ at the end of line in the source file acts like \^^M and this creates only one space. – wipet Oct 16 '14 at 4:51

I do not recommend this, but for the sake of completeness, a macro name with a single non-letter character do not gobble the spaces after the macro:

\def\æ{Arnold Schwarzenegger}
\æ is an actor.  
share|improve this answer
Note that \@ is a predefined command in LaTeX. There are others to choose from. – egreg Apr 28 at 22:09
@egreg yes, is not the best example. may be better – Fran Apr 28 at 22:17
The edit is even worse. Better a seven bit character – egreg Apr 28 at 22:27
@egreg Why worse? Because is too similar to \ae ? – Fran Apr 28 at 22:33
@Fran, I think that vanilla TeX ignores non-7-bit characters. I forget which variants (if any) are OK with the full Unicode spectrum. (My wife, who is Italian, frequently runs into this trouble when TeXing her documents, which contain accented letters aplenty, on my computer.) – L Spice Apr 29 at 2:19

This is also an answer to this How to define a macro which does not read the next token after itself? question, hence two variants of definition. * is here a character that will never be a true argument.



This is a sample sentence, \ACROe* it does not make much sense.

\def\arnold*{Arnold Schwarzenegger}
\arnold* is a

enter image description here

share|improve this answer
Why “prematurely closed”? Don't you think it was a duplicate? Spreading the information across multiple questions is what this site tries to avoid. – egreg Oct 15 '14 at 21:52
@egreg There was no time to put there an answer, as we can assume, probably better for OP. Closing duplicates is OK for me but not near immediately. Hence “prematurely closed”. But probably I do not catch customaries of this site correctly. – Przemysław Scherwentke Oct 15 '14 at 22:01
@PrzemysławScherwentke A duplicate should be closed as soon as possible exactly in order to avoid spreading the information across questions. You had an additional answer? Fine, but this question is the proper place. – egreg Oct 15 '14 at 22:16
Interesting, but why is typing \arnold* any shorter than \arnold\ . This also has an issue with already defined macros (\TeX for example). – Peter Grill Oct 23 '14 at 20:54
@PeterGrill It is rather, as mentioned, an answer to the closed question and there \ACROeg and \ACROe* have the same length. – Przemysław Scherwentke Oct 23 '14 at 21:54

Yes, look at the xspace package.


And later on...

\newcommand{\arnold}{Arnold Schwarzenegger\xspace}
share|improve this answer
It's a tricky one. My advisor years ago told me about it or I would never have found it. – Uri Feb 4 '09 at 19:16
Note this will not work when you enclose it in braces again: \newcommand{\arnold}{{Arnold Schwarzenegger\xspace}} This would be useful in situations where you must enclose your commands anyway, e.g. in combination with the soul package: \hl{foo \arnold bar} would not work unless you enclose it in additional braces. – math Mar 29 '12 at 12:15
Importantly related: Drawbacks of xspace – doncherry Dec 15 '12 at 19:28

Apart from using an empty statement

\hello{} world

You can also use a tilde as an explicit space:


Make sure not to put another space after the tilde, as this will result in two spaces.

share|improve this answer
However, this would make the phrase hello world inseparable end of a line when otherwise LaTeX would put them in separate lines. This may not be the desired behavior. – Mobius Pizza Oct 10 '12 at 10:45

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.