8

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?

2
  • Have you considered \underbrace or \overbrace?
    – Mark
    Apr 26, 2015 at 21:07
  • actually I just solved how to create the boxes around the terms I need... I am trying to understand now how to add the comments Apr 26, 2015 at 21:09

2 Answers 2

10

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

3

You can use TikZ to draw a boxed node with a label below. Next code defines \boxandcomment command. It has four parameters:

#1. optional: For special node characteristics. #2. name of node. for later reference #3. comment #4. node contents

\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}
\usepackage{tikz}

\tikzset{math/.style={draw, execute at begin node={$\displaystyle}, execute at end node={$}}}

\newcommand{\boxandcomment}[4][]{%
    \tikz[baseline=(#2.base), remember picture]{%
        \node[math, label=below:{#3}, #1] (#2) {#4};}}

\begin{document}
  \begin{frame}[fragile]
  Si pu\`o dimostrare che il problema \`a descritto dalla:
  \begin{equation*}
  \frac{\partial f}{\partial t}-\boxandcomment{X}{comment A}{\alpha c_{x}\frac{\partial f}{\partial c_{y}}} - \boxandcomment[red, fill=blue!30, inner sep=5mm]{Y}{comment B}{\beta\frac{\partial}{\partial \pmb{c}}\cdot(f\pmb{c})} = Q(f,f)
  \label{boltzmann_termostatato}
  \end{equation*}  
  \tikz[remember picture,overlay] \draw[bend left] (X.north) to (Y.north);
  \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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .