24

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 another and shorter way?

26 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,
Arnold Schwarzenegger ,

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

25

Yes, look at the xspace package.

\usepackage{xspace}

And later on...

\newcommand{\arnold}{Arnold Schwarzenegger\xspace}

0

Apart from using an empty statement

\hello{} world

You can also use a tilde as an explicit space:

\hello~world

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

0

just what I'm looking for.. thanks a lot..

-2

For this specific instance, can't you just write,

\newcommand{\arnold}{Arnold Schwarzenegger }

(there's a space after "egger".)

That works on my machine.

Or are you trying to do something more general that this doesn't work for, and this is just a toy example?