By loading pgfpages
before pdfpages
, it works:
\documentclass[a4paper,10pt]{article}
\usepackage{pgfpages}
\usepackage{pdfpages}
\pgfpagesuselayout{4 on 1}[a4paper]
\begin{document}
\includepdf[pages=-]{page1.pdf}
\includepdf{page2.pdf}
\includepdf{page3.pdf}
\includepdf{page4.pdf}
\end{document}
I would suggest using the background
package and a little trickery. The following defines a new command \installbackgrounds[]{}
. The first argument is optional and sets the total number of pages in the file of backgrounds. The second, mandatory argument specifies the file. If no total is specified, the number defaults to 1
.
\documentclass[a4paper]{report}
\usepackage{graphicx}
\usepackage{background, etoolbox, kantlipsum}
\newcounter{mypagebackground}
\setcounter{mypagebackground}{0}
\newcounter{mypagebackgroundpages}
\setcounter{mypagebackgroundpages}{0}
\newcommand*\myinstallbackground[1]{\relax}
\newcommand*\installbackgrounds[2][1]{%
\setcounter{mypagebackground}{0}%
\setcounter{mypagebackgroundpages}{#1}%
\gdef\mybackgroundfile{#2}%
}
\AddEverypageHook{\stepcounter{mypagebackground}}
\backgroundsetup{%
contents={%
\AddEverypageHook{% adapted from pp. 6-7 of background manual
\ifnumless{\value{mypagebackgroundpages}}{\value{mypagebackground}}{}{%
\begin{tikzpicture}[remember picture, overlay]
\node at (current page.center) {\includegraphics[page=\themypagebackground]{\mybackgroundfile}};
\end{tikzpicture}}%
}%
}%
}
\begin{document}
\kant[1-5]
\installbackgrounds[7]{mypages.pdf}
\kant[1-30]
\installbackgrounds{example-image-a.pdf}
\kant[1-5]
\end{document}
mypages.pdf
is a PDF consisting of 7 pages, one for each colour of the rainbow.
EDIT: Looping Effects
This a response to the discussion in comments. It is not an answer. It is intended to help understand what is going on. Run this code and compare the different effects.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \i in {10,20,...,100}
\node [minimum width=\i mm, minimum height=\i mm, draw=red!\i] at (current page.center) {};
\end{tikzpicture}
\clearpage
\foreach \i in {10,20,...,100}{%
\begin{tikzpicture}[remember picture, overlay]
\node [minimum width=\i mm, minimum height=\i mm, draw=blue!\i] at (current page.center) {};
\end{tikzpicture}}
Some text on this page.
\clearpage
\foreach \i in {10,20,...,100}{%
\begin{tikzpicture}
\node [minimum width=\i mm, minimum height=\i mm, draw=green!\i] at (current page.center) {};
\end{tikzpicture}}
\foreach \i in {10,20,...,100}{%
\begin{tikzpicture}
\node [minimum width=\i mm, minimum height=\i mm, draw=orange!\i] {};
\end{tikzpicture}
Some text on page \thepage.
\clearpage}
\end{document}
Notice that the first orange square is on the page with the green squares because there is no \clearpage
after the final green square (which is well off the page).
Best Answer
There are two possibilities.
Using the package
graphicx
: As long as you compile withpdflatex
you can include every external pdf file with\includegraphics
.Using the package
pdfpages
: The package provides the command\includepdfmerge
which can handle multiple pdf files: