![包含带页眉和页脚的多页 pdf](https://linux22.com/image/427927/%E5%8C%85%E5%90%AB%E5%B8%A6%E9%A1%B5%E7%9C%89%E5%92%8C%E9%A1%B5%E8%84%9A%E7%9A%84%E5%A4%9A%E9%A1%B5%20pdf.png)
我想发布科研论文的作者版本,并附加版权注释。我有一个多页 pdf 文件论文.pdf它是使用 IEEE 会议论文集的 IEEEtran 模板创建的。现在我想在所包含的 pdf 的上方和下方添加一个页眉框和一个页脚框,并使用空白处来添加其他法律信息。我最终得到了以下代码:
\documentclass[12pt]{scrartcl}
\renewcommand{\familydefault}{cmss}
\usepackage{pdfpages}
\begin{document}
\newcommand{\headernote}{
\centering
\vspace*{-2cm}
\fboxrule=0.4pt \fboxsep=3pt
\fbox{\begin{minipage}{1.05\linewidth} % header box
This is the author's version of an article that has been published in the ICMA 2020 proceedings.\\
Changes were made to this version by the publisher prior to publication. \\
The final version of record is available at http://dx.doi.org/10.1109/ICMA49215.2020.9233709
\end{minipage}}
\fbox{\begin{minipage}{1.05\linewidth} % footer box
Copyright (c) 2020 IEEE. Personal use is permitted. For any other purposes, permission must be obtained from the IEEE by emailing [email protected].
\end{minipage}}
}
\includepdf[pages=-,pagecommand={\thispagestyle{empty}\headernote}]{paper.pdf}
\end{document}
使用\thispagestyle{empty}
删除页码。页眉框按我想要的方式放置。但我无法将页脚框放在包含的 pdf 下方。在小页面之间使用 vspace 不成功,添加额外的空小页面也不成功。我可以分开这些框,但还不够,或者我可以将页脚框带到下一页。我想我在这里遗漏了一些基本的东西。
答案1
像其他帖子中展示的那样定义新的页面样式绝对是一个好主意。另一种可能且非常灵活的方法是使用选项picturecommand
:
\includepdf[
pages=-,
picturecommand={%
\put(50,800){top: lorem ipsum}%
\put(50,100){bottom: lorem ipsum}}
]{dummy.pdf}
答案2
使用fancyhdr
和放大页面尺寸即可达到目的。(从信纸到 A4)。
scale=0.98
稍微缩小源的尺寸(需要graphicx
)。
offset=8pt -20pt
有助于使其位于页面中央。
您可以尝试这些设置,也可以使用top
和bottom
来找到您喜欢的布局。
\documentclass[12pt, a4paper]{article}
\usepackage[top=1.5in, left=0.8in, right=1in, bottom=0.9in]{geometry} % added
% letter 8.5x11.0 in
% A4 8.3x11.7 in
\renewcommand{\familydefault}{cmss}
\usepackage{pdfpages}
\usepackage{graphicx} % added
\usepackage{fancyhdr} % added
\fancyhead{}
\fancyfoot{}
\fancyhead[C]{\headernote}
\fancyfoot[C]{\footernote}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\begin{document}
\newcommand{\headernote}{%
\vspace*{-2cm}
\fboxrule=0.4pt \fboxsep=3pt \fbox{\begin{minipage}{1.05\linewidth} % header box
This is the author's version of an article that has been published in the ICMA 2020 proceedings.\\
Changes were made to this version by the publisher prior to publication. \\
The final version of record is available at http://dx.doi.org/10.1109/ICMA49215.2020.9233709
\end{minipage}}
}
\newcommand{\footernote}{%
\fboxrule=0.4pt \fboxsep=3pt\fbox{\begin{minipage}{1.05\linewidth} % footer box
\centering
Copyright (c) 2020 IEEE. Personal use is permitted. For any other purposes, permission must be obtained from the IEEE by emailing [email protected].
\end{minipage}}
}
\includepdf[pages=-,pagecommand={\thispagestyle{fancy}},scale=0.98,offset=8pt -20pt]{IEEEtran_HOWTO.pdf}
\end{document}
IEEEtran_HOWTO.pdf
我使用的文件是分发的一部分作为源文件ieetran
。它的页面大小为 8.5 x 11.0 英寸(信纸)。
答案3
您可以加载包scrlayer
(KOMA-Script 包的一部分)并声明一个新的图层页面样式:
\documentclass[12pt]{scrartcl}
\renewcommand{\familydefault}{cmss}
\usepackage{pdfpages}
\usepackage{scrlayer}
\DeclareNewLayer[
background,
head,
addhoffset=-.06\textwidth,% horizontal shift
width=1.12\textwidth,% maximal width
addvoffset=.5\baselineskip,% vertical shift
contents=\headernote
]{headerbox}
\newcommand\headernote{}
\DeclareNewLayer[
background,
foot,
addhoffset=-.06\textwidth,% horizontal shift
addwidth=.12\textwidth,% maximal width
addvoffset=2\baselineskip,% vertical shift
contents=\footernote
]{footerbox}
\newcommand\footernote{}
\DeclareNewPageStyleByLayers{boxes}{headerbox,footerbox}
\newcommand\copyrightbox[2][1.1\textwidth]{% syntax: \pagestylebox[<width of minipage>]{<content>}
\setlength{\fboxrule}{0.4pt}%
\setlength{\fboxsep}{3pt}%
\centering
\fbox{\begin{minipage}{#1}#2\end{minipage}}%
}
\begin{document}
\renewcommand\headernote{\copyrightbox{%
This is the author's version of an article that has been published in the ICMA 2020 proceedings.\\
Changes were made to this version by the publisher prior to publication. \\
The final version of record is available at http://dx.doi.org/10.1109/ICMA49215.2020.9233709
}}
\renewcommand\footernote{\copyrightbox{%
Copyright (c) 2020 IEEE. Personal use is permitted.
For any other purposes, permission must be obtained from the IEEE by emailing [email protected].
}}
\includepdf[pages=-,pagecommand={\thispagestyle{boxes}}]{IEEEtran_HOWTO.pdf}
\end{document}