Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

One can use the command such as \textcolor[rgb]{1.00,0.00,0.00}{boundary} to color the word "boundary" in a document.

Here is my question:

How to color the math symbols in $$? For example, can one turn $C^{2}$ into red in LaTeX?

share|improve this question
Sort of related question: tex.stackexchange.com/q/335/86 –  Loop Space Jun 25 '11 at 19:50
In \eqnarray environment, I find that curly bracketing can control the range of coloring. For example, {\color{red}{some symbols}} will ensure that math symbols after '}' are not colored. –  EKG Jun 13 '12 at 19:56
Don't use eqnarray. –  kahen Oct 16 '12 at 0:28
add comment

1 Answer

up vote 34 down vote accepted

\textcolor from the xcolor package also works in mathmode, even if the name says otherwise. You can also use $ \color{<color>} C^2 $. It sets the color for the rest of the current scope (group).





$ \color{red} C^2 $

$ \color{yellow} A = \textcolor{blue}{B} \mathbin{\textcolor{red}{-}} \textcolor{green}{C} $


Note that the \mathbin must be wrapped around the coloured, binary - here, as Leo Liu pointed out in his comment, to set the correct spacing again. The coloring changes the math type so they spacing would be different.

share|improve this answer
There's a little problem: \textcolor{red}{-} makes it a \mathord, but it should be a \mathbin. Use \mathbin{\textcolor{red}{-}} to get proper spacing. –  Leo Liu Jun 26 '11 at 2:23
@Leo: Thanks, fixed. I wasn't sure about that myself. –  Martin Scharrer Jun 26 '11 at 8:47
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.