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:



\includepdf[pages={33-34}, landscape, turn=false]{thesis.pdf} % some landscape pages
\includepdf[pages={1-5,{},{},{}}, landscape, nup=1x2, turn=false]{Appendices/specs.pdf}


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.

LaTeX: coloured text and blank page fun.

I want to insert some research papers into my thesis. These are in separate pdf files which I don't yet know how I will insert. (pdfpages isn't my friend because I'm banned from using pdflatex due to having eps graphics which I can't be bothered to convert.)

I'll figure out that bit in a minute, but right now I want to force a blank page (with a header and footer) which will be printed on the reverse of an appendix section page. This has to come before the place where I will insert the pdf pages. Actually, latex adds this page automatically at the moment, because it wants my "Appendix" section pages to be on the right-hand sides of my document. The issue is that if I then start to add to my page counter, the reverse-side blank page has the wrong page number for where it will be printed!

Here's my work-around. Each introductory page for an appendix goes like this:

\chapter{An included paper}
Following is a copy of an amazing paper from our research group.

The mbox ensures the new page actually happens. Then, before the next \include{} in the master file, I add four pages (the research paper length!) to my counter.


So far, so awesome. Now I'll fight to include the papers in the file. I'm thinking psutils...

OH! I forgot to tell you about coloured text! Before I found the mbox doo-dah I was going to just write "cheese" in white on the blank page. I'd do the following in my preamble:


and then on my "blank" page, I'd do:


Ok, that's orange, but you get the picture. You can define white.