## August 29, 2016

### Embedding PDFs in a LaTeX file

Have you ever wanted to embed a PDF inside a larger LaTeX document?  For my "Book of Infinite Learning" I wanted to embed a copy of two different journal articles.  I didn't want to just grab the text and redo the layout of the articles.

Fortunately, there is a LaTeX way to do this.  Here are the commands I used:
\newgeometry{left=3cm,bottom=0.01cm,right=0.01cm}
\includepdf[pages=-, fitpaper=true]{filename.pdf}
\restoregeometry
The heavy lifting is done by the \includepdf command from the pdfpages package.  Read up on the options for that command if you don't want to use all the pages in the file.

What really made my day was the ability to change the margins for my LaTeX document for just the PDFs I wanted to embed.  Using \newgeometry I can specify smaller margins for these pages, since the PDF already has plenty of margin spacing.  Then \restoregeometry reverts back to the document margins.

I'm very happy with how this turned out.