# Spacing after alias [duplicate]

I'm not sure whether I am repeating an already existent question or not, but I'd like to know how to approach the following situation:

I want to define a macro to be an alias to some word or fragment of text. When I define it, the space coming after the command is ignored and consequently the spacing between that word and the next one is deleted, as can be viewed in the MWE below.

The following code

\documentclass{report}

\newcommand{\alias}{Paulo}
\newcommand{\altalias}{Paulo }
\newcommand{\formatalias}{%
{\fontfamily{ptm}\selectfont\textsc{Paulo}}%
}
\newcommand{\altformatalias}{%
{\fontfamily{ptm}\selectfont\textsc{Paulo}} %
}

\begin{document}

This is \alias, who is just checking \LaTeX's behaviour.\par
This is \alias who is just checking \LaTeX's behaviour.\par
This is \altalias who is just checking \LaTeX's behaviour.\par
This is \formatalias who is just checking \LaTeX's behaviour.\par
This is \altformatalias who is just checking \LaTeX's behaviour.

\end{document}


outputs like this:

So my question is, am I doing it right by just adding a space at the end of my macro, or should I do something else?

• No, you will have trouble at \formatalias. It will be PAULO . i.e., space before period. Use \formatalias{} instead. – user11232 Mar 29 '15 at 18:22
• As Harish says, or \formatalias. (swap . with whatever punctuation is appropriate) when punctuation immediately follows the macro and \formatalias\  when a space should follow the macro. – Paul Gessler Mar 29 '15 at 18:25

1. Use \mymacro{} even if the macro doesn't take an argument. The empty group {} at the end of \mymacro doesn't influence the output (in terms of spacing), but sets a space if a space follows the macro, or punctuation if that's the case. Sure, this may seem cumbersome, but you'll get used to it.
2. Use \mymacro\  to force a (control) space whenever you need it.
3. Use xspace, with caution...
• egreg will throw thunderbolts after you for xspace ;-) – user31729 Mar 29 '15 at 18:30
• You could consider adding a third option (still preferable to xspace IMHO): see my comment on the question for details. – Paul Gessler Mar 29 '15 at 18:32