# Add annotation on beamer slide, simulating hand-drawing?

I would like to add on my beamer slides something that simulate as if I had been drawing a comment by hand. This would circle, come on top of text or formulas, and allows to insert text. Ideally, I could use this with the beamer overlay specification, i.e. add it only in a second step. See example below.

Is there anything that could bring me somewhere close to that?

\documentclass[english]{beamer}

\usepackage{babel}

\begin{document}
\begin{frame}{Make Titles Informative. }

Iintroduce here two theorems:
\begin{theorem}
Algebra

1+2=3
\end{theorem}

\begin{corollary}
2+1=3
\end{corollary}

\end{frame}

\end{document}


Thanks!

## 2 Answers

As pointed out by @cfr, tikzmark is very useful here. In addition, decorations.pathmorphing comes with random steps, which arguably looks as if you would have drawn it with your own claws, err, sorry, hands.

\documentclass[english]{beamer}
\usepackage{tikz}
\usetikzlibrary{tikzmark,decorations.pathmorphing}

\begin{document}
\begin{frame}{Make Titles Informative}

Introduce two \tikzmarknode{theorems}{theorems} here:
\begin{theorem}
Algebra

1+2=3
\end{theorem}

\begin{corollary}
2+1=\tikzmarknode[circle,draw=red,decorate,decoration={random steps,segment
length=1pt,amplitude=0.4pt}]{3}{3}
\end{corollary}
\begin{tikzpicture}[overlay,remember picture,decoration={random steps,segment
length=1pt,amplitude=0.4pt},red]
\draw[decorate] (theorems.south west) -- (theorems.south east)
to[out=-40,in=180] ++ (2,-1) node[right]{comment};
\draw[decorate] (3)
to[out=-40,in=180] ++ (2,-1) node[right]{some text};
\end{tikzpicture}
\end{frame}
\end{document}


• oh, that looks very close to what I need! I was not able to compile though, with error message such as No shape named theorems is known... Also, does this work with beamer overlays, i.e. can you use it with \onslide{}, etc? Thanks!! – Matifou Nov 29 '18 at 4:26
• @Matifou When was the last time you have updated your LaTeX installation? (There is a new version of the tikzmark package, which has the \tikzmarknode command in it, could it be that you do not yet have this version?) – user121799 Nov 29 '18 at 4:30
• This is what I was suspecting indeed. I ave Ubuntu 18.04, and see a line like: tikz.sty 2015/08/07 v3.0.1a (rcs-revision 1.151) in the .log file, does not seem very new indeed... Is there a way to avoid the \tikzmarknode function for now? Thanks! – Matifou Nov 29 '18 at 4:53
• @Matifou I really LOVE this new function. What precisely prevents you from updating? (My problem is that it is very hard to check if a downgraded code really works because I cannot install the older version of tikzmark easily without spoiling my other TeX documents. On the other hand, you could just download the more recent version from CTAN in your local directory, and I am almost 100% sure it will work. A cleaner way would, however, be to update your LaTEX installation, which AFAIK does not mean you need to update UBUNTU.) – user121799 Nov 29 '18 at 5:01
• ok, I'll work on updating the pkg, makes sense. For now just copy/paste all files in the tikz pkg, base/tex did not help much, but hopefully I'll sort it soon. Did you geta chance to see if the tikz could be used with the beamer overlays? That would be aweseome :-) Thanks!!! – Matifou Nov 29 '18 at 5:21

If you got problems with tikzmark, here is a pure TikZ solution.

The command \mypos has 2 arguments: what to highlight and the name you would like to give to it. If the numbers are in math mode put $...$ in \mypos first argument.

\documentclass[english]{beamer}

\usepackage{babel}
\usepackage{tikz}
\newcommand{\mypos}[2]{\tikz[remember picture]{\node[inner sep=0pt, anchor=base](#2){#1};}}
\newcommand{\myund}{}
\begin{document}
\begin{frame}{Make Titles Informative. }

Iintroduce here two \mypos{theorems}{myth}:
\begin{theorem}
Algebra

1+2=3
\end{theorem}

\begin{corollary}
2+1=\mypos{3}{mynum}
\end{corollary}
\begin{tikzpicture}[overlay, remember picture]
\node[draw, red, circle] (A) at (mynum){};
\draw[red] ([yshift=-2pt]myth.south west)--([yshift=-2pt]myth.south east) to[bend right] ++(1,-1) node[red, anchor=west] {Comment};
\draw[red] (A.south east) to[bend right] ++(1,-1) node[red, anchor=west] {Some text};
\end{tikzpicture}
\end{frame}


\end{document}

• Oh great!!! And it seems using just \onslide<2->{ \begin{tikzpicture}.....} makes it appear on slide 2 only, nice!!! – Matifou Nov 29 '18 at 8:11
• @Matifou I'm happy you find it useful! – CarLaTeX Nov 29 '18 at 8:43