TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
You can take a look at hf-tikz package, it's just for highlighting formulas. – giordano Jun 8 '13 at 14:47
up vote 15 down vote accepted

One possibility using TikZ:


  \tikz[remember picture,overlay] \node[inner xsep=0pt] (#1) {};
\node[draw=red!70!black,fill=red!20,align=left,#1] (box\themybox) {#2};


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


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.

share|improve this answer
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 Jun 8 '13 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. – Gonzalo Medina Jun 8 '13 at 14:34
moreover, one can't use equation environment inside a node, to number the formula. I'll keep adjusting spacing. Thanks – giordano Jun 8 '13 at 14:44

Your Answer


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.