beamer
beamer copied to clipboard
Make beamer's \againframe work with xr package
Suppose I'd like to extract from a main (long) beamer file some of the frames it contains. It would be nice if the xr package could work with \againframe, as in the following example (where the compilation of extracted-frames.tex fails):
\begin{filecontents*}[overwrite]{extracted-frames}
\documentclass{beamer}
\usepackage{xr}
\externaldocument{main}
\begin{document}
\againframe{bar}
\end{document}
\end{filecontents*}
\documentclass{beamer}
\begin{document}
\begin{frame}[label=foo]
\frametitle{Foo}
Foo
\end{frame}
\begin{frame}[label=bar]
\frametitle{Bar}
Bar
\end{frame}
\end{document}
xr and againframe are quite different things. xr gives a reference, but with againframe you actually want a frame content.
You could try something like this:
Main file
\documentclass{beamer}
\begin{document}
\begin{frame}[fragile,label=foo]
\frametitle{Foo}
Foo
\end{frame}
\begin{frame}[fragile,label=bar]
\frametitle{Bar}
Bar
\end{frame}
\end{document}
With the fragile option, beamer will write files main.1.vrb and main.2.vrb.
You could then reinsert e.g. the second frame with something like this:
\documentclass{beamer}
\usepackage{xr}
\externaldocument{main}
\usepackage{refcount}
\begin{document}
\begin{frame}
\input{main.\getpagerefnumber{bar}.vrb}
\end{frame}
\end{document}
\end{filecontents*}
I did not check what happens if overlays are involved and if you actually need xr-hyper instead of xr.