[Tex/LaTex] How to add square/circle around a term in equation and add comments using beamer

beamerequations

I am using beamer to write a presentation. In one slide I wrote a formula that looks like this:

enter image description here

What I would like to do is something like this:

enter image description here

Basically I want to draw a square or a circle around two elements of the equation and add two comments to it.

Here is the code i wrote:

\documentclass{beamer}
\usetheme{CambridgeUS}
\usepackage[T1]{fontenc}      % european characters
\usepackage{amssymb,amsmath}  % use mathematical symbols
\usepackage{graphicx}
\newcommand*{\Scale}[2][4]{\scalebox{#1}{$#2$}}%
\newcommand*{\rttensor}[1]{\underline{\underline{#1}}}
\newcommand*{\rttensortwo}[1]{\bar{\bar{#1}}}
\usepackage{palatino}         % use palatino as the default font
\usepackage{multicol}

\begin{document}
  \begin{frame}[fragile]
  Si pu\`o dimostrare che il problema \`a descritto dalla:
  \begin{equation*}
  \frac{\partial f}{\partial t}-\alpha c_{x}\frac{\partial f}{\partial c_{y}} -\beta\frac{\partial}{\partial \pmb{c}}\cdot(f\pmb{c}) = Q(f,f)
  \label{boltzmann_termostatato}
  \end{equation*}
  \begin{itemize}
   \item \textbf{Conseguenza dello USF}: dissipazione di energia sotto forma di di calore con un conseguente aumento di temperatura.
   \item \textbf{Soluzione}: Implementazione di un termostato Gaussiano il quale mantiene la temperatura traslazionale costante.
  \end{itemize}
\end{frame}
\end{document}

Can you tell me what I should do?

Best Answer

You can use \boxed with some trickery to add a comment under the box. Equalizing the two requires a bit of tweaking (a phantom subscript, not a big deal).

Note that \bm from the package bm gives much better results than \pmb.

\documentclass{beamer}
\usetheme{CambridgeUS}
\usepackage[T1]{fontenc}      % european characters
\usepackage{amssymb,amsmath}  % use mathematical symbols
\usepackage{bm}

\newcommand{\commentedbox}[2]{%
  \mbox{
    \begin{tabular}[t]{@{}c@{}}
    $\boxed{\displaystyle#1}$\\
    #2
    \end{tabular}%
  }%
}

\begin{document}

\begin{frame}
Si pu\`o dimostrare che il problema \`e descritto dalla:
\begin{equation*}
  \frac{\partial f}{\partial t} -
  \commentedbox{\alpha c_{x}\frac{\partial f}{\partial c_{y}}}
    {\tiny Commento A} -
  \commentedbox{\beta\frac{\partial}{\partial \bm{c}_{\vphantom{y}}}\cdot(f\bm{c})}
    {\tiny Commento B} = Q(f,f)
  \label{boltzmann_termostatato}
\end{equation*}
\begin{itemize}

\item \textbf{Conseguenza dello USF}: dissipazione di energia sotto forma 
di calore con un conseguente aumento di temperatura.

\item \textbf{Soluzione}: Implementazione di un termostato Gaussiano il 
quale mantiene la temperatura traslazionale costante.

\end{itemize}
\end{frame}

\end{document}

enter image description here

Related Question