Tell me more ×
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 would like to display a sequence of images in a timed fashion in beamer i.e. I want to zoom an image from small size to large size. Below is the code I tried and I get some errors while compiling.

\documentclass{beamer}

\usetheme{Copenhagen}
\usecolortheme{whale}
\useinnertheme{rounded}

\usepackage{tikz}
\usepackage{calc}
\usepackage{forloop}

\begin{document}

\newcounter{k}
\forloop{k}{1}{\value{k} < 11}{
\begin{frame}
\transduration{0.1}
\includegraphics[scale=\value{0.01\arabic{k}}]{images/my_image.pdf}
\end{frame}
}

\end{document}
share|improve this question

2 Answers

up vote 6 down vote accepted

You can do something like this, using TikZ's \foreach and the overlay specification for \includegraphics:

\documentclass{beamer}
\usetheme{Copenhagen}
\usecolortheme{whale}
\useinnertheme{rounded}
\usepackage{tikz}

\begin{document}

\begin{frame}
\centering
\transduration{0.1}
\foreach \k [evaluate=\k as \kscale using \k/100] in {1,2,...,10}
  {\includegraphics<\k>[scale=\kscale]{ctanlion}}

\end{frame}

\end{document}

enter image description here

CTAN lion drawing by Duane Bibby.

share|improve this answer
Thanks Gonzalo Medina! – user17762 Oct 19 '12 at 1:45

The use of \transduration requires Adobe Reader for display. Therefore, one could also use the animate package. The animation is embedded in a single physical page of the final PDF:

\documentclass{beamer}
\usetheme{Copenhagen}
\usecolortheme{whale}
\useinnertheme{rounded}
\usepackage{animate}

\newsavebox\imgbox
\sbox\imgbox{\includegraphics[scale=0.5]{ctanlion}}

\begin{document}

\begin{frame}
\begin{center}
\begin{animateinline}[loop,autoplay]{10} %10 frames per s
\multiframe{10}{rScale=0.1+0.1}{
  \hbox to \wd\imgbox{
    \hss  %\hss, \vss -->stretchable space for centering
    \vbox to \ht\imgbox{\vss\scalebox{\rScale}{\usebox\imgbox}\vss}
    \hss
  }
}
\end{animateinline}
\end{center}
\end{frame}

\end{document}
share|improve this answer
Thanks. `\transduration' also works with Document viewer on ubuntu, which is what I use to open pdf files. – user17762 Oct 19 '12 at 18: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.