Monday 16 August 2010

Including pdf files into latex

Further to my earlier post today, this post is the story of how I managed to get my research papers into my thesis as appendices. The earlier post tells a fascinating tale of how I sorted the page counters out and forced some blank pages. I then compiled up to pdf (via ps2pdf, to include my eps diagrams). To insert my other pdf pages I wrote a new latex file to stitch stuff together using pdfpages. Sadly this makes my hyperlinks go away, but nevermind. The object here is to be able to have a file which can be printed and bound by people who don't care to re-arrange pages for me. Behold:

\documentclass[a4paper,portrait]{article}
\usepackage{pdfpages}

\begin{document}

\includepdf[pages={1-32}]{thesis.pdf}
\includepdf[pages={33-34}, landscape, turn=false]{thesis.pdf} % some landscape pages
\includepdf[pages={35-202}]{thesis.pdf}
\includepdf[pages={1-5,{},{},{}}, landscape, nup=1x2, turn=false]{Appendices/specs.pdf}
\includepdf[pages={203-204}]{thesis.pdf}
\includepdf[pages={1-4}]{Appendices/prl.pdf}
\includepdf[pages={205-206}]{thesis.pdf}
\includepdf[pages={1-4}]{Appendices/pra.pdf}
\includepdf[pages={207-220}]{thesis.pdf}

\end{document}

Chunks of my thesis are included (I guess you can spot them), including some landscape pages as a special case. The "turn = false" means that any pdf viewers still display them as portrait. This was important to me, as I want to be able to check they're not going to print upside down! The last two appendices are four pages each and on American letter ("freedom") paper, but that's okay: they'll be scaled for A4. The "specs.pdf" file is 5 pages long and I have included it as 2-up printing on landscape pages which show as portrait in the viewer. Since I needed ensure that they occupy 4 sides of A4 in total, I included 3 blank pages denoted by the empty braces {}. So, the first two-and-a-half sides of A4 have the 5 pages of specs.pdf, and then there are one-and-a-half blank sides following.

I compile with pdflatex.

No comments: