Take the 2-minute tour ×
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.

Possible Duplicate:
\newcommand and spacing

In my latex document I have defined a new command to force a consistency in naming of a product I talk in my document:

\newcommand{\fancyName}{\emph{ABC}} 

However I experience a problem that:

\fancyName is a wonderfull and fancy product.

is compiled to:

ABCis a wonderfull and fancy product.

without a space after \fancyName in the compiled text.

Does anybody know how to define a new command and avoid this issue?

share|improve this question

marked as duplicate by Gonzalo Medina, Martin Scharrer May 10 '11 at 13:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
guess it is a dublicate –  Martin H May 10 '11 at 12:53
    
(La)TeX ignores all spaces after any macro, user defined or not. This is because the space might just be a separator to indicate the end of the macro name. As already states in the answer here and in the duplicate question: Either use {} after the macro, insert an explicit space using \ , ~ (unbreakable), or \space or add \xspace at the very end. It will add a space if the macro isn't used before a punctuation mark. –  Martin Scharrer May 10 '11 at 13:11

1 Answer 1

up vote 10 down vote accepted

This is a well known "problem". You can either write \macro{} or maybe you consider using

\usepackage{xspace}
\newcommand{\fancyName}{\emph{ABC}\xspace}

xspace should create a space if the macro is used in text but no space if it is at the end of a sentence and followed by a full stop.

share|improve this answer
1  
Another option is to add {} after the macro call, like \fancyName{}. –  ℝaphink May 10 '11 at 12:55

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