13

I'm trying to reproduce the example on creating a Presentation with LaTeX Beamer – Equations and tikz and the given code throws the following error

Package pgfkeys Error: I do not know the key '/tikz/na'.

The LaTex code is

\documentclass[compress]{beamer}
\usetheme{Warsaw}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}

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

\begin{document}

\begin{frame}
\frametitle{Test}


\begin{itemize}
\item Overall mean \tikz[na] \node[coordinate] (s1) {};
\end{itemize}

\tikzstyle{na} = [baseline=-.5ex]

\begin{equation}
y_{ijk} = \tikz[baseline]{ \node[fill=blue!20,anchor=base,rounded corners=2pt]
  (d1) {$\mu$}; }
+ \tikz[baseline]{ \node[fill=red!20,anchor=base,rounded corners=2pt]
  (d2) {$r_{i}$}; }
+ \tikz[baseline]{ \node[fill=green!20,anchor=base,rounded corners=2pt]
  (d3) {$c_{j}$}; }
+ \tikz[baseline]{ \node[fill=yellow!20,anchor=base,rounded corners=2pt]
  (d4) {$t_{k}$}; }
+ \epsilon_{ijk}
\end{equation}

\begin{itemize}
\item Effect of row $i$ \tikz[na] \node[coordinate] (s2) {};
\item Effect of column $j$ \tikz[na] \node[coordinate] (s3) {};
\item Effect of treatment $k$ \tikz[na] \node[coordinate] (s4) {};
\end{itemize}

\begin{tikzpicture}[overlay]
\path[->] (s1) edge [bend left] (d1);
\path[->] (s2) edge [bend right] (d2);
\path[->] (s3) edge [out=0, in=-90] (d3);
\path[->] (s4) edge [out=0, in=-90] (d4);
\end{tikzpicture}

\end{frame}

\end{document}

Also my equation is not animated. Any help to fix this error will be highly appreciated. Thanks

13

If you move the \tikzstyle{na} = [baseline=-.5ex] to be in the preamble, then it compiles:

enter image description here

Notes:

Animation:

  • Since you are using the beamer class, the \pause macro can be used to create the effect of animation across several slides:

    \begin{tikzpicture}[overlay]                  \pause
        \path[->] (s1) edge [bend left] (d1);     \pause
        \path[->] (s2) edge [bend right] (d2);    \pause
        \path[->] (s3) edge [out=0, in=-90] (d3); \pause
        \path[->] (s4) edge [out=0, in=-90] (d4); \pause
    \end{tikzpicture}
    

With this change and two compiles, you should get an 6 page document that I think will do what you are looking for.

enter image description here


Code:

\documentclass[compress]{beamer}
\usetheme{Warsaw}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}

\tikzstyle{every picture}+=[remember picture]
\tikzstyle{na} = [baseline=-.5ex]

\begin{document}

\begin{frame}
\frametitle{Test}


\begin{itemize}
\item Overall mean \tikz[na] \node[coordinate] (s1) {};
\end{itemize}


\begin{equation}
y_{ijk} = \tikz[baseline]{ \node[fill=blue!20,anchor=base,rounded corners=2pt]
  (d1) {$\mu$}; }
+ \tikz[baseline]{ \node[fill=red!20,anchor=base,rounded corners=2pt]
  (d2) {$r_{i}$}; }
+ \tikz[baseline]{ \node[fill=green!20,anchor=base,rounded corners=2pt]
  (d3) {$c_{j}$}; }
+ \tikz[baseline]{ \node[fill=yellow!20,anchor=base,rounded corners=2pt]
  (d4) {$t_{k}$}; }
+ \epsilon_{ijk}
\end{equation}

\begin{itemize}
\item Effect of row $i$ \tikz[na] \node[coordinate] (s2) {};
\item Effect of column $j$ \tikz[na] \node[coordinate] (s3) {};
\item Effect of treatment $k$ \tikz[na] \node[coordinate] (s4) {};
\end{itemize}

\begin{tikzpicture}[overlay]
\path[->] (s1) edge [bend left] (d1);
\path[->] (s2) edge [bend right] (d2);
\path[->] (s3) edge [out=0, in=-90] (d3);
\path[->] (s4) edge [out=0, in=-90] (d4);
\end{tikzpicture}

\end{frame}

\end{document}
  • Thanks @Peter for your help. Using your suggestion there is no error but not still there is no animation. I wonder how to get the animation of arrows. Any idea. Thanks – MYaseen208 May 10 '12 at 5:25
  • @HarishKumar: Maybe I have a faster internet connection. :-) – Peter Grill May 10 '12 at 5:28
  • @MYaseen208: I don't see anything about animation in the code or the page you linked to. – Peter Grill May 10 '12 at 5:28
  • Sorry @PeterGrill, my bad! Would you mind to guide me how to animate these arrows. Thanks – MYaseen208 May 10 '12 at 5:33
  • @MYaseen208: I am not an expert in beamer, but perhaps the updated solution is what you are looking for. The only other animation I have experience with is Sieve of Eratosthenes in tikz – Peter Grill May 10 '12 at 5:40
12

This is supposed to be the supplement for @Peter Grill's solution regarding animation. One can use <1-> thing as in this MWE:

\documentclass[compress]{beamer}
\usetheme{Warsaw}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}

\tikzstyle{every picture}+=[remember picture]
\tikzstyle{na} = [baseline=-.5ex]

\begin{document}

\begin{frame}
\frametitle{Test}


\begin{itemize}
\item<2-> Overall mean \tikz[na] \node[coordinate] (s1) {};
\item<1->[]{%
\begin{equation}
y_{ijk} = \tikz[baseline]{ \node[fill=blue!20,anchor=base,rounded corners=2pt]
  (d1) {$\mu$}; }
+ \tikz[baseline]{ \node[fill=red!20,anchor=base,rounded corners=2pt]
  (d2) {$r_{i}$}; }
+ \tikz[baseline]{ \node[fill=green!20,anchor=base,rounded corners=2pt]
  (d3) {$c_{j}$}; }
+ \tikz[baseline]{ \node[fill=yellow!20,anchor=base,rounded corners=2pt]
  (d4) {$t_{k}$}; }
+ \epsilon_{ijk}
\end{equation}}%

\item<3-> Effect of row $i$ \tikz[na] \node[coordinate] (s2) {};
\item<4-> Effect of column $j$ \tikz[na] \node[coordinate] (s3) {};
\item<5-> Effect of treatment $k$ \tikz[na] \node[coordinate] (s4) {};
\end{itemize}


\begin{tikzpicture}[overlay]
\path<2->[->] (s1) edge [bend left] (d1);
\path<3->[->] (s2) edge [bend right] (d2);
\path<4->[->] (s3) edge [out=0, in=-90] (d3);
\path<5->[->] (s4) edge [out=0, in=-90] (d4);
\end{tikzpicture}

\end{frame}
\end{document}

enter image description here

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.