3

I'm new to LaTeX and currently working on my first beamer presentation.I tried to add already proven formulas in a proof as a comment using TikZ since I saw something similar here. My current status is this:

\documentclass[beamer,compress,t]{beamer}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\usetikzlibrary{shapes.callouts}

\begin{document}
\begin{frame}
\frametitle{Title}

\[\norm{a-b} \tikz[remember picture] \node (a) {$\leq$}; \norm{a} + \norm{b} \]

\begin{tikzpicture}[remember picture,overlay]
\path<2> (a.south) ++(0,1) node[anchor=north,rectangle callout,fill=blue!50,opacity=1, callout absolute pointer={(a.mid)}]  {From $\Delta$};
\end{tikzpicture}
\pause \pause
\[\norm{\lambda x} = \lambda \norm{x} \]
\end{frame}

\end{document}

which results in this:

enter image description here

This works reasonably well, but I'd like the \leq sign not to move up and the box to be under the sign. However, it seems like this isn't an anchor option. I tried looking this up, but the TikZ help seems a little intimidating right now.

Stefan Pinnow
  • 29,535
Jabor
  • 41

2 Answers2

2

If I understand correctly, you want something like this?

enter image description here

You can prevent the \leq from moving by identifying the baseline in the \tikz command before the tikzpicture. The callout can be placed below simply by using a negative sign in your relative positioning, such as ++(0,-0.5). You can adjust anchors and distances as you like. Code is below.

\documentclass[beamer,compress,t]{beamer}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\usetikzlibrary{shapes.callouts}

\begin{document}
\begin{frame}
\frametitle{Title}

\[\norm{a-b} \tikz[remember picture,baseline=(a.base)] \node (a) {$\leq$}; \norm{a} + \norm{b} \]

\begin{tikzpicture}[remember picture,overlay]
\path<2> (a.south) ++(0,-0.5) node[anchor=north,rectangle callout,fill=blue!50,opacity=1, callout absolute pointer={(a.south)}]  {From $\Delta$};
\end{tikzpicture}
\pause \pause
\[\norm{\lambda x} = \lambda \norm{x} \]
\end{frame}

\end{document}
erik
  • 12,673
1

For the second part of your question, the trick is to stick in the overlay first. For the first part, look at the anchor and baseline arguments to the node.

enter image description here

\documentclass[beamer,compress,t]{beamer}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{tikz}


\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\usetikzlibrary{shapes.callouts}

\begin{document}
    \begin{frame}
        \frametitle{Title}

        \begin{tikzpicture}[remember picture,overlay]
        \path<2> (a.south) ++(0,1.2) node[anchor=north,rectangle callout,fill=blue!50,opacity=1, callout absolute pointer={(a.mid)}]  {From $\Delta$};
        \end{tikzpicture}
        \[\norm{a-b} \tikz[remember picture,anchor=base,baseline] \node (a)  {$\leq$}; \norm{a} + \norm{b} \]

        \pause \pause
        \[\norm{\lambda x} = \lambda \norm{x} \]
    \end{frame}

\end{document}
JPi
  • 13,595