using LaTeX pdfpages and geometry packages together

I would like to embed a pdf document (few pages) in my latex document. However, I use the geometry package to set the margins and when I load \usepackage{pdfpages} it completely destroys all my margins.

I have:

\usepackage[a4paper, twoside, scale={1,1},
hmargin={3.3cm, 2.7cm},
vmargin={2cm, 4.5cm},


when I use \usepackage{pdfpages} then it changes all my margin and my document looks like the attached image . Basically using the pdfpages shifts my texts to header section.

I would appreciate if someone tells me how to resolve this issue.

here is a MWE (minimum working example). It does not show the exact error but you see if you comment line 83 (\usepackage{pdfpages}) the margins are different. Note that I do not even use \includepdf yet.

\documentclass[11pt,a4paper,twoside]{report} %physics

\usepackage[dvips]{graphicx}
\usepackage{setspace}
\usepackage{fancyhdr, lastpage}
\pagestyle{fancy}
\usepackage{nomencl}
\usepackage{colortbl}
\usepackage{multirow}
\usepackage{parskip}
\usepackage{hyperref}
\usepackage{titlesec}
\usepackage{xcolor,colortbl}
\usepackage{blindtext}

\definecolor{darkblue}{rgb}{0.0,0.0,0.0}  %{0.0,0.0,0.3}
anchorcolor=darkblue,citecolor=darkblue,
pdftitle = {Test Procedure: Tank Testing},
pdfauthor = {Ashkan}}
\renewcommand{\nomentryend}{\vspace{-8pt}}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}

%%%To be able to have smaller fonts
\newcommand{\changefont}{%
\fontsize{8}{11}\selectfont
}

%%%To be able to have larger fonts
\newcommand{\changefonttitle}{%
\fontsize{12}{11}\selectfont
}
%%%%%%%%%%%%%%%%%%
\titleformat{\chapter}
{\normalfont\LARGE\bfseries}{\thechapter.}{0.5em}{}
\titlespacing*{\chapter}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%Creating a new colour Light Blue for the table on the front page
\definecolor{LightBlue}{rgb}{0.3,0.6,1.0}

%%%To have headers/footers on the title page
\fancypagestyle{empty}{%
\fancyfootoffset{0.0cm}
\renewcommand{\footrulewidth}{0.4pt}
\fancyhf{}%
\fancyhead[L]{\changefont {\textsc{TEST PROCEDURE -- TANK TESTING}}}
\fancyfoot[C]{\changefont{\color{red}{CONFIDENTIAL -- COMERCIAL IN CONFIDENCE \\ THIS DOCUMENT IS UNCONTROLLED WHEN PRINTED}} }%
}

%%%To have headers/footers on the pages that are using plain template
\fancypagestyle{plain}{%
\fancyfootoffset{0.0cm}
\renewcommand{\footrulewidth}{0.4pt}
\fancyhf{}%
\fancyhead[L]{\changefont {\textsc{TEST PROCEDURE -- TANK TESTING}}}
\fancyfoot[C]{\changefont{\color{red}{CONFIDENTIAL -- COMERCIAL IN CONFIDENCE \\ THIS DOCUMENT IS UNCONTROLLED WHEN PRINTED}}\\}%
\fancyfoot[RE, RO]{Page {\thepage} of \pageref{LastPage}}
}

\makeglossary
%%%%%%%%%%%%% Mike's section %%%%%%%%%%%%%%%%%%%%%%%
\usepackage[a4paper, twoside, scale={1,1},
hmargin={3.3cm, 2.7cm},
vmargin={2cm, 4.5cm},

\onehalfspacing
\usepackage{pdfpages}
%%%%%%%%%%%%% end of mike's section %%%%%%%%%%%%%%%%

\begin{document}

\title{
\textsc{\\*[-2cm] Test Procedure \\ Tank Testing}
}
\author{}

\date{\raggedright}

\maketitle
\thispagestyle{empty}%
\pagenumbering{roman}%
\setcounter{secnumdepth}{-1}%
\thispagestyle{empty}%
\tableofcontents

\clearpage%
%--------------------------------------------------------------------------
\pagenumbering{arabic} \setcounter{secnumdepth}{3}

\pagestyle{fancy}%
\fancyfootoffset{0.0cm}
\renewcommand{\footrulewidth}{0.4pt}
\fancyhf{}%
\fancyhead[L]{\changefont {\textsc{Specification -- Tank Testing Model}}
\fancyfoot[C]{\changefont{\color{red}{CONFIDENTIAL -- COMERCIAL IN CONFIDENCE \\ THIS DOCUMENT IS UNCONTROLLED WHEN PRINTED}}\\}%
\fancyfoot[RE, RO]{Page {\thepage} of \pageref{LastPage}}

%%%%%%%%%%%%Chapters (Contents of the document)%%%%%%%

%------------------------------------------------------------------------------------------
\blindtext[10][10]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}


to run you need this save it in the same folder as logo.png.

• I swear you: A lot of people use both package together. And if the combination would "destroy" a document someone would have noticed. So something is special in your case and you should really show a complete example and not only a snippet. Sep 18, 2014 at 8:18
• Ulrike, the images shows my issue very well. I cannot attach my document, it is a technical note with confidential materials. The issue as you see is that when I add \usepackage{pdfpages} even if I don not use it, it overwrites the margin I defined in geometry. Sep 18, 2014 at 8:27
• We can see the output, but cannot reproduce it. Try to boil your document down to a minimal working example (MWE). You don't have to share confidential material. Substiture it with dummy text provided by package blindtext. Sep 18, 2014 at 8:33
• By the way, welcome to TeX.SX. Please have a look at package siunitx. It makes typesetting units much easier and consistent (ensures that they are upright). Sep 18, 2014 at 8:35

The image logo.png is much too large for the header, from the .log file:

Package Fancyhdr Warning: \headheight is too small (12.0pt):
Make it at least 56.17505pt.
We now make it that large for the rest of the document.
This may cause the page layout to be inconsistent, however.


Also package geometry throws a warnings:

Package geometry Warning: Over-specification in h'-direction.
width' (597.50787pt) is ignored.

Package geometry Warning: Over-specification in v'-direction.
height' (845.04684pt) is ignored.


Removing option scale and adding headheight fixes these issues:

\usepackage[a4paper, twoside,
hmargin={3.3cm, 2.7cm},
vmargin={2cm, 4.5cm},


The warning

pdfTeX warning (ext4): destination with the same identifier
(name{page.1}) has been already used, duplicate ignored


can be avoided by disabling page anchors for the title page:

\begin{document}
\hypersetup{pageanchor=false}
...
\maketitle
\hypersetup{pageanchor=true}

• And there is a brace missing here  \fancyhead[L]{\changefont {\textsc{Specification -- Tank Testing Model}}. And one should use the option dvips when running pdflatex. Sep 18, 2014 at 10:47
• Many thanks Heiko. I really appreciate it, it fixed my problem. Sep 19, 2014 at 1:13

Maybe I'm wrong, but your picture seems to display what happens, if you include a large page of a PDF into a page with a headline. I have to admit, I don't use geometry but typearea.

pdfpages insertes the pages centered. If you insert a DIN A4 page into the page of your document, what do you expect other than the inserted page filling the page of your document completely?

The manual describes how to scale the inserted page and how to make an offset, etc. You get the manual by typing texdoc pdfpages on the command line, as ususal.

• Thanks Keks. The issue is it happens by just adding the \usepackage{pdfpages} line to my document, even without inserting any pdf yet. Sep 18, 2014 at 9:12
• @AshkanRafiee Sorry, but what you wrote is far from being a minimal working example. Sep 18, 2014 at 9:25
• I know but I could not make it any shorter... Sep 18, 2014 at 9:49