Page LayoutBody Text wrongly written in Header

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
fpires
Posts: 15
Joined: Wed Dec 23, 2015 7:10 pm

Body Text wrongly written in Header

Post by fpires »

Hello!

I have tried to create a header with 2 lines: the first one 1.5 cm below the top margin, and the second one 4 cm below the top margin. Well, this task I guess I have solved! The problem is the body text of the document. At the first page, it starts in the header, and not below it! This problem, however, does not occur from the second page on. Please take a look at this mwe:

Code: Select all

\documentclass[a4paper,12pt]{report}

\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}

\usepackage[utf8]{inputenc}

\usepackage[brazilian]{babel}

\setlength{\headsep}{5.98mm}
\setlength{\textheight}{212mm}
\setlength{\topmargin}{15mm}
\setlength{\headheight}{9.6pt}
\setlength{\voffset}{-25.4mm}

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\rightmark}{}
\fancyfoot{}

\begin{document}

	\fancyhead[L]{\fontsize{8}{9.6}\selectfont \textbf{Text to the left.}}
	\fancyhead[R]{\fontsize{8}{9.6}\selectfont \textbf{abc\\[24.44mm] Text to the right.}}

	line 1\\ 
	line 2\\
	line 3\\
	line 4\\
	line 5\\
	line 6\\
	line 7\\
	line 8 

	\newpage
	
	line 9\\
	line 10\\
	line 11	

	\newpage
	
	line 12\\
	line 13\\
	line 14	
	
\end{document}
Does the first page of the document work differently in comparison to the others? Please, help me solve this problem!

I thank you all in advance.

Felipe

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Body Text wrongly written in Header

Post by Johannes_B »

You should check the log file for warnings. A warning is a wonderful thing, is is a message teling you something is strange.

Code: Select all

Package Fancyhdr Warning: \headheight is too small (9.6pt): 
 Make it at least 87.74654pt.
 We now make it that large for the rest of the document.
 This may cause the page layout to be inconsistent, however.
This is what i get running your example. Adding \setlength{\headheight}{90pt} to your preamble will take care of the problem.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Body Text wrongly written in Header

Post by Stefan Kottwitz »

Hi Felipe,

welcome to the forum!

Johannes' suggestion will probably fix it.

I suggest though to use the geometry package for setting text width and height, margin size, and header height. And by the way, normal text lines never need to be ended by \\. A line ending, so a paragraph ending, is done by an empty line in LaTeX. \\ only ends the line but does not end the paragraph - so if they actually are paragraphs, \\ may cause a bad effect.

Stefan
LaTeX.org admin
fpires
Posts: 15
Joined: Wed Dec 23, 2015 7:10 pm

Body Text wrongly written in Header

Post by fpires »

Thank you very much, Johannes and Stefan! You were right, I didn't pay attention to the warning message. Problem solved. Thank you!
Post Reply