57

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

Günal
  • 3,393
  • 8
  • 31
  • 31

6 Answers6

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}
WillAdams
  • 7,187
  • 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 '13 at 12:52
  • I modified my answer, see the example. –  Jan 12 '13 at 12:53
  • how can I add a caption? – Günal Jan 12 '13 at 18:57
  • for every page or the last one? –  Jan 12 '13 at 19:12
  • for the last one – Günal Jan 12 '13 at 21:52
  • insert the last one with \includegraphics and use \caption as usual –  Jan 13 '13 at 08:24
  • @Herbert The \includepdf command is not working as expected. The pdf is still showing only one page and overwrites on the text. It doesnt seem to work with \Floatbarrier which I am using to keep the graphs in the same section. Any solutions? Many thanks. – Anusha Sep 23 '14 at 06:39
  • All the pages in the pdf are getting overlapped. – Anusha Sep 23 '14 at 06:42
  • \includepdf inserts complete pages. If you do not want that use \includegraphics –  Sep 23 '14 at 07:11
  • @Herbert The page is not showing with \includepdf and overwrites on the text. I tried using \clearpage as well but only the first page is showing. Even if use \includegraphics and break it into pages by specifying page = 1, .. page = 5 etc, only the first two pages get printed. Rest seem to be hidden. Please help. – Anusha Sep 23 '14 at 08:15
  • I cannot help without a test document which shows that behaviour. –  Sep 23 '14 at 08:20
  • Should I post as a question then ? In the meantime, is there a limit on the number of includepgraphics[page = 1] used. I had to break 10 pages into two per figure environment. Is there any other environment I should use ? – Anusha Sep 23 '14 at 08:27
  • post a new question! –  Sep 23 '14 at 08:33
  • Got it. \includepdf does not work with the figure environment and I was using that to include captions. For completeness, use \captionof from package caption. – Anusha Sep 23 '14 at 16:35
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.

moewe
  • 175,683
  • This adds only the first page. Is there another package I should be using? – Günal Jan 12 '13 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 '13 at 12:47
  • @Günal added to the reply. The argument templatesize={width}{height} should provide scaling. See the pdfpages manual for the details. – Peter Jansson Jan 12 '13 at 12:52
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

Ignasi
  • 136,588
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

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}
RomainL.
  • 143