# Highlight changed part of the equation

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

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?

• Actually, your tutor wouldn't need this! – AboAmmar Mar 19 '16 at 19:07
• Sure, the tutor is capable of reading through way more obscure text. I just thought to make his job a little bit easier. – Martin Ueding Mar 19 '16 at 19:42

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):

\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}

• The colorbox is nice, I think with a subtle color it might bring value to a less-official document like a homework problem set or a complicated derivation in an appendix. I have tried \textcolor before, and it mesed up the spacing. With the \colorbox, it still seems that it has enough padding (inside) but not enough margin to other characters. – Martin Ueding Mar 20 '16 at 8:01
• @MartinUeding - About the color choice: You wrote in your posting that you were thinking of "dark blue or dark green". I thought that would be too dark, and that's why I chose a medium blue for the answer. If that's still too dark, you're obviously free to make a more suitable choice. About the outer padding: I suspect the appropriate amount of whitespace padding will depend strongly on what's on either side of the \cbox -- the larger the term, the more padding will be required -- as well as on the color used for highlighting. \: will give you a medium-space of whitespace. – Mico Mar 20 '16 at 8:20