6

I wanted a document with a header/footer on the first page and only a slighlty different footer on every other page. If I do it like suggested in different places:

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

When I do it like that, all text after the first page is moved slightly to the top of the page. I figured out that the header is the problem. When I put the header on every page the text moves slightly down.

How can I get rid of the skip?
And after I achieved that how can I let the text start on the second and following pages on the same height as the header on the first page?

5

Put \headheight 40pt \headsep 10pt outside the fancypage definition:

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

enter image description here

But you shouldn't use `fancyheadings. In your log file you get a warning:

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)..

So use fancyhdr instead.

Edit

To start the text on the second and following pages on the same height as the header on the first page:

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

enter image description here

However, IMO, this spoils the consistency of page layout.

  • Thank you. I did use fancyhdr, fancyheading was just a test. How do I move the text up on the second page, without moving the footer? – snippl Jan 15 '13 at 9:24
  • Can I make the value change in any way dynamic? When I write text, I normally don't use \newpage. – snippl Jan 15 '13 at 9:32
  • If I use the the first suggestion, the footer moves up. If I use \afterpage nothing happens on the second page. – snippl Jan 15 '13 at 9:50
  • @snippl See the edit. I don't think you can do it dynamically as this involves changing text height. So you have to put \restoregeometry at the end of the page manually. – user11232 Jan 15 '13 at 12:01

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.