I'm trying to define a macro replaces a phrase by a single latex expression, e.g., I want \myPhrase to return the phrase "this is the dog". The trouble is that when you do this in the obvious way
\def\myPhrase{this is the dog}
then you always have to remember to add a space after the macro, i.e.,
\myPhrase that I like
will return
this is the dogthat I like.
Since my coauthor will never remember to always write
\myPhrase\ that I like
I tried to define a macro with an optional argument. The default would be a space, and if you wanted punctuation you would add it as an argument.
For example
\documentclass[11pt,reqno,fleqn]{amsart}
\newcommand{\myPhrase}[1][\ ]{This is the dog{#1}}
\begin{document}
\myPhrase that I was telling you about. \myPhrase{,} which is a collie.
\end{document}
In principle the above should do the trick but it adds space even when there's an optional argument, i.e.,
\myPhrase{,}
returns
This is my dog , which is a collie
when it should return
This is my dog, which is a collie
Any advice would be very much appreciated! Thanks Leo

xspacepackage. Also see the TeX-FAQ: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=xspace – Aditya Jun 17 '14 at 20:33