149

I have a PDF file with multiple figures; each figure is a separate page in the PDF file.

I am using pdflatex, and I would like to use \includegraphics or equivalent to include some of the figures.

Of course I could use an external tool to split the PDF file into multiple one-page PDF files. Then I could use \includegraphics as usual. However, I would have a much simpler workflow if I could avoid this extra step. Hence the question:

How can I include, e.g., page 3 of foo.pdf as a figure?

I am aware that there is a Latex package called pdfpages, but it seems to be designed for something else: with pdfpages, each page in the input file will produce a full page in the final document, not just a box.

gernot
  • 49,614
Jukka Suomela
  • 20,795
  • 13
  • 74
  • 91

2 Answers2

190

graphicx (the extended version of graphics) knows the page option:

\includegraphics[page=3]{foo}

should work, or

\includegraphics[page=..,trim=...,clip]{foo}

for only parts of the page. If you want to include more than one page then use Package pdfpages and the command \includepdf

  • 7
    Many thanks, it indeed works! I was already writing that I would like to do something like \includegraphics[page=3]{foo}, but didn't try it, as I couldn't find anything like that in the documentation of the graphicx package... Thus a follow-up question that might help me and others in the future: where is the page= option documented? – Jukka Suomela Dec 29 '10 at 19:35
  • 4
    that is defined only for the driver pdftex, the reason why you find it not in graphicx, but in the file pdftex.def –  Dec 29 '10 at 19:53
  • 12
    But that effectively means that it's not documented at all, since pdftex.def certainly isn't where anyone should look for such information, and other that a single mention that the graphicx package has "automatic pdfTeX support", the pdftex documentation isn't really helpful either. (I've been using graphicx for years and didn't know about this either.) – Alan Munn Dec 29 '10 at 21:17
  • 2
    @Alan: the problem is that most people think that graphicx inserts the graphic, but it didn't, it provides only the useful infos for TeX or pdftex for typesetting. pdftex itself also didn't know anything about the graphic format, but it is the only system, which has its own driver. The others have only drivers for external programs, like dvips, dvipsone, dvipdf and so on. The file pdftex.def has some more useful features. I understand your point, but it is not me who provides pdftex.def ... :-) –  Dec 29 '10 at 21:34
  • 3
    Anyone knows how to put not a entire page, but just a piece. I mean, just 60% of one page in a pdf file. – João Mar 07 '13 at 19:51
  • 4
    @João: use \includegraphics[page=..,trim=...,clip]{file.pdf} –  Mar 08 '13 at 08:32
  • \includegraphics[page=3]{foo} includes ONLY page number 3 for me. Any idea on that?? thanks! – mt1111 Jan 09 '15 at 09:26
  • 1
    @marinko: \includegraphics always includes ONE page. If you want more then use \includepdf –  Jan 09 '15 at 09:53
  • 2
    In case anyone is wondering, this still works for xelatex. – daknowles Jun 06 '17 at 16:42
  • I seem to observe that the document compilation becomes much slower, while including pages in this fashion. Anyone else observed the same? I will try splitting pages to separate PDFs, benchmark and report, perhaps. – Karthik Raman Jan 06 '19 at 07:14
4

Here another possibility using graphics package. In this way you can include each one of the pages than you want from your pdf file ([page= number of the page in the pdf file that you want to include). In the example I want to include a big table that I do in pdf having 2 pages and including that in the TOC like table.

\begingroup

\begin{sidewaysfigure}

    \begin{center}
    %\fbox{
    \includegraphics[page=1, width=\linewidth]{Foo}%}
    \end{center}
\end{sidewaysfigure}


\begin{sidewaysfigure}

    \begin{center}
    %\fbox{
    \includegraphics[page=2, width=\linewidth]{Foo}%}
    \captionof{table}{Caption}
    \label{Zones_intervention_tab}
    \end{center}
\end{sidewaysfigure}

\endgroup
Heiko Oberdiek
  • 271,626
DARIO
  • 61