23
votes

I am creating a large LaTeX document, and my appendix has reproductions of several booklets that I have as PDFs. I am trying to create a section header and then include the pages at a slightly lower scale. For example:

\section{Booklet about Yada Yada Yada}

\includepdf[pages={-}, frame=true, scale=0.8]{booklet_yadayada.pdf}

However, pdfpagex does two annoying things. First, it devotes one output document page for included document page. I can live with that as I am using 80% scale. The main problem, however, is that the first page is also a new page, so I have a page with just a section title, and then a separate page with the booklet.

Is there some way to get pdfpages to be a little smarter here?

5
wrt your comment on jleedev's post, have you tried putting {1-} as your pages?Charles Stewart
This question belongs to tex.stackexchange.com.Léo Léopold Hertz 준영

5 Answers

16
votes

\includepdf uses \includegraphics internally, so something like

\section{Foo}
\fbox{\includegraphics[page=1,scale=0.8]{foo.pdf}}

would include the page without starting a new one, although it only does one page at a time.

9
votes

For me the following worked just fine:

\includepdf[pages=1,pagecommand=\section{Section Heading}]{testpdf}
\includepdf[pages=2-,pagecommand={}]{testpdf}
7
votes

I tried this solution too, but \includepdf keeps the advantage of outputting the file over the margin (the output is centered from the edges of the page). So I openned pdfpages.sty, and I searched for \newpage command. I deleted the first occurance (line 326), just to try, and after saving then compiling again, there were no page break anymore.

3
votes

Thanks for all the answers - I couldn't for the life of me figure out what logic \includepdf uses to insert blank pages; the trick with including the first page via \includegraphics solved most (but not all) of those problems; so here are some notes:

First, out of curiosity, I have also tried to use only \includepdf, but split in two parts:

\includepdf[pages=1]{MYINCLDOC.pdf} 
\includepdf[pages=2-last]{MYINCLDOC.pdf} 

... unfortunately, this has the same problem as the question in OP.

  • Since @WASE's answer, there are now multiple \newpages in the source (pdfpages.sty). I tried reading the source, but I found it quite difficult; so I tried temporarily setting \newpage to \relax only for \includepdf - and that puts all pages in the document on top of each other; so probably not a good idea to get rid of \newpage blindly.
  • Just \includegraphics[page=1,scale=0.8]{foo.pdf} works - but (as @WASE also note) it is aligned at the top-left corner of the page body, which is to say inside the margins; for a full page we'd want the pdf inclusion overlaid over the whole page, margins included.

This page: graphics - How do I add an image in the upper, left-hand corner using TikZ and graphicx - TeX - LaTeX points to several possibilities for positioning on page over the margins; but for me, the best solution for a full page PDF inclusion is to use package tikz to center it to the page:

\begin{tikzpicture}[remember picture,overlay]
  \node at (current page.center) {\includegraphics[page=1]{MYINCLDOC.pdf}};
\end{tikzpicture}
\includepdf[pages=2-last]{MYINCLDOC.pdf} 

After this is done, as a bonus, I have also experienced:

  • Proper targets of PDF bookmarks (going to the right page when clicked)
  • If you use package pax, the data seems to be included also for the \includegraphics standalone first page, so no difference there
  • If you have a twoside document - pdfpages, with the above split of the first page in \includegraphics, will now (seemingly) correctly insert the equivalent of \cleardoublepages between pdfs that are included back to back (so I don't have to insert such a command manually).

Hope this helps someone,
Cheers!

2
votes

Use the minipage environement :

\chapter*{Sujet du stage}
%\fbox{
\begin{minipage}{\textwidth}
\includepdf[scale=0.8]{../sujet-stage/main.pdf}
\end{minipage}

It doesn't add any extra page and it works with includepdf.