Reputation:
When I assign a new command and call it at the beginning of a \par the space between the variable text and next word is missing.
\newcommand{\testcmd}{This is a test}
\par \testcmd foobar.
Will be rendered as:
This is a testfoobar.
\par foo \testcmd bar.
Renders fine as: foo This is a test bar.
Anyone come across this before and have a solution?
Thanks
Upvotes: 2
Views: 4210
Reputation: 5953
Actually a much simpler answer would be to:
\newcommand{\testcmd}{This is a test}
\par \testcmd \ foobar.
Notice the extra "\ " before foobar (slash and space). No extra package needed. It is the same as the most common method for things like:
Mr.\ Smith
etc.\ and
Proc.\ Amer.\ Math.\ Soc.
Upvotes: 1
Reputation: 10848
I do not know the exact thing which is going on here but there are several ways to get that space back:
\newcommand{\testcmd}{This is a test } % <- space before closing brace
par \testcmd{} foobar % <- note {}
The most verbose but the most robust way too:
\usepackage{xspace}
\newcommand{\testcmd}{This is a test\xspace}
Upvotes: 4