68

Is there a way to incorporate some slides into an existing slide into my Beamer presentation?

Say, I want to put slide 2 in file A (a Beamer PDF file) into my Beamer presentation, can this be done?

PS: file A is a PDF and does not have bounding box.

Richard
  • 1,157
  • 3
    Every PDF has a bounding box - otherwise it would be broken. – Martin Schröder May 27 '12 at 13:10
  • Formally speaking, a PDF has no "bounding box". Available boxes with their full names are: /MediaBox, /CropBox, /BleedBox, /ArtBox and /TrimBox. The only required box info that must be present in a PDF file is the /MediaBox. If undefined, the other boxes should be assumed by PDF-processing software to have the same values as the /MediaBox... – Kurt Pfeifle May 23 '15 at 15:32

3 Answers3

76

To import a slide from another beamer presentation as a "picture", you can use pdfpages. You'll have to \setbeamercolor{background canvas}{bg=} as explained in this answer because only a white frame will be shown otherwise:

\documentclass{beamer}
\usepackage{pdfpages}
\begin{document}
\begin{frame}
Content
\end{frame}
{
\setbeamercolor{background canvas}{bg=}
\includepdf[pages=3]{filea.pdf}
}
\end{document}

However, if you use head- or footlines or even a different theme in your existing presentation, this will probably not fit snugly. In this case, a better solution would be to actually import the source code of the existing presentation, which can be done using the docmute package in combination with the \againframe command:

Suppose this is your existing presentation filea.tex: You need to give the slides you want to import a name using the label option of the frame environment, like this:

\documentclass{beamer}
\begin{document}
\begin{frame}[label=myframe]
Frame to be included
\end{frame}
\end{document}

Then you can use this code in your new presentation:

\documentclass{beamer}

\usepackage{docmute}
\makeatletter
\newcommand*{\loadpresentation}[1]{{\beamer@inlecturefalse\input{#1}}}
\makeatother

\begin{document}
\loadpresentation{filea.tex}
\begin{frame}
  The new presentation
\end{frame}
\againframe{myframe}
\end{document}

Issuing \loadpresentation{filea.tex} imports the frames from your existing presentation without displaying them. You can insert them wherever needed using \againframe with the label you chose in filea.tex. The command \loadpresentation should be used someplace after \begin{document} (but before you actually include a frame from this presentation, of course).

This works roughly the same as if you'd actually copy the source code of the frame from the existing presentation, so things like overlays etc. are taken over.

diabonas
  • 25,784
29

If you want to put a "thumbnail" of some target beamer PDF fileA in your source, you can use

\includegraphics[page=<n>,width=<len>]{fileA}

where <n> is the absolute page number of the slide in fileA.pdf, and <len> is the width of the imported page. You can also scale this using the other options provided by graphicx. beamer loads graphicx by default, so the functionality is already available.

If you want to put a "full page" of some target beamer PDF fileA in your source, you can use

\begin{frame}
\vspace*{-1pt}
\makebox[\linewidth]{\includegraphics[page=<n>,width=\paperwidth]{fileA}}
\end{frame}

where <n> is the absolute page number of the slide in fileA. The slide is stretched to fit \paperwidth so should overlay the source presentation completely.

The vertical correction (1pt) is needed to maintain a consistent display from one slide to the next.

Werner
  • 603,163
  • this comes with a bounding box error, it seems the fileA does not have bounding box. – Richard May 26 '12 at 16:21
  • @Richard: Not in my minimal testing. You should post two minimal examples as part of your question. One for fileA (if created using LaTeX) and one for you main document. – Werner May 26 '12 at 16:41
  • the main doc is a beamer presentation created in latex, and file A is a pdf generated in Mac. – Richard May 26 '12 at 17:57
  • The amount of vspace needs to be tweaked for the specific style being used, but this works flawlessly for me with PDFs generated by other software such as Keynote or PowerPoint. – András Salamon Aug 24 '18 at 11:45
  • +1: Used this approach many times today (for the first time). Can you explain the reasoning behind `\vspace{-1pt}and\makebox[\linewidth]`? And how is the vertical position determined?* – Dr. Manuel Kuehner Mar 26 '19 at 18:29
  • @Werner, Is there a way to specify more than one page e.g. if the target has more than 1 page? – CKM Aug 05 '19 at 20:46
  • @chandresh: Just include separate images, one from each of the pages you're after. – Werner Aug 05 '19 at 21:57
  • This is what I did as a workaround. I thought there might be a scalable way in case someone wants to include large number of pdf pages. – CKM Aug 06 '19 at 08:07
  • @chandresh: You can include page ranges using pdfpages, but they would be included as-is (sleeved between your other document pages). Using \includegraphics you can select the page you want to include and resize it to fit where you want it. – Werner Aug 06 '19 at 15:37
  • @Werner. Thanks for the suggestion. I did this. { \setbeamercolor{background canvas}{bg=} \includepdf[pages={1-4}, frame=true]{haar-1-4.pdf} } to include multiple pages in beamer. It indeed spills over the entire page. I am not sure what you mean about \includegraphics resizing thing. – CKM Aug 07 '19 at 09:50
  • 1
    @chandresh: When you use \includegraphics, the image (or page) is imported as an object that you can \resizebox as you like. For example, \resizebox{\paperwidth}{\paperheight}{\includegraphics[page=1]{haar-1-4.pdf}\includegraphics[page=2]{haar-1-4.pdf}\includegraphics[page=3]{haar-1-4.pdf}\includegraphics[page=4]{haar-1-4.pdf}} to have 4 pages sized to your dimensions. In general, it allows you to include "thumbnails" of pages and place it wherever you want. If you use \includepdf, adjusting the layout of the imported pages is not always easy. – Werner Aug 07 '19 at 16:07
  • 1
    You can also change the size of the included PDF using scale: \includegraphics[scale=.5]{someDir/myPdf} – Matthias Braun Nov 19 '19 at 08:46
0

I end up with using very basic solution.

how to incorparate slides in existing multi-page pdf (say file A) into my beamer?

@windows, cutepdf to print many one-slide pdfs B from file A.

@ubuntu, pdftops to create per-slide eps C for each pdf B.

then, load those eps C in latex.

Richard
  • 1,157