Text FormattingUnderbrace color

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
pisoir
Posts: 8
Joined: Thu Aug 06, 2009 4:10 pm

Underbrace color

Post by pisoir »

Hello, is it possible to change the color of underbrace only? I have an equation that is in normal black color, and I underbrace some part of it. However, I want to have the underbrace in light gray color. Is is somehow possible to change the color only of the brace and not the text? Thank you.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Underbrace color

Post by frabjous »

You could just turn the color back to black inside the brace, e.g.:

Code: Select all

\documentclass{article}
\usepackage{xcolor}
\begin{document}
$\textcolor[gray]{0.8}{\underbrace{\textcolor{black}{this~is~black}}_{\textcolor{black}{this~too}}}$ 
\end{document}
pisoir
Posts: 8
Joined: Thu Aug 06, 2009 4:10 pm

Re: Underbrace color

Post by pisoir »

Thank you. That's what I actually did it the meantime. Here is my macro:

\newcommand{\ubcolor}[2]{\color{#1}{\underbrace{\color{black}{#2}}}}

Thanks anyway.
Post Reply