7

I would like to make an arrow and write some notes as shown below enter image description here

I tried with the following code

\documentclass{beamer} %
\usetheme{CambridgeUS}
\usepackage[latin1]{inputenc}
\usefonttheme{professionalfonts}
\usepackage{times}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}

\author{Author}
\title{Presentation title}

\begin{document}

\frame{
\ft{MATERIAL IN THE UNIVERSE}
\framesubtitle{Simulations need to account for the full cosmic matter-energy content}
\begin{block}{Main ingredients of the Universe:}
\begin{itemize}
\item Dark Energy \hspace{16.3 mm} $\Rightarrow $ expansion, $a(t)$
\item Dark Matter \hspace{16.3 mm} $\Rightarrow $ collisionless fluid, interacting \\ \hspace{68 mm} via gravity
\item Baryonic Matter (`gas') $\Rightarrow $ \tikz[baseline]{\node[fill=green!20,anchor=base] (t1){(magneto)hydrodynamic};},\\ \hspace{68 mm} self-gravity
\end{itemize}
\begin{itemize}[<+-| alert@+>]
    \item that is actually not enough, we need to include sub-resolution physics (cooling, star formation, feedback processes, ...) and we would like to have radiative transport as well
        \tikz[na] \node[coordinate] (n1) {};
\end{itemize}

\begin{tikzpicture}[overlay]
        \path[->]<3-> (n1) edge [out=0, in=-90] (t1);
\end{tikzpicture}

\end{block}
}
\end{document}

But it is giving me the following error

! Undefined control sequence. \beamer@doifinframe ...gas') $\Rightarrow $ \tikz [baseline]{\node [fill=gre... l.185 } The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., \hobx'), typeI' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined.

How can I solve this? What could be the problem? Is there any another easier method to do this?

Thanks

  • 1
    You have to use remember picture in the options of n1 and t1. – user11232 Sep 3 '14 at 6:54
6

You have to use remember picture in the options of n1 and t1 like

\tikz[remember picture] \node[coordinate] (n1) {};

Code:

\documentclass{beamer} %
\usetheme{CambridgeUS}
\usepackage[latin1]{inputenc}
\usefonttheme{professionalfonts}
\usepackage{times}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}

\author{Author}
\title{Presentation title}

\begin{document}

\frame{
\frametitle{MATERIAL IN THE UNIVERSE}
\framesubtitle{Simulations need to account for the full cosmic matter-energy content}
\begin{block}{Main ingredients of the Universe:}
\begin{itemize}
\item Dark Energy \hspace{16.3 mm} $\Rightarrow $ expansion, $a(t)$
\item Dark Matter \hspace{16.3 mm} $\Rightarrow $ collisionless fluid, interacting \\ \hspace{68 mm} via gravity
\item Baryonic Matter (`gas') $\Rightarrow $ \tikz[baseline,remember picture]{\node[fill=green!20,anchor=base] (t1){(magneto)hydrodynamic};},\\ \hspace{68 mm} self-gravity
\end{itemize}
\begin{itemize}[<+-| alert@+>]
    \item that is actually not enough, we need to include sub-resolution physics (cooling, star formation, feedback processes, ...) and we would like to have radiative transport as well
        \tikz[remember picture] \node[coordinate] (n1) {};
\end{itemize}

\begin{tikzpicture}[remember picture,overlay]   %% use here too
        \path[draw=magenta,thick,->]<3-> ([yshift=2mm]n1.north) to [out=0, in=0,distance=1in] (t1.east);
\end{tikzpicture}

\end{block}
}
\end{document}

enter image description here

With tikzmark:

\documentclass{beamer} %
\usetheme{CambridgeUS}
\usepackage[latin1]{inputenc}
\usefonttheme{professionalfonts}
\usepackage{times}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}

\author{Author}
\title{Presentation title}

