When I insert a short maths section in a sentence, it renders fine with a space each side as expected:
...returned $\mathcal{P}$ from...
If I define a command to do the same thing, it also renders with a space each side:
\newcommand{\pc}{\mathcal{P}}
...
...returned $\pc$ from...
However, if I define a function with ensuremath, the space following the expression disappears:
\newcommand{\pc}{\ensuremath{\mathcal{P}}}
...
...returned \pc from...
Why does ensuremath do this? Is there a way to make it more analogous to manually entering math mode?
Thanks!
\pc{}or{\pc}. – Joshua Taylor Jun 27 '14 at 21:02\xspaceand{}didn't work, but adding a blank space at the end of the macro did... – PatrickT Jan 21 '24 at 02:09