An issue with centering
I am trying to include several pages of a pdf within a document (hence using includepdf
). These take up most of the page, so a 1-to-1 page input to page output is desired. The main document is two sided with odd and even margins set and some fancy headers. When I include the pdf pages, these are not respecting the page margins (seemingly always centred). How can I get the page margins to be preserved? (I would also like the solution to have the included pdfs vertically centred in the space the text would otherwise fill). I don't want to enforce that the included pages start after a \cleardoublepage
, but just a \clearpage
.
Undesired alignment from includepdf
Using the code (as in the MWE)
\includepdf[page={3-4}, frame, trim={30mm 50mm 30mm 50mm}, clip=true, pagecommand={\pagestyle{fancy}},width=\linewidth]{dummy_pages}
The sort of alignment I want from includegraphics
Instead using:
\noindent
\fbox{\includegraphics[width=\linewidth, page=3, trim={30mm 60mm 30mm 60mm}, clip=true]{dummy_pages}}
The alignment here is better albeit I think the inner margin is still not perfectly aligned despite stating width=\linewidth
.
MWE
I have created a pdf file called dummy_pages.pdf
which is dozens of page of lipsum.
\documentclass[a4paper,11pt,twoside]{book}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{pdfpages}
\usepackage[top=20mm,bottom=20mm,left=20mm, right=30mm, heightrounded, marginparwidth=24mm, marginparsep=3mm, headsep=10mm]{geometry}
% The nice headers and footers.
\pagestyle{fancy}
% Specifying the headers and footers.
\fancyhf{}
\renewcommand*{\headrulewidth}{1pt}%
\fancyhead[LO]{\nouppercase{\leftmark}}
\fancyhead[RE]{\nouppercase{\rightmark}}
\fancyhead[LE,RO]{\thepage}
\fancypagestyle{plain}{%
\fancyhf{}%
\renewcommand*{\headrulewidth}{0pt}%
}
\cfoot{}
\begin{document}
\lipsum
\clearpage
\includepdf[page={3-4}, frame, trim={30mm 50mm 30mm 50mm}, clip=true, pagecommand={\pagestyle{fancy}},width=\linewidth]{dummy_pages}
\end{document}
Here the fancy headers shows the page numbering and margins.
Related material
There is a related question and answer here to how to position pdf with \includepdf in book, also depending on even/odd page. However, their "solution" is more of a one-off hack than a solution.