[Tex/LaTex] Problem with header/footer position

fancyhdrheader-footer

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?

Best Answer

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.