58

I have a pdf file consisting of four pages (see attached). I want to include it in Latex, but when I use the basic code given below, only the first page of the pdf appears. I want to do is to present one pdf page in each latex file. Suggestions please

\begin{figure}[h!]
\centering
\includegraphics[scale=0.77]{bplot.pdf}

enter image description here

0

6 Answers 6

94

for a single page of a multipage .pdf:

\documentclass{article}
\usepackage{graphicx}
\begin{document}

\includegraphics[page=2,scale=0.75]{bplot.pdf}      

\end{document}

or if you want all pages:

\documentclass{article}
\usepackage{pdfpages}
\begin{document}

\includepdf[pages={1-},scale=0.75]{bplot.pdf}

\end{document}
14
  • Thanks @Herbert. This is what I was after. How could I scale the pdf? \includepdf[pages=1-]{scale=0.51}{bplot.pdf} does not work
    – Günal
    Jan 12, 2013 at 12:52
  • I modified my answer, see the example.
    – user2478
    Jan 12, 2013 at 12:53
  • how can I add a caption?
    – Günal
    Jan 12, 2013 at 18:57
  • for every page or the last one?
    – user2478
    Jan 12, 2013 at 19:12
  • for the last one
    – Günal
    Jan 12, 2013 at 21:52
25

You can use pdfpages package.

\documentclass{article}
\usepackage{pdfpages}

\begin{document}

\includepdf[pages=2]{bplot.pdf}

\end{document}

The [pages=2] displayes the first page. To insert multiple pages, insert a list such as [pages={1,4}] or a range such as [pages={1-4}]. Check the pdfpages manual for details on package and command options.

4
  • This adds only the first page. Is there another package I should be using?
    – Günal
    Jan 12, 2013 at 12:41
  • I used \includepdf[pages=2]{bplot.pdf} \includepdf[pages=3]{bplot.pdf} etc. The problem is now the scale. I used \includepdf[pages=3][scale=0.5]{bplot.pdf}, that soes not work. Any suggestions?
    – Günal
    Jan 12, 2013 at 12:47
  • @Günal added to the reply. The argument templatesize={width}{height} should provide scaling. See the pdfpages manual for the details. Jan 12, 2013 at 12:52
  • 1
    To display all pages, input pages=-
    – Marten
    Apr 7 at 14:07
7

Compile the following code with either pdflatex or xelatex.

\documentclass{article}
\usepackage[a5paper,margin=2cm,showframe]{geometry}
\usepackage{graphicx}
\usepackage{multido}
\usepackage{ifxetex}

\ifxetex
    \newcount\pdflastximagepages
    \def\pdfximage#1{\pdflastximagepages=\XeTeXpdfpagecount"#1"\relax}
\fi

\def\filename{pst-fun-doc.pdf}
\def\scale{0.4}
\pdfximage{\filename}

\begin{document}
    \multido{\i=1+1}{\the\pdflastximagepages}{%
        \begin{center}
        \fbox{\includegraphics[page=\i,scale=\scale]{\filename}}
        \end{center}
        \newpage
    }
\end{document}

Output:

enter image description here

4
  • Top secret note: Compiling it with xelatex produces a weird PDF. Please try! Jan 12, 2013 at 13:31
  • I have no problem with xelatex. Current up-to-date TL2012
    – user2478
    Jan 12, 2013 at 14:23
  • @Herbert: OK. Thanks for confirming. I still get the same weird result. Jan 12, 2013 at 14:28
  • How do you make that crazy animated gif?
    – vy32
    Apr 12, 2019 at 16:08
7

A tcbraster combined with tcbincludepdf can also be used to include framed pages from an external file into another document.

tcolorbox will do all scaling work.

\documentclass{article}
\usepackage[most]{tcolorbox}

\begin{document}
\begin{tcbraster}[%
    raster columns=1,
    colframe = blue,
    colback = white,
    colbacktitle = blue!50,
    fonttitle = \small\ttfamily,
    boxsep = 0pt,
    toptitle = 1mm,
    bottomtitle = 1mm,
    drop lifted shadow,
    center title,
    graphics pages = {1,...,3},
    title = {\imagename\ [\imagepage]}]
\tcbincludepdf{tcolorbox.pdf}
\end{tcbraster}

\begin{tcbraster}[%
    raster columns=2,
    colframe = blue,
    colback = white,
    colbacktitle = blue!50,
    fonttitle = \small\ttfamily,
    boxsep = 0pt,
    toptitle = 1mm,
    bottomtitle = 1mm,
    drop lifted shadow,
    center title,
    graphics pages = {4,...,20},
    title = {\imagename\ [\imagepage]}]
\tcbincludepdf{tcolorbox.pdf}
\end{tcbraster}
\end{document}

enter image description here

4

Another way (derived from kiss) :

\documentclass{article}
\usepackage[a5paper,margin=2cm,showframe]{geometry}
\usepackage{graphicx}
\usepackage{multido}
\usepackage{ifxetex}

\ifxetex
    \newcount\pdflastximagepages
    \newcommand\pdfximage#1{\pdflastximagepages=\XeTeXpdfpagecount"#1"\relax}
\fi
\newcommand{\ajoutpdf}[2] {
    \pdfximage{#1}
    \multido{\i=1+1}{\the\pdflastximagepages}{%
        \includegraphics[page=\i,scale=#2]{#1}
        \newpage
    }
}
\begin{document}
\ajoutpdf{pdf/my.pdf}{.8}
\end{document}
4

As described in the documentation you can insert all pages of a pdf by using: pages- option

 \includepdf[pages=-]{my_pdf.pdf}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .