# How to insert a space after a substitution of a variable or a command? [duplicate]

I am trying to learn how to define commands (\newcommand) and variables (\def) in LaTeX.

When I try:

\def \new {$new$}


or

\newcommand{\new}{$new$}


and substitute it in the text:

\documentclass{article}

%\def \new {$new$}
%\newcommand{\new}{$new$}

\begin{document}
lala \new lala
\end{document}


The substituted text sticks to the following text as shown here:

no matter how many spaces I put after the command.

What causes this behavior and how can I change it?

• That's the normal behaviour. Any amount of space after a control sequence (such as \new) gets gobbled. To effect a space after \new, you can, for instance, use an empty group {}: try lala \new{} lala. – jub0bs Nov 22 '13 at 14:30
• Or use xspace package and put \newcommand{\new}{$new$\xspace}. David is here any way to help ;-) – user11232 Nov 22 '13 at 14:52