A PDF can carry more than static pages — attached files, toggleable layers, animations, even media. LaTeX exposes these through small packages. One caveat, though: how much actually works depends on the PDF viewer (the fanciest features lean on Adobe Acrobat, and some broke when Flash died). This page surveys them with that in mind.
Attaching and embedding files
You can embed a file inside the PDF. attachfile (and the improved attachfile2) gives \attachfile{file}, which places a clickable paperclip icon, and \textattachfile{file}{link text}, which makes your own text the link. embedfile’s \embedfile{file} attaches a file with no visible icon (handy for shipping the .tex source inside the PDF). Attachments are broadly supported across viewers.
\usepackage{attachfile}
\attachfile{data.csv} % クリップのアイコン / paperclip icon
\textattachfile{data.csv}{データを開く} % 任意のリンク文字 / custom link textLayers — ocgx2
A PDF’s OCG (Optional Content Groups, i.e. layers) are layers you can show or hide. ocgx2 (by Alexander Grahn) wraps content in \begin{ocg}{name}{id}{initial visibility}…\end{ocg} and provides clickable toggles (\toggleocgs, \showocgs, \hideocgs). Great for step-by-step reveals or interactive figures — but toggling works mainly in Acrobat; other viewers may show only the initial state.
\usepackage{ocgx2}
\begin{ocg}{答え}{ans}{0} % 0 = 初期は非表示 / initially hidden
これが答えです。
\end{ocg}
\toggleocgs{ans}{答えの表示/非表示}Animation — animate
animate (by Alexander Grahn) builds JavaScript-driven animations inside the PDF. \animategraphics turns a numbered series of images (or a multipage PDF) into a playable clip with controls; the animateinline environment animates inline frames (TikZ, PSTricks, text). Being JS-based, it works in several viewers (Acrobat, Okular, Foxit, pdf.js) — more portable than embedded video.
\usepackage{animate}
% 12fps、frame-0 … frame-59 を再生 / play frame-0 … frame-59 at 12 fps
\animategraphics[controls,autoplay]{12}{frame-}{0}{59}Multimedia — media9 (with a caveat)
media9’s \includemedia embeds video, audio, and 3D; movie15 is its obsolete predecessor. Important caveat: media9 relied on the Flash Player built into Adobe Reader, and Flash is gone — so embedded video is largely unplayable in today’s viewers. For new work, link to external media instead, or use animate for frame-based motion. Treat media9 as legacy.