In the code below, the kerning is different if I apply color and if I don't. I understand why it's happening, but how do I change the definition of the command \C so that the kerning is the same as when the color is black? I'm asking for a general solution; I understand that I can fix all kerning manually.
The differences are not obvious in the font used here, but with e.g. mtpro2, it can get pretty ugly. As an aside, the widths of the two boxes are 12.496pt and 12.13722pt respectively; with mtpro2 the numbers are 13.9092 and 13.30093.
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\newcommand{\C}[1]{{\color{blue}#1}}
\newsavebox{\Cbox}
\newsavebox{\Obox}
\begin{document}
\begin{equation}
\C y_{jt}^* \qquad \text{is kerned differently than} \qquad y_{jt}^*
\end{equation}
\savebox{\Cbox}{$\C y_{jt}^*$}
\showthe\wd\Cbox
\savebox{\Obox}{$y_{jt}^*$}
\showthe\wd\Obox
\end{document}


yis replaced withx, at least if the Computer Modern math font is used. Very puzzling. – Mico Mar 14 '17 at 21:39xanyway? the issue is the negative kerning to bring things closer to they, sox_iis pretty much likex{}_ibuty_iandy{}_iare different which makes adding anything and not affecting thespacing hard:-) – David Carlisle Mar 14 '17 at 21:45$\C{x}^*_{jt}$and$x^*_{jt}$if Computer Modern is used, there is a difference ifmtpro,newtxmath,newpxmath, orkpfontsis loaded -- with the uncolored item always being less wide. Oh, and the differences in width, with eitherxoryas the "main" character, go away if there's just a superscript term but no subscript term. – Mico Mar 14 '17 at 21:52cmmi10, for example, the character “x” has no italic correction, whereas “y” has an italic correction of 0.35879pt. In general, the difference in width should be exactly equal (within rounding errors) to the said italic correction. For the case of an isolated supercript, the end of Rule 17 and Rule 18d yield again a net kern = δ. – GuM Mar 15 '17 at 15:13