# How to change only the color of curly brace made by \underbrace but keep the content color remain unchanged?

I have to set globally the color of every math to blue. However, if I need to annotate an expression by using \underbrace, the curly brace must be in black (for example).

The following are my MWE and its corresponding output in which I failed to accomplish my objective.

\documentclass[preview,border=12pt]{standalone}
\usepackage{amsmath}
\usepackage{xcolor}
\everymath{\color{blue}}
\newcommand\HighlightedTerm[2]{%
\color{black}%
\underbrace{#1}_{\color{red}\text{#2 term}}%
}
\begin{document}
Consider an expression $2a^3b^2cd^7e-ab^2cde^3$. It has 2 terms as shown in the following,
$\HighlightedTerm{2a^3b^2cd^7e}{1st}\HighlightedTerm{-ab^2cde^3}{2nd}$
Do you understand?
\end{document}


Could you help me to realize my objective? Please don't advice me to use TikZ or PSTricks. :-)

-
Note: making every equation in blue is my strategy to prevent someone from photocopying my book. –  Please don't touch Feb 16 '13 at 14:41
How exactly do you expect that strategy to prevent anyone from photocopying your book? –  trav1s Jun 5 '13 at 7:23
@trav1s: Text in blue is difficult to be copied. It is my experience. –  Please don't touch Jun 7 '13 at 13:47

The definition of \underbrace uses the definition of \upbracefill. Both commands are defined in the file fontmath.ltx

The command \upbracefill is defined as follows and you can see it opens a new math-environment.

\def\upbracefill{$\m@th \setbox\z@\hbox{$\braceld$}% \bracelu\leaders\vrule \@height\ht\z@ \@depth\z@\hfill\bracerd \braceld\leaders\vrule \@height\ht\z@ \@depth\z@\hfill\braceru$}


So the easiest way will be the adding of a simple \color{black} to the default definition:

\def\upbracefill{$\color{black}\m@th \setbox\z@\hbox{$\braceld$}% \bracelu\leaders\vrule \@height\ht\z@ \@depth\z@\hfill\bracerd \braceld\leaders\vrule \@height\ht\z@ \@depth\z@\hfill\braceru$}


Here your MWE using \makeatletter and \makeatother.

\documentclass[preview,border=12pt]{standalone}
\usepackage{amsmath}
\usepackage{xcolor}
\everymath{\color{blue}}
\newcommand\HighlightedTerm[2]{%
\color{black}%
\underbrace{#1}_{\color{red}\text{#2 term}}%
}

\makeatletter
\def\upbracefill{$\color{black}\m@th \setbox\z@\hbox{$\braceld$}% \bracelu\leaders\vrule \@height\ht\z@ \@depth\z@\hfill\bracerd \braceld\leaders\vrule \@height\ht\z@ \@depth\z@\hfill\braceru$}
\makeatother
\begin{document}
Consider an expression $2a^3b^2cd^7e-ab^2cde^3$. It has 2 terms as shown in the following,
$\HighlightedTerm{2a^3b^2cd^7e}{1st}\HighlightedTerm{-ab^2cde^3}{2nd}$
Do you understand?
\end{document}


-