[Tex/LaTex] Colored underbraces for annotating equations

beamerequationsformatting

I am trying to implement my previous Powerpoint presentation in beamer.

I have a figure like

enter image description here

I want to create something like this in beamer.

I wrote a equation as follows but I couldn't write the description underneath the equation as shown in figure:

\begin{equation}
\partial _t(m_x m_yHu)+ \partial_x(m_yHuu)+\partial_y(m_xHvu)+\partial_z(m_xm_ywu)-m_xm_yf_cHv
\end{equation}

Any help/suggestion is highly appreciated.

Best Answer

The operator spacing is not perfect, but the braces add some horizontal padding which might be sufficient:

enter image description here

\documentclass{beamer}% http://ctan.org/pkg/beamer
\usepackage{mathtools}% http://ctan.org/pkg/mathtools
\begin{document}
\begin{frame}
\[
  \alert{\underbrace{\color{black}\partial _t(m_x m_yHu)}_
    {\mathclap{\text{Local acceleration}}}}
  {+}
  \alert{\underbrace{\color{black}
    \partial_x(m_yHuu) + \partial_y(m_xHvu) + \partial_z(m_xm_ywu)}_
      {\text{Advective acceleration}}}
  {-}
  \alert{\underbrace{\color{black}m_xm_yf_cHv}_
    {\substack{\text{Coriolis}\\\text{acceleration}}}}
\]
\end{frame}
\end{document}

Some highlights:

  • \alert provides the colour choice for the \underbraces, while \color{black} avoids the colour transformation of the expression.
  • \text (from amsmath, loaded by mathtools) allows for easy formatting of text in sub-/superscripts without having to worry about the font sizes.
  • Since the text under the first brace is wider than the math component, \mathclap inserts the contents in a zero-width box so as to not influence the surrounded components being set.
  • \substack allows for stacking of elements vertically, especially as a subscript under an operator, which \underbrace intrinsically is.
  • Surrounding the operators with braces {<op>} removes their "binary operator" spacing. However, the padding inserted by the \underbraces (on either side) acts as a sufficient buffer. It's not perfect, but it might not be all the noticeable.