\newcommand{\tikzmark}[1]{\tikz[remember picture] \node[coordinate] (#1) {#1};}

\begin{document}

\frame{
\frametitle{MATERIAL IN THE UNIVERSE}
\framesubtitle{Simulations need to account for the full cosmic matter-energy content}
\begin{block}{Main ingredients of the Universe:}
\begin{itemize}
\item Dark Energy \hspace{16.3 mm} $\Rightarrow $ expansion, $a(t)$
\item Dark Matter \hspace{16.3 mm} $\Rightarrow $ collisionless fluid, interacting \\ \hspace{68 mm} via gravity
\item Baryonic Matter (`gas') $\Rightarrow $ \tikzmark{t1},\\ \hspace{68 mm} self-gravity
\end{itemize}
\begin{itemize}[<+-| alert@+>]
    \item that is actually not enough,\tikzmark{n1} we need to include sub-resolution physics (cooling, star formation, feedback processes, ...) and we would like to have radiative transport as well
\end{itemize}

\begin{tikzpicture}[remember picture,overlay]
        %\path[draw=magenta,thick,->]<3-> ([yshift=3mm]n1) to ++(0,3mm) to [out=0, in=0,distance=2.5in] (t1);
   \path[draw=magenta,thick,->]<3-> ([yshift=3mm]n1) -- (t1);
\end{tikzpicture}

\end{block}
}
\end{document}

enter image description here

  • 1
    You may better use tikzmark for defining n1 and t1 and also use to instead of edge. edge is a monster with lot of powers and you can expect trouble sometimes with monsters ;-) – user11232 Sep 3 '14 at 7:01
  • 1
    @RSJohn: Use remember picture in \begin{tikzpicture}[remember picture,overlay] \path[draw=magenta,.... also, which I forgot earlier. – user11232 Sep 3 '14 at 7:14
  • With this example, the tikzpicture doesn't just add an arrow, but it also adds spurious blank space where it is put (here, at the bottom of the block). For instance, remove the \begin{tikzpicture} ... \end{tikzpicture} part, and see how the position of the text is modified. How can one eliminate this space? – vinc17 Jun 13 '16 at 15:20
  • Replying to my own comment: the picture needs to be put in an existing paragraph. See my answer. – vinc17 Jun 14 '16 at 12:22
3

First, as already said, remember picture needs to be used in n1 and t1 too, but this can be done globally with:

\tikzstyle{every picture}+=[remember picture]

Moreover, the picture with the arrow needs to be part of a paragraph, as said in answer to Tikzpicture with overlay takes up space. Here's an example with various correct and incorrect solutions:

\documentclass[10pt]{beamer}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}

% Tests of TikZ pictures with remember picture + overlay
% under Debian/unstable on 2016-06-14 (TeX Live 2016).

\begin{document}
\tikzstyle{every picture}+=[remember picture]

%%% Frame without the arrow (expected layout)

\begin{frame}

Text \tikz[baseline] \node[coordinate] (n1) {};

Text \tikz[baseline] \node[coordinate] (t1) {};

\end{frame}

%%% Frame with an arrow - correct (TikZ picture part of a paragraph)

\begin{frame}

Text \tikz[baseline] \node[coordinate] (n1) {};

Text \tikz[baseline] \node[coordinate] (t1) {};
\tikz[overlay]{\path[->]<1-> (n1) edge [bend left] (t1);}%

\end{frame}

%%% Frame with an arrow - correct (TikZ picture part of a paragraph)

\begin{frame}

Text \tikz[baseline] \node[coordinate] (n1) {};

\tikz[overlay]{\path[->]<1-> (n1) edge [bend left] (t1);}%
Text \tikz[baseline] \node[coordinate] (t1) {};

\end{frame}

%%% Frame with an arrow - incorrect due to picture not in a paragraph
%%% The picture takes some space, slightly moving text upwards.

\begin{frame}

Text \tikz[baseline] \node[coordinate] (n1) {};

Text \tikz[baseline] \node[coordinate] (t1) {};

\tikz[overlay]{\path[->]<1-> (n1) edge [bend left] (t1);}%

\end{frame}

%%% Frame with an arrow - also incorrect: the \makebox(0,0) does not help
%%% Same problem.

\begin{frame}

Text \tikz[baseline] \node[coordinate] (n1) {};

Text \tikz[baseline] \node[coordinate] (t1) {};

\makebox(0,0){\tikz[overlay]{\path[->]<1-> (n1) edge [bend left] (t1);}}%

\end{frame}

%%% Frame with an arrow - also incorrect due to picture not in a paragraph
%%% The space taken by the picture is now between the two lines of text.

\begin{frame}

Text \tikz[baseline] \node[coordinate] (n1) {};

\makebox(0,0){\tikz[overlay]{\path[->]<1-> (n1) edge [bend left] (t1);}}%

Text \tikz[baseline] \node[coordinate] (t1) {};

\end{frame}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.