1

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},
            headsep=0.5cm]{geometry}

when I use \usepackage{pdfpages} then it changes all my margin and my document looks like the attached image enter image description here. 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}
\hypersetup{colorlinks,breaklinks,
            linkcolor=darkblue,urlcolor=darkblue,
            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}{%
 \renewcommand{\headrulewidth}{0.4pt}%
  \fancyheadoffset{0.0cm}
  \fancyfootoffset{0.0cm}
  \renewcommand{\footrulewidth}{0.4pt}
  \fancyhf{}%
  \fancyhead[L]{\changefont {\textsc{TEST PROCEDURE -- TANK TESTING}}}
  \fancyhead[R]{\includegraphics[scale=0.3]{./logo.png}}
  \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}{%
 \renewcommand{\headrulewidth}{0.4pt}%
  \fancyheadoffset{0.0cm}
  \fancyfootoffset{0.0cm}
  \renewcommand{\footrulewidth}{0.4pt}
  \fancyhf{}%
  \fancyhead[L]{\changefont {\textsc{TEST PROCEDURE -- TANK TESTING}}}
  \fancyhead[R]{\includegraphics[scale=0.3]{./logo.png}}
  \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},
            headsep=0.5cm]{geometry}

\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}%
  \fancyheadoffset{0.0cm}
  \fancyfootoffset{0.0cm}
  \renewcommand{\headrulewidth}{0.4pt}%
  \renewcommand{\footrulewidth}{0.4pt}
  \fancyhf{}%
  \fancyhead[L]{\changefont {\textsc{Specification -- Tank Testing Model}}
  \fancyhead[R]{\includegraphics[scale=0.3]{./logo.png}}
  \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 enter image description here save it in the same folder as logo.png.

  • 1
    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. – Ulrike Fischer Sep 18 '14 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. – Ashkan Rafiee Sep 18 '14 at 8:27
  • 1
    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. – Johannes_B Sep 18 '14 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). – Johannes_B Sep 18 '14 at 8:35
3

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},
            headheight=56.17505pt,
            headsep=0.5cm]{geometry}  

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. – Ulrike Fischer Sep 18 '14 at 10:47
  • Many thanks Heiko. I really appreciate it, it fixed my problem. – Ashkan Rafiee Sep 19 '14 at 1:13
0

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. – Ashkan Rafiee Sep 18 '14 at 9:12
  • @AshkanRafiee Sorry, but what you wrote is far from being a minimal working example. – Keks Dose Sep 18 '14 at 9:25
  • I know but I could not make it any shorter... – Ashkan Rafiee Sep 18 '14 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.