Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have two different animations, made with TikZ and the animate package, that I want to include in a beamer presentation. When I had the code inside of my presentation's .tex file everything worked fine, then I tried to move the animation code into separate files and include them with \input, and it stops working.

Here's the especially weird thing: If I include only one of the animations and comment out the other, the code works. When I include both animations I get an error about

Missing \endgroup inserted

or

Something's wrong: perhaps a missing \item?

depending on whether I comment out the first or second \input. Any advice would be most appreciated. Below is a piece of the code just to give you an idea of what I'm doing (my complete preamble is included, just in case one of the other packages is what's causing issues).

\documentclass[xcolor=dvipsnames]{beamer}
\usepackage{mathrsfs}
\usepackage[absolute,overlay]{textpos}
\mode<presentation>
{
   \usetheme{Singapore}
   \usecolortheme{seahorse}
   \setbeamercovered{transparent}
}
\usepackage{tikz}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{color}
\usepackage{animate}  % Animations
\usepackage{fp}       % Fixed point calculations
\usepackage{ifthen}
\usepgflibrary{arrows}
\usetikzlibrary{decorations.markings, arrows, decorations.pathmorphing,
  backgrounds, positioning, fit, shapes.geometric}

\newcounter{frame}
\setcounter{frame}{0}

\begin{document}
\begin{frame}[fragile]{Animation 1}
  \begin{center}
    \input{animations/anim1.tex}
  \end{center}
\end{frame}

\begin{frame}[fragile]{Animation 2}
  \begin{center}
    \input{animations/anim2.tex}
  \end{center}
\end{frame}
\end{document}

anim1.tex and anim2.tex are identical:

\begin{animateinline}[autoplay, loop, controls, poster=first]{15}
  \whiledo{\theframe < 179}{
    \begin{tikzpicture}
      \draw (-3, -3) rectangle (3, 3);
      \filldraw (\theframe : 2cm) circle (0.05cm);
    \end{tikzpicture}

    \stepcounter{frame}
    \ifthenelse{\theframe < 179}{
      \newframe
    }{
    \end{animateinline}
   }
}

I'm very much a newbie with the animate package, so perhaps someone who's more knowledgeable will easily recognize what's wrong, but this is very frustrating right now.

Any help would be most appreciated.

share|improve this question
1  
Your preamble loads too many packages. It is recommended to remove the unnecessary packages from your current MWE. And please show your anim1.tex and anim2.tex. –  stalking is prohibited Mar 31 '13 at 18:57
    
Added an example of anim1.tex and anim2.tex. –  cjohnson Mar 31 '13 at 19:38
    
Where is the frame counter defined? –  stalking is prohibited Mar 31 '13 at 20:24
    
My mistake: I copied/pasted and in cutting out some irrelevant things from the preamble, got rid of frame. –  cjohnson Mar 31 '13 at 20:37
    
See my answer for the latest update. –  stalking is prohibited Mar 31 '13 at 20:42

1 Answer 1

up vote 1 down vote accepted
\documentclass{beamer}
\usepackage{tikz}
\usepackage{animate}
\usepackage{filecontents}

\begin{filecontents*}{anim1.tex}
\begin{animateinline}[autoplay, loop, controls, poster=first]{15}
  \multiframe{181}{iAngle=0+1}{%
    \begin{tikzpicture}
      \draw (-3, -3) rectangle (3, 3);
      \filldraw (\iAngle : 2cm) circle (0.05cm);
    \end{tikzpicture}}
\end{animateinline}
\end{filecontents*}

\begin{filecontents*}{anim2.tex}
\begin{animateinline}[autoplay, loop, controls, poster=first]{15}
  \multiframe{181}{iAngle=0+1}{%
    \begin{tikzpicture}
      \draw (-3, -3) rectangle (3, 3);
      \filldraw (\iAngle : 2cm) circle (0.05cm);
    \end{tikzpicture}}
\end{animateinline}
\end{filecontents*}


\begin{document}
\begin{frame}[fragile]{Animation 1}
  \begin{center}
    \input{anim1.tex}
  \end{center}
\end{frame}

\begin{frame}[fragile]{Animation 2}
  \begin{center}
    \input{anim2.tex}
  \end{center}
\end{frame}
\end{document}
share|improve this answer
    
If you borrow code from an answer in the site, you should mention the source. –  egreg Mar 31 '13 at 19:51
    
@egreg: Done. Thanks. –  stalking is prohibited Mar 31 '13 at 19:55
    
I don't understand your answer. Are you claiming I should create a separate PDF for the animation and then include it with \animategraphics? Also, my question explicitly says that everything works fine with one \input (as is used in your example), but doesn't work once I use \input twice. –  cjohnson Mar 31 '13 at 20:00
    
Seems to work now. Thanks for your help! –  cjohnson Mar 31 '13 at 21:13

Your Answer

 
discard

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.