obtain the same kerning after coloring as without coloring in math mode
wherein we learn tex outputs the superscript before the subscript:-)
The issue is the color restore after y
breaks the kerning, so with a bit of care you can reset the colour somewhere else...
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\makeatletter
\def\unrestoredcolor{\aftergroup\@gobble\color}
\let\restorecolor\reset@color
\makeatletter
\newcommand{\C}[1]{\begingroup\unrestoredcolor{blue}#1\endgroup}
\newsavebox{\Cbox}
\newsavebox{\Obox}
\begin{document}
color
\begin{equation}
\C y_{jt}^{\restorecolor*}\qquad \text{is kerned differently than} \qquad y_{jt}^*
\end{equation}
\savebox{\Cbox}{$\C y_{jt}^{\restorecolor*}$}
\showthe\wd\Cbox
\savebox{\Obox}{$y_{jt}^*$}
\showthe\wd\Obox
\end{document}
This is a known problem (cf. https://tex.stackexchange.com/a/183496/29873). It can be fixed by using LuaTeX and luacolor
:
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{luacolor}
\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}