我(仍在)从常规 LaTeX 课程(报告、文章)转向 Koma-Script。很多东西都还好,但不是全部。
我目前的问题在于 PDF 包含和所包含的 PDF 页面的页眉/页脚更改。
在很多文档中,我必须到处添加 PDF 文档。为了便于阅读,我想修改页脚或页眉以添加一些有关所包含 PDF 文档的数据。
使用report
和article
类fancyheaders
以及pagecommand
,这真的很容易:
\includepdf[addtotoc={1, section, 1, For the ToC, reference},
fitpaper=false,pages=-,frame,scale=0.7,
pagecommand={\thispagestyle{fancy}
\fancyfoot[RE,LO]{\footnotesize\textbf{Some Footer}}}]{ThePDF}
使用时就没有那么幸运了scrheadings
。我完全无法更改所包含的 PDF 页面的页脚(或页眉)。
这是一个最小(不)工作示例:
\documentclass[headheight=1.2cm,headsepline]{scrartcl}
\usepackage[bottom=2.8cm,footskip=18mm]{geometry}
\usepackage[headsepline]{scrpage2}
\usepackage{lipsum}
\usepackage{pdfpages}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[frenchb]{babel}
\pagestyle{scrheadings}
\chead[]{Center header}
\ihead[]{Inside header}
\ohead[]{Outside header}
\cfoot[]{Center footer -- \thepage{} --}
\ifoot[]{Inside footer}
\ofoot[]{Outside footer}
\begin{document}
\title{That is some title}
\author{Author name}
\date{Someday}
\maketitle
\tableofcontents
\section{Blah}
\lipsum[3-5]
\includepdf[addtotoc={1, subsection, 1, Included PDF,tag},
turn=false,frame,scale=0.8,pages=1,
pagecommand={\thispagestyle{scrheadings}
\ofoot{Another outside footer}
\ifoot{Another inside footer}
\chead{And a center header}}]{SomePDF}
\lipsum[3-5]
\end{document}
知道我做错了什么或如何达到这个目标吗?
答案1
\includepdf
为了达到您的目标,请将MWE 中的宏调用更改为:
{% Start group to have changes locally
\ofoot{Another outside footer}
\ifoot{Another inside footer}
\chead{And a center header}
\includepdf[%
addtotoc={1, subsection, 1, Included PDF,tag},
turn=false,frame,scale=0.8,pages=1-3,
pagecommand={\thispagestyle{scrheadings}}
]{SomeFile.pdf}
}% Ends group, old footer and header are active ...
现在您获得了新的页眉和页脚...
答案2
您可以定义新的页面样式,以提供更大的灵活性。
\documentclass[headheight=1.2cm,headsepline,twoside]{scrartcl}
\usepackage[bottom=2.8cm,footskip=18mm]{geometry}
\usepackage[headsepline]{scrpage2}
\usepackage{lipsum}
\usepackage{pdfpages}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[frenchb]{babel}
\pagestyle{scrheadings}
\chead[]{Center header}
\ihead[]{Inside header}
\ohead[]{Outside header}
\cfoot[]{Center footer -- \thepage{} --}
\ifoot[]{Inside footer}
\ofoot[]{Outside footer}
% Easy interface
%\deftripstyle{pdfincl}
% {}
% {And a center header}
% {}
% {Another inside footer}
% {}
% {Another outside footer}
% Expert interface
\newpagestyle{pdfincl}
{% HEADER
(0pt,0pt)% no above rule
{% header, even pages
\hfil And a center header\hfil
}
{% header, odd pages
\hfil And a center header\hfil
}
{% header, single side
\hfil And a center header\hfil
}
(\textwidth,0.4pt)% rule below header
}
{% FOOTER
(0pt,0pt)% no separation rule
{% footer, even pages
Another outside footer\hfil Another inside footer
}
{% footer, odd pages
Another inside footer\hfil Another outside footer
}
{% footer, single side
Another inside footer\hfil Another outside footer
}
(0pt,0pt)% no rule below footer
}
\begin{document}
\title{That is some title}
\author{Author name}
\date{Someday}
\maketitle
\tableofcontents
\section{Blah}
\lipsum[3-5]
\includepdf[addtotoc={1, subsection, 1, Included PDF,tag},
turn=false,frame,scale=0.8,pages=-,
pagecommand={\thispagestyle{pdfincl}}]{chineheadincl}
\lipsum[3-5]
\end{document}
简单的界面不需要规则。当然,如果你知道你的文件是单面的,你不需要填写所有字段。