我想要一份在第一页上有页眉/页脚的文档,而其他每页的页脚只有一点不同。如果我按照不同地方的建议去做:
\documentclass[12pt,a4paper,ngerman]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman,german]{babel}
\usepackage{lastpage}
\usepackage[left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\title{title}
\author{some name}
\usepackage{fancyhdr}
\pagestyle{fancyplain}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\lfoot{Some Text}
\rfoot{\thepage/\pageref{LastPage}}
\fancypagestyle{seite1}
{
\fancyhf{}
\renewcommand{\headrulewidth}{0.5pt}
\lhead{some\\text}
\chead{~\\even more text}
\rhead{text\\\today}
\rfoot{\thepage/\pageref{LastPage}}
\headheight 40pt
\headsep 10pt
}
\begin{document}
\thispagestyle{seite1}
\section*{Aufgabe 1:}
\newpage
\section*{Aufgabe 1:}
\end{document}
当我这样做时,第一页之后的所有文本都会稍微移到页面顶部。我发现问题出在页眉上。当我将页眉放在每一页上时,文本会稍微向下移动。
我该如何摆脱这种跳过现象?
实现这一点后,如何才能让文本在第二页及后续页面上的起始高度与第一页上的页眉高度相同?
答案1
放在定义\headheight 40pt \headsep 10pt
之外fancypage
:
\documentclass[12pt,a4paper,ngerman]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman,german]{babel}
\usepackage{lastpage}
\usepackage[left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\title{title}
\author{some name}
\usepackage{fancyheadings} %% Use \usepackage{fancyhdr} here.
\pagestyle{fancyplain}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\lfoot{Some Text}
\rfoot{\thepage/\pageref{LastPage}}
\fancypagestyle{seite1}
{
\fancyhf{}
\renewcommand{\headrulewidth}{0.5pt}
\lhead{some\\text}
\chead{~\\even more text}
\rhead{text\\\today}
\rfoot{\thepage/\pageref{LastPage}}
}
\headheight 40pt %% put this outside
\headsep 10pt %% put this outside
\begin{document}
\thispagestyle{seite1}
\section*{Aufgabe 1:}
\newpage
\section*{Aufgabe 1:}
\end{document}
但你不应该使用“fancyheadings”。在你的日志文件中,你会收到一条警告:
Package fancyheadings Warning: Please stop using fancyheadings!
(fancyheadings) Use fancyhdr instead.
(fancyheadings) We will call fancyhdr with the very same
(fancyheadings) options you passed to fancyheadings.
(fancyheadings)
(fancyheadings) fancyhdr is 99 percent compatible with
(fancyheadings) fancyheadings. The only incompatibility is
(fancyheadings) that \headrulewidth and \footrulewidth and
(fancyheadings) their \plain... versions are no longer length
(fancyheadings) parameters, but normal macros (to be changed
(fancyheadings) with \renewcommand rather than \setlength)..
所以改用fancyhdr
。
编辑
要使第二页和后续页面上的文本与第一页上的页眉具有相同的高度:
\documentclass[12pt,a4paper,ngerman]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman,german]{babel}
\usepackage{lastpage,lipsum} %% lipsum for dummy text remove in your file
\usepackage[margin=3cm,showframe]{geometry}
%
\title{title}
\author{some name}
%
\usepackage{fancyhdr}
\fancypagestyle{myfancy}
{
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\lfoot{Some Text}
\rfoot{\thepage/\pageref{LastPage}}
}
%
\fancypagestyle{seite1}
{
\fancyhf{}
\renewcommand{\headrulewidth}{0.5pt}
\lhead{some\\text}
\chead{~\\even more text}
\rhead{text\\\today}
\rfoot{\thepage/\pageref{LastPage}}
}
\pagestyle{myfancy}
\geometry{left=3cm,right=3cm,top=1.6cm,bottom=3cm,headheight=0pt,headsep=10pt}
\begin{document}
\newgeometry{margin=3cm,headheight=40pt,headsep=10pt}
\thispagestyle{seite1}
\section*{Aufgabe 1:}
\lipsum[1-5]
Nulla egestas. Curabitur a leo. Quisque egestas wisi eget nunc.
Nam feugiat lacus vel est. Curabitur consectetuer.
%% Put the following line at the end of the first page
\restoregeometry
\lipsum[1-4]
\section*{Aufgabe 1:}
\end{document}
然而,在我看来,这破坏了页面布局的一致性。