同时使用 LaTeX pdfpages 和几何包

同时使用 LaTeX pdfpages 和几何包

我想在我的 latex 文档中嵌入一个 pdf 文档(几页)。但是,我使用 geometry 包来设置边距,当我加载 \usepackage{pdfpages} 时,它会完全破坏我的所有边距。

我有:

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

当我使用 \usepackage{pdfpages} 时,它会更改我的所有边距,我的文档看起来就像所附图像一样在此处输入图片描述。基本上,使用 pdfpages 会将我的文本移至标题部分。

如果有人告诉我如何解决这个问题我将不胜感激。

这是 MWE(最小工作示例)。它没有显示确切的错误,但如果您注释第 83 行(\usepackage{pdfpages}),您会发现边距不同。请注意,我甚至还没有使用 \includepdf。

\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}

要运行,您需要在此处输入图片描述将其保存在与 logo.png 相同的文件夹中。

答案1

该图像logo.png对于标题来说太大了,来自文件.log

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.

软件包还geometry抛出警告:

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.

删除选项scale并添加headheight可修复以下问题:

\usepackage[a4paper, twoside,
            hmargin={3.3cm, 2.7cm},
            vmargin={2cm, 4.5cm},
            headheight=56.17505pt,
            headsep=0.5cm]{geometry}  

警告

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

可以通过禁用标题页的页面锚点来避免:

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

答案2

也许我错了,但您的图片似乎显示了如果将 PDF 的大页面放入带有标题的页面中会发生什么。我不得不承认,我没有使用几何图形,而是使用 typearea。

pdfpages 将页面居中插入。如果您将 DIN A4 页面插入文档页面,除了插入的页面完全填满文档页面之外,您还期望什么?

该手册描述了如何缩放插入的页面以及如何进行偏移等。您可以texdoc pdfpages像往常一样通过在命令行中键入来获取手册。

相关内容