Embedding PDFs¶
Sometimes you need to include pages from an existing PDF file into your LaTeX document. This is common for including certifications, full-page diagrams, or merging documents.
The pdfpages Package¶
The standard way to insert full PDF pages is using the pdfpages package.
Basic Usage¶
First, add \usepackage{pdfpages} to your preamble.
Then use the \includepdf command:
\documentclass{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages=-]{myfile.pdf} % Includes all pages
\end{document}
Options for \includepdf¶
pages={1}: Include only page 1.pages={1,3}: Include pages 1 and 3.pages={1-5}: Include pages 1 through 5.pages=-: Include all pages.scale=0.9: Scale the page down to 90%.landscape=true: Rotate the included page.pagecommand={\thispagestyle{plain}}: Keep page numbering on the included page.
Example¶
We have created an example file embedding-example.tex which embeds simple-report.pdf.
- Source Code: embedding-example.tex
- PDF to be embedded: simple-report.pdf
- Resulting PDF: embedding-example.pdf
Including PDFs as Images (graphicx)¶
If you just want to include a PDF file as a figure (like a chart generated by R or Python), treat it like an image.
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[h]
\centering
\includegraphics[width=0.8\textwidth]{chart.pdf}
\caption{A chart from a PDF file}
\end{figure}
\end{document}
LaTeX handles vector graphics in PDFs perfectly, maintaining high resolution.