I use the initialism "CE" a lot in my thesis, both in an out of equations. I find that the letters are too far spaced for my liking when used in an equation, so I use the \! command to reduce the spacing. When I do this manually it seems to work perfectly, but when I incorporate the this into a \newcommand the result is that I always lose a space after the command if one exists.
Is there a way to stop this? It would be even better if I could have one command in and out of equation environments.
\documentclass{article}
\begin{document}
% Commands
\newcommand\CE{{C\!E}} % CE for equation environment
\newcommand\ce{$C\!E$} % CE for inline writing
\ce. \ce this is a line. % space lost after second \ce
$\CE$. $\CE$ this is a line. % Works fine but cumbersome
$C\!E$. $C\!E$ this is a line. % Works fine but would like this in a command
\end{document}

\newcommand\CE{\textit{CE}}or\newcommand\CE{\mathit{CE}}. There will be no difference if you use the Computer Modern font family for your document, but there may be a difference if you use other fonts for text-mode and math-mode material. – Mico Feb 17 '16 at 08:29\ensuremathto ensure that "CE" is typeset as math both inside and outside of math environments, meaning you can combine them into one command. – sodd Feb 17 '16 at 08:30{\command}– Brian Albert Monroe Feb 17 '16 at 08:56