13

Is it possible to have write equations accompanied with explanatory bubbles and comments? I am familiar with underbracket, overbracket, underbrace and overbrace but I have terms close together and I can't squeeze the explanations in. In the main body of the paper, people can scroll and read what a particular symbol means but in a powerpoint/beamer I would rather that people can see the relevant information and the meanings of the variables in the same slide.

Maybe it is better to have a legend accompanying the equation. I'd really appreciate alternative suggestions for getting information across in slides.

enter image description here

2

1 Answer 1

15

One possibility using TikZ:

\documentclass{beamer}
\usepackage{tikz}

\newcounter{mybox}
\newcommand\tikzmark[1]{%
  \tikz[remember picture,overlay] \node[inner xsep=0pt] (#1) {};
}
\newcommand<>\ColorBox[2][]{%
\stepcounter{mybox}%
\node[draw=red!70!black,fill=red!20,align=left,#1] (box\themybox) {#2};
}

\begin{document}

\begin{frame}
\begin{align*}
a(b + c) \tikzmark{a}\onslide<2->{{}&= ab+ac} \\
\tikzmark{b}\onslide<3->{{}&= ba+ca}\\
\tikzmark{c}\onslide<4>{{}&= (b+c)a.}
\end{align*}
\begin{tikzpicture}[remember picture,overlay]
\onslide<2->{%
\ColorBox[xshift=3cm,yshift=3cm]{by distributivity}
\draw[red!70!black,->] 
  (box1) -| ([xshift=7.5pt,yshift=4pt]a.north west);
}
\onslide<3->{%
\ColorBox[xshift=1.5cm,yshift=1cm,fill=blue!30,draw=blue]{by commutativity}
\draw[blue,->] 
  (box2.north) |- ([xshift=1.5pt,yshift=3pt]b.west);
}
\onslide<4>{%
\ColorBox[xshift=1.5cm,fill=orange!30,draw=orange]{by distributivity}
\draw[orange,->] 
  (box3.east) -| ([xshift=7.5pt,]c.west);
}
\end{tikzpicture}
\end{frame}

\end{document}

enter image description here

\ColorBox has one optional argument to control options for the \node used to draw the box, and a mandatory argument for the explanatory text. The associated node is automatically named box<number>. Using \tikzmark you mark any element that will be the end of the arrow and then you can draw the arrow with a standard \draw command.

3
  • If there is text after and/or before the equation, boxes cover it. Is there a way to get the correct spacing between paragraphs and equation, apart from manually changing it?
    – giordano
    Commented Jun 8, 2013 at 8:50
  • @giordano Off the top of my head I think one could write the whole thing (equation and boxes) in one single tikzpicture environment, using a \node to place the equation; this, however, might cause problems with alignment. I guess the simplest thing to do is to manually add some spacing before and/or after the equation if required. Commented Jun 8, 2013 at 14:34
  • moreover, one can't use equation environment inside a node, to number the formula. I'll keep adjusting spacing. Thanks
    – giordano
    Commented Jun 8, 2013 at 14:44

You must log in to answer this question.

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