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:

\partial _t(m_x m_yHu)+ \partial_x(m_yHuu)+\partial_y(m_xHvu)+\partial_z(m_xm_ywu)-m_xm_yf_cHv

Any help/suggestion is highly appreciated.

  • This is not exactly what you want to do, but it may be of interest. – jub0bs Mar 19 '13 at 22:13
  • @Jubobs Thanks for your reply. In fact that post is interesting too. I will also try to implement that in my future slides. Very impressive. – Jdbaba Mar 19 '13 at 22:24
  • Related, a previous question of mine. Just in case you are interested: Isolated coloring of math symbols and boxes in equations – hpesoj626 Mar 20 '13 at 11:27
  • Also related: Highlight terms in equation mode. Highlights parts of equations, not with underbraces, but with colored shading / boxes. – Xavier Jul 28 '13 at 19:23

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
  \alert{\underbrace{\color{black}\partial _t(m_x m_yHu)}_
    {\mathclap{\text{Local acceleration}}}}
    \partial_x(m_yHuu) + \partial_y(m_xHvu) + \partial_z(m_xm_ywu)}_
      {\text{Advective acceleration}}}

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.
  • 1
    @ Werner Thank you so much for your answer and your explanations are superb. It really helps a beginner like. Much appreciated. – Jdbaba Mar 19 '13 at 22:42

Building on Werner's solution, you can define a new command for more automation.

In the code below, I define a command called \redub (for "red underbrace") that uses _ as delimiter between its two arguments, just like \underbrace, and with which

  1. juggling the two colours (red and the current colour) is not necessary,
  2. hardcoding the current colour is not necessary.

enter image description here


    {\@latex@warning{Missing argument for \string\redub}\@redub{#1}_{}}%

\color{blue} % only to demonstrate 1. and 2. (see the top of my answer)
A simple example:
    \redub{Ax=b}_{\mathclap{\text{my linear system}}}
blah blah blah\ldots \\[1em]

A more involved example
    \redub{\partial _t(m_x m_yHu)}_{\mathclap{\text{Local acceleration}}}
    \redub{\partial_x(m_yHuu) + \partial_y(m_xHvu) + \partial_z(m_xm_ywu)}_%
    {\text{Advective acceleration}}
  • 1
    @ Jubobs Thanks for this. It will be very useful to me as I have to write several equations. – Jdbaba Mar 19 '13 at 23:09
  • Why some text have \mathclap in front and some don't? What does it do? – LWZ Aug 22 '13 at 2:51
  • 1
    @LWZ It prevents extra space on either side of the maths stuff passed as the first argument of \underbrace. Try to remove the \mathclap command, leaving simply the text as the second argument to \underbrace and you'll see what happens. See the mathtools documentation for more detail. – jub0bs Aug 22 '13 at 2:56
  • Now I tested this in my beamer slides. I notice that this method affects font size. The terms with \underbrace becomes smaller than normal. – LWZ Sep 10 '13 at 4:24
  • @LWZ Perhaps, but what you describe has little to do with the approach I use to get coloured underbraces or the document class you use; that's the normal behaviour of \underbrace. See this for more detail on how to scale the font of \underbrace's arguments. – jub0bs Sep 10 '13 at 4:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.