[Tex/LaTex] Highlight changed part of the equation

equationshighlighting

As a physicist, I often have unhandy expressions and do manipulations on them. One such example is the following:


enter image description here


The only thing that has really changed are that the \gamma^0 from the outside moved into the square bracket. Everything else is the same.

I would like to aid the reader (in this case my tutor) by highlighting the changed parts of the equation. For this I thought about coloring the changed parts in a dark blue or dark green. Or alternatively I could try to typeset everything else in gray to make the changed parts pop out.

Is anything like that even sensible? Most people just hand in their homework with formulas hand-written on a sheet of paper without any text in between. Would any sort of highlighting actually help or be more distracting?

Best Answer

You could load the xcolor package and use the \colorbox macro (consult the user guide of the xcolor package to decide on the highlighting color):

enter image description here

\documentclass{article}
\usepackage[dvipsnames]{xcolor} % for 'CornflowerBlue'
\usepackage{newtxtext,newtxmath,amsmath,bm}
\newcommand\cbox[1]{\colorbox{CornflowerBlue}{$#1$}}
\begin{document}
\noindent
Then we expand the exponential as a series and have
\begin{align*}
&= \gamma^0 \sum_{n=0}^\infty \frac{1}{n!} 
   \Bigl[i\frac{\alpha}{2}\gamma^5\Bigr]\gamma^0.
\intertext{With $\gamma^0\gamma^0=\bm{1}_4$, we can wrap every 
single $\gamma^5$ into $\gamma^0$.}
&= \sum_{n=0}^\infty \frac{1}{n!} 
   \Bigl[\cbox{\gamma^0} i\frac{\alpha}{2}\gamma^5\cbox{\gamma^0}\Bigr].
\end{align*}

\end{document}