681

I am trying to insert a PDF or doc file as an appendix in my LaTeX file. Do you know how I can do this?

Matthias Braun
  • 32,039
  • 22
  • 142
  • 171
Guido
  • 6,853
  • 3
  • 16
  • 9
  • 14
    Are you just appending the pdf, or do you want to embed it like a picture? – zdav Apr 29 '10 at 16:52
  • 17
    Note to anyone thinking of suggesting we migrate this to text.stackexchange - we can't. It's from 2010 which makes it far too old to migrate. – ChrisF Mar 27 '15 at 17:11
  • 1
    See also: [Insert PDF file in LaTeX document](http://tex.stackexchange.com/q/105589/5645) – Martin Thoma Jan 22 '16 at 19:36
  • See also: https://tex.stackexchange.com/questions/8662/merge-two-pdf-files-output-by-latex – 0 _ Sep 17 '17 at 16:38

6 Answers6

996

Use the pdfpages package.

\usepackage{pdfpages}

To include all the pages in the PDF file:

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

To include just the first page of a PDF:

\includepdf[pages={1}]{myfile.pdf}

Run texdoc pdfpages in a shell to see the complete manual for pdfpages.

IcyFlame
  • 5,059
  • 21
  • 50
  • 74
Mica
  • 18,501
  • 6
  • 46
  • 43
  • 186
    To be clear, you need to specify the pages you wish to include, i.e. `\includepdf[pages={1,3,5}]{myfile.pdf}` would include pages 1, 3, and 5 of the file. To include the entire file, you specify `pages={-}`, where `{-}` is a range without the endpoints specified which default to the first and last pages, respectively. – rcollyer Apr 30 '10 at 01:39
  • 55
    The first two things I had to also do were to scale and to reenable my outer page design (to show page numbers again) which can both be set using the configuration, e.g.: `\includepdf[pages=-,scale=.8,pagecommand={}]{file}` – LeoR Dec 19 '12 at 14:30
  • `\includepdf[pages={1}]{myfile.pdf}` adds the first page of myfile.pdf to the generated pdf and number it 1. What if I'm adding a cover and I want to number it C so it doesn't disturb the numbers of other pages? – user5402 Aug 18 '13 at 22:26
  • @mikepurvis care to share more details? an error message perhaps? – Mica Jun 10 '14 at 05:26
  • It sounds like it's a fairly basic incompatibility: http://tex.stackexchange.com/a/60211/53854 – mikepurvis Jun 10 '14 at 11:04
  • 6
    it does not seem to work with latex beamer; here is how to do it with beamer: http://tex.stackexchange.com/questions/57441/how-to-include-existing-pdf-slides-into-my-beamer – thias Aug 27 '14 at 12:23
  • If you want proper chapter or section headers for your PDF pages, consider [this](https://tex.stackexchange.com/questions/5911/how-to-include-pdf-pages-without-a-newpage-before-the-first-page#85613). – Matthias Braun Jun 03 '15 at 14:39
  • 4
    The offset option is useful `\includepdf[page={-},offset=mm mm]{myfile.pdf}` – Katu Nov 27 '15 at 22:10
  • It doesn't work for me. It compiles fine, but then displays several blank pages. – Fly by Night May 10 '17 at 16:07
  • @rcollyer `pages={-}` will include whole file, but can one somehow include whole file except few pages? For example, if someone wanted to include 99 out of 100 pages, does we have to write down all the numbers from 1 to 99 manually, or we can somehow exclude this single page? – Kusavil Jan 10 '18 at 18:57
  • 2
    @Kusavil from the (docs)[http://mirrors.sorengard.com/ctan/macros/latex/contrib/pdfpages/pdfpages.pdf], you can specify ranges, e.g. if you wanted to drop page 49 out of 100 total, you could use `pages={1-48,50-100}`. Not as simple as say something like, `pages={!49}`, but not that arduous. – rcollyer Jan 10 '18 at 20:20
  • Is there any way to do more zoom in the pdf file? –  Sep 13 '21 at 13:05
  • any idea how can i open/import pdf files in the web version of letex called overleaf – Muhammad Uzair Apr 23 '22 at 21:54
  • Can we change its sizing? – alper May 27 '23 at 17:12
103

For putting a whole pdf in your file and not just 1 page, use:

\usepackage{pdfpages}

\includepdf[pages=-]{myfile.pdf}
RobinAugy
  • 1,379
  • 3
  • 11
  • 18
  • 5
    you can just use \includepdf{myfile.pdf} –  Jan 02 '16 at 18:00
  • 2
    @CroCo yeah, for some reason sometimes it works and sometimes it doesn't, sorry for misleading you :( –  Apr 14 '16 at 01:34
55
\includegraphics{myfig.pdf}
dagray
  • 877
  • 6
  • 3
  • 5
    yes i know how to include a figure.pdf but the file i have to include has more then 1 page. – Guido Apr 29 '10 at 17:06
  • 27
    Hi dagray, your answer could have been what Guido was looking for, but even than, just writing a little piece of code without any further explanation is unhelpful. – LeoR Dec 19 '12 at 13:27
  • 7
    @LeoR I disagree. Question is essentially: "how to insert a pdf in latex?" answer is what dagray wrote. The question is not "how do you insert pdf into latex and can you explain how it works". There is enough info in this answer to find the rest out yourself. – Automatico Jun 07 '14 at 15:04
  • 3
    Still, the question explicitly declares it's a DOC/PDF for an appendix, so it's probably not one page long. – igorsantos07 Nov 22 '15 at 03:19
  • 7
    note a `\usepackage{graphicx}` is required to be able to use this command – anroesti Aug 10 '19 at 12:30
32

The \includegraphics function has a page option for inserting a specific page of a PDF file as graphs. The default is one, but you can change it.

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

You can find more here.

MattAllegro
  • 6,455
  • 5
  • 45
  • 52
Phoenix Mu
  • 648
  • 7
  • 12
22

I don't think there would be an automatic way. You might also want to add a page number to the appendix correctly. Assuming that you already have your pdf document of several pages, you'll have to extract each page first of your pdf document using Adobe Acrobat Professional for instance and save each of them as a separate pdf file. Then you'll have to include each of the the pdf documents as images on an each page basis (1 each page) and use newpage between each page e,g,

\appendix
\section{Quiz 1}\label{sec:Quiz}
\begin{figure}[htp] \centering{
\includegraphics[scale=0.82]{quizz.pdf}}
\caption{Experiment 1}
\end{figure}  

\newpage
\section{Sample paper}\label{sec:Sample}
\begin{figure}[htp] \centering{
\includegraphics[scale=0.75]{sampaper.pdf}}
\caption{Experiment 2}
\end{figure}

Now each page will appear with 1 pdf image per page and you'll have a correct page number at the bottom. As shown in my example, you'll have to play a bit with the scale factor for each image to get it in the right size that will fit on a single page. Hope that helps...

yCalleecharan
  • 4,656
  • 11
  • 56
  • 86
  • 2
    The question was about inserting whole pages, as is, and not about how to include the contents of a pdf file in an existing page that is otherwise formatted and generated by latex. – Mayer Goldberg Jul 04 '15 at 10:21
11

There is an option without additional packages that works under pdflatex

Adapt this code

\begin{figure}[h]
    \centering
    \includegraphics[width=\ScaleIfNeeded]{figuras/diagrama-spearman.pdf}
    \caption{Schematical view of Spearman's theory.}
\end{figure}

"diagrama-spearman.pdf" is a plot generated with TikZ and this is the code (it is another .tex file different from the .tex file where I want to insert a pdf)

\documentclass[border=3mm]{standalone}
\usepackage[applemac]{inputenc}
\usepackage[protrusion=true,expansion=true]{microtype}
\usepackage[bb=lucida,bbscaled=1,cal=boondoxo]{mathalfa}
\usepackage[stdmathitalics=true,math-style=iso,lucidasmallscale=true,romanfamily=bright]{lucimatx}
\usepackage{tikz}
\usetikzlibrary{intersections}
\newcommand{\at}{\makeatletter @\makeatother}

\begin{document}

\begin{tikzpicture}
\tikzset{venn circle/.style={draw,circle,minimum width=5cm,fill=#1,opacity=1}}
\node [venn circle = none, name path=A] (A) at (45:2cm) { };
\node [venn circle = none, name path=B] (B) at (135:2cm) { };
\node [venn circle = none, name path=C] (C) at (225:2cm) { };
\node [venn circle = none, name path=D] (D) at (315:2cm) { };
\node[above right] at (barycentric cs:A=1) {logical}; 
\node[above left] at (barycentric cs:B=1) {mechanical}; 
\node[below left] at (barycentric cs:C=1) {spatial}; 
\node[below right] at (barycentric cs:D=1) {arithmetical}; 
\node at (0,0) {G};    
\end{tikzpicture}

\end{document} 

This is the diagram I included

enter image description here

pachadotdev
  • 3,345
  • 6
  • 33
  • 60