Colorbox adds some spaces when I use it in equations. E.g. in
\documentclass[12pt]{article}
\usepackage{xcolor}
\begin{document}
\colorbox{yellow}{${a^2}+b^2=c^2$}
\colorbox{yellow}{$\colorbox{blue}{$a^2$}+b^2=c^2$}
\end{document}
the second equation is longer than the first (just taking into account the mathematical symbols). Is there a way to prevent this? Note that I do not mind that the size of the boxes is larger than the enclosed symbols and that the boxes could overlap symbols which are not enclosed if no spaces are added. Note also that I would like to avoid adding negative spaces by hand.


\mathstrut, which is useful to ensure that the various boxes are the same size. – Peter Grill Apr 10 '12 at 16:53