14

I'm using LuaLaTeX of latest TexLive 2014 on Windows 7.

I want to overlap headers (page numbers) and documents.

My code is as below:

\documentclass[a4, 10pt]{article}
\usepackage{fancyhdr}

\setlength{\headheight}{0mm}
\setlength{\headsep}{0mm}

\pagestyle{fancy}
\rhead{\thepage{}}

\begin{document}
test1
\clearpage
test2
\end{document}

When I typeset the code, 2 pages are generated.
But these layouts are different.
"test1" is above the header line, but "test2" is below.

How can I raise the text after 2nd page?

David Carlisle
  • 757,742
Magician
  • 143

1 Answers1

22

Check the console or the .log file, package fancyhdr is telling you, what is happening:

Package Fancyhdr Warning: \headheight is too small (0.0pt): 
 Make it at least 12.0pt.
 We now make it that large for the rest of the document.
 This may cause the page layout to be inconsistent, however.

Solution: set \headheight to 12pt in the preamble. Manually:

\setlength{\headheight}{12pt}

Or if package geometry is already used:

\usepackage[
  headheight=12pt,
  % other options
]{geometry}

BTW: There is a typo (two times) in the MWE: \0mm0mm.

Heiko Oberdiek
  • 271,626
  • I checked my .log and understood what happened. I reset \headheight appropriately and \headsep to minus, and I got a good result.

    "\0mm → 0mm." Sorry, that's my mistake. My TeX PC was offline, so I [mis]retyped it. The original code was definitely '0mm'.

    – Magician Aug 31 '14 at 14:09
  • As a beginner, I tried to type something like: \headheight{12pt}. I would like to leave a proper command here for people with the same problem in future: \setlength{\headheight}{12pt} – mpasko256 Sep 14 '16 at 15:06