You could use
$\underbrace{\texttt{\textcolor{blue}{Title}}}_{\texttt{Title}}$
but with some more work you can obtain a fairly general command where you can set text properties independently.
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\ExplSyntaxOn
\NewDocumentCommand{\textunderbrace}{ O{} m m }
{
\group_begin:
\invalid_tub:NNnnn \underbrace \sb { #1 } { #2 } { #3 }
\group_end:
}
\NewDocumentCommand{\textoverbrace}{ O{} m m }
{
\group_begin:
\invalid_tub:NNnnn \overbrace \sp { #1 } { #2 } { #3 }
\group_end:
}
\keys_define:nn { invalid/tub }
{
font .tl_set:N = \l__invalid_tub_font_tl,
font-main .tl_set:N = \l__invalid_tub_fontmain_tl,
font-sub .tl_set:N = \l__invalid_tub_fontsub_tl,
color .tl_set:N = \l__invalid_tub_color_tl,
color-main .tl_set:N = \l__invalid_tub_colormain_tl,
color-sub .tl_set:N = \l__invalid_tub_colorsub_tl,
font .initial:n = \text,
color .initial:n = .,
}
\cs_new_protected:Nn \invalid_tub:NNnnn
{
\keys_set:nn { invalid/tub } { #3 }
\tl_if_empty:NT \l__invalid_tub_fontmain_tl
{
\tl_set_eq:NN \l__invalid_tub_fontmain_tl \l__invalid_tub_font_tl
}
\tl_if_empty:NT \l__invalid_tub_fontsub_tl
{
\tl_set_eq:NN \l__invalid_tub_fontsub_tl \l__invalid_tub_font_tl
}
\tl_if_empty:NT \l__invalid_tub_colormain_tl
{
\tl_set_eq:NN \l__invalid_tub_colormain_tl \l__invalid_tub_color_tl
}
\tl_if_empty:NT \l__invalid_tub_colorsub_tl
{
\tl_set_eq:NN \l__invalid_tub_colorsub_tl \l__invalid_tub_color_tl
}
\ensuremath
{
#1 % \underbrace or \overbrace
{
\l__invalid_tub_fontmain_tl { \color{\l__invalid_tub_colormain_tl} #4 }
}
#2 % \sb or \sp
{
\l__invalid_tub_fontsub_tl { \color{\l__invalid_tub_colorsub_tl} #5 }
}
}
}
\ExplSyntaxOff
\begin{document}
$\underbrace{\texttt{\textcolor{blue}{Title}}}_{\texttt{Title of the Project}}$
\textunderbrace[font=\texttt,color-main=blue]{Title}{Title of the Project}
\bigskip
\textunderbrace{Title}{Title of the project}
\bigskip
\textoverbrace[
font-main=\texttt,
font-sub=\textit,
color-main=blue,
color-sub=red,
]{Title}{Title of the Project}
\end{document}
If you use font=<command>
, it will affect both parts; but you can set separately font-main
and font-sub
; similarly for color
, color-main
and color-sub
.
Fewer braces mean fewer occasions to count them wrong.
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/Do8IC.png)