Introduction
PDF documents are typically static, but LaTeX enables animations, hyperlinks, and interactive features that transform passive documents into engaging experiences. From animated presentations in Beamer to clickable navigation in long documents, interactive features enhance reader engagement.
This guide covers techniques for creating animated and interactive documents that leverage PDF capabilities.
Beamer Animations
Basic Animation Commands
\documentclass{beamer}
\begin{frame}{Animated Content}
\only<1>{First step}
\only<2>{Second step}
\only<3>{Third step}
\pause
\visible<2->{Appears from slide 2}
\end{frame}
Overlay Specifications
\begin{frame}{Overlay Examples}
% Show on slides 2-4
\onslide<2-4>{Content}
% Show from slide 3 onward
\onslide<3->{Later content}
% Hide from slide 2
\onslide<2->{Visible after slide 2}
% Temporal specification
\temporal<3>{Before slide 3}{Exactly slide 3}{After slide 3}
\end{frame}
Item Animations
\begin{frame}{Step-by-Step}
\begin{itemize}
\item<1-> First point (always visible)
\item<2-> Second point (slide 2+)
\item<3-> Third point (slide 3+)
\end{itemize}
\begin{itemize}[<+->]
\item Auto-incrementing bullets
\item Each appears on new slide
\item No manual numbering needed
\end{itemize}
\end{frame}
Animation Effects
\begin{frame}{Transition Effects}
\transdissolve
Content with dissolve transition
\transwipe[direction=right]
Wipe from right
\transglitter
Glitter effect
\end{frame}
Hyperlinks in Documents
Internal Links
\usepackage{hyperref}
\section{Introduction}
\label{sec:intro}
% Link to section
See Section~\ref{sec:intro} on page~\pageref{sec:intro}
% Clickable link
\hyperref[sec:intro]{Go to Introduction}
% Custom link text
\autoref{sec:intro}
External Links
\usepackage{hyperref}
\url{https://example.com}
\hyperlink{https://example.com}{Visit Example}
\ href{https://example.com}{\textbf{Bold Link}}
Bookmark Navigation
\usepackage{bookmark}
\bookmark[page=1,level=0]{Cover}
\bookmark[page=5,level=1]{Introduction}
\bookmark[page=10,level=1]{Chapter 1}
Interactive Forms
PDF Forms
\usepackage{eforms}
\textField[name=firstname,width=2in]{First Name:}
\checkBox[name=agree,width=10pt,height=10pt]{I agree}
\choiceMenu[name=country,
width=2in,
combo,
populate={Select Country}]{Country:}
{USA,Canada,UK,Germany}
Form Actions
\usepackage{eforms}
\pushButton[name=submit,
width=1in,
onclick={app.alert("Thank you!");}]
{Submit}
\textField[name=email,
width=2in,
validate{event.value=/^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$/;}}]
{Email Address}
Animated Graphics
TikZ Animations
\usepackage{animate}
\begin{animateinline}[autoplay,loop]{10}
\multiframe{10}{i=0+1}{
\begin{tikzpicture}
\draw (0,0) circle (\i mm);
\end{tikzpicture}
}
\end{animateinline}
Graphic Sequence
\usepackage{animate}
\animategraphics[autoplay,loop,controls]{12}%
{images/frame_}{0}{99}
Button-Controlled Animation
\usepackage{animate}
\animategraphics[buttonfg=blue]{5}%
{diagrams/frame_}{1}{20}
% Navigation buttons
\animbtn{First}
\animbtn{Prev}
\animbtn{Play}
\animbtn{Next}
\animbtn{Last}
Media Embedding
Audio Embedding
\usepackageimedia}
\sound[autostart,repeat]{audio.mp3}
\mediaurl[autostart]{http://example.com/audio.mp3}
Video Embedding
\usepackageimedia}
\includemedia[
width=6cm,
height=3.4cm,
activate=pageopen,
addresource=video.mp4,
flashvars={source=video.mp4}
]{}{VPlayer.swf}
3D Objects
\usepackage{media9}
\includemedia[
width=6cm,
height=6cm,
add3Djs,
addresource=cube.u3d,
3Dmenu,
3Dcomposite
]{}{u3d/Primitives.u3d}
JavaScript Integration
Document-Level JavaScript
\usepackage{pdfmanagement-testphase}
\DocumentMetadata{}
\begin{document}
\ExplSyntaxOn
\pdfmanagement_add:nnn {Catalog / Names}{JavaScript~ /~ Names}{
\pdf_object_new:nn {app}{dict}
\pdf_object_write:nn {app}{app}{alert~ {Hello~ World!}}
}
\ExplSyntaxOff
\end{document}
Button Actions
\usepackage{hyperref}
\usepackage{eforms}
\pushButton[name=hello,
onclick={app.alert("Hello from PDF!");}]
{Say Hello}
\textField[name=input]
\pushButton[name=process,
onclick={var~v~=~this.getField("input").value;
app.alert("You~entered:~"+~v);}]
{Process}
Navigation Features
Thumbnails
\usepackage{bookmark}
\bookmark[page=1,level=0,view={Thumbnails:B}]{Cover}
\bookmark[page=5,level=0,view={Thumbnails:B}]{Contents}
Outline (Bookmarks)
\usepackage{bookmark}
\bookmark[level=0]{Title}
\bookmark[level=1,dest=section.1]{Section One}
\bookmark[level=1,dest=section.2]{Section Two}
Best Practices
Performance
- Limit animation complexity
- Compress embedded media
- Test on target PDF viewers
- Provide fallbacks for print
Accessibility
- Ensure links have meaningful text
- Don’t rely solely on color
- Include text alternatives for media
- Test with screen readers
Compatibility
- Test across PDF viewers
- Provide print versions
- Use standard features
- Avoid proprietary extensions
Conclusion
LaTeX enables sophisticated animations and interactive features in PDF documents. From Beamer presentations with animated overlays to full interactive forms, these capabilities transform static documents into engaging experiences.
Use interactivity thoughtfullyโenhance engagement without compromising accessibility or compatibility.
Comments