This question already has an answer here:

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.


% 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


CE spacing image

marked as duplicate by egreg equations Feb 17 '16 at 8:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Since "CE" isn't the product of two variables named "C" and "E", you should use either \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 8:29
  • Also, you can use \ensuremath to ensure that "CE" is typeset as math both inside and outside of math environments, meaning you can combine them into one command. – hooy Feb 17 '16 at 8:30
  • Have a look at this thread. – Sveinung Feb 17 '16 at 8:30
  • Just out of curiosity: What does "CE" stand for? – Mico Feb 17 '16 at 8:35
  • CE stands for "Certainty Equivalent", A fixed outcome that an agent values equally to some uncertain distribution of outcomes. Useful stuff all around! I think I'm going to go with a suggestion in the comments of one of the answers in the "marked as duplicate question" {\command} – Brian Albert Monroe Feb 17 '16 at 8:56

You have a few options. In addition to Zarko's answer, macros should generally be followed by a trailing \, which is has a special character class that tells TeX to stop reading for more characters (it is trying to figure out the macro name). Or you could enclose it in a group like {\ce} or even \ce{}.

See What are category codes?

Unfortunately, the space (cat 10), although aesthetically pleasing, will always be eaten up by the TeX parser. The { (cat 1), } (cat 2), $ (cat 3), and \ (escape cat 0) will not. (alphabetical characters are cat 11)

Not the answer you're looking for? Browse other questions tagged or ask your own question.