10
votes

I want to add some pdf-pages in my appendix in latex using this command:

\includepdf[pages=-,scale=.8,pagecommand={},linktodoc=true]{myPDF.pdf}

Works fine so far, however it is always placed in a new page... in other words:

I add \section{title 1} and then \includepdf-command and then \section{title 2} and \includepdf-command..... But after each \section I get an empty page and then the pdf-files. But I want them to be placed immediately after a section-title, if applicable.

Hope the problem is clear.

3
How many pages are in myPDF.pdf? Are the page sizes in myPDF.pdf and your document the same?Werner
it's the same size. the page numbers are different.malptek
If they're the same size, then any regular content you wish to put on the page will be overlaid on top of the included page, so how should that be handled?Werner

3 Answers

16
votes

Another stylish solution in case of adding multi page documents:

\includepdf[pages=1,scale=.8,pagecommand={\section{My header}\label{pdf:myfile}},linktodoc=true]{myfile.pdf}
\includepdf[pages=2-,scale=.8,pagecommand={},linktodoc=true]{myfile.pdf}

Features:

  1. Header placed at the top of the first page without cropping
  2. You can set a label for the section created
  3. Multi page friendly
5
votes

Found the solution here: https://tex.stackexchange.com/questions/5911/how-to-include-pdf-pages-without-a-newpage-before-the-first-page

the only thing is to add the \section in the pagecommand of \includepdf like this:

\includepdf[pages=-,scale=.8,pagecommand={\section{title 1}\label{}},linktodoc=true]{myPDF1.pdf}
\includepdf[pages=-,scale=.8,pagecommand={\section{title 2}\label{}},linktodoc=true]{myPDF2.pdf}
....

thanks guys.

UPDATE: i noticed that \label{} is not working in the pagecommand, hence i cannot reference to any of these appendix-files. is there another workaround?

0
votes

Alternatively you can use minipage for this.

\begin{minipage}[t]{0.8\linewidth}
  \includepdf[pages=1,scale=1,pagecommand={},linktodoc=true]{myPDF.pdf}
\end{minipage}