Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
This is not exactly what you want to do, but it may be of interest. –  Jubobs 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
add comment

2 Answers 2

up vote 16 down vote accepted

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.
share|improve this answer
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
add comment

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

\documentclass{article}
\usepackage{xcolor}
\usepackage{mathtools}

\makeatletter
\newcommand{\redub}{}
\def\redub#1{%
  \@ifnextchar_%
    {\@redub{#1}}
    {\@latex@warning{Missing argument for \string\redub}\@redub{#1}_{}}%
}
\def\@redub#1_#2{%
    \colorlet{currentcolor}{.}%
    \color{red}%
    \underbrace{\color{currentcolor}#1}_{\color{red}#2}%
    \color{currentcolor}%
}
\makeatother

\setlength{\parindent}{0pt}
\begin{document}
{
\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}}
    {-}
    \redub{m_xm_yf_cHv}_{\substack{\text{Coriolis}\\\text{acceleration}}}
\]
\end{document}
share|improve this answer
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. –  Jubobs 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. –  Jubobs Sep 10 '13 at 4:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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