How do you go about redefining a command such as \underbrace
, which uses an "uncommon" delimiter, i.e. _
, between its two arguments, so that the redefined command be usable in exactly the same way as the original one?
As an example, consider the command \redub
("red underbrace") defined below on the basis of \underbrace
:
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\newcommand\redub[2]{%
\colorlet{currentcolor}{.}%
\color{red}%
\underbrace{\color{currentcolor}#1}_{\color{red}#2}%
\color{currentcolor}%
}
\begin{document}
\[
\redub{e^{-x^2}}{\text{foo}} + \redub{e^{-2x^2}}{\text{bar}}
\]
\end{document}
For someone who commonly uses \underbrace
, it would be much easier to be able to use the command just like \underbrace
, i.e. like this:
\redub{}_{}
;
not like that:
\redub{}{}
.