Page Layoutmargin gone wrong on first page

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
bobonaut
Posts: 3
Joined: Fri Mar 02, 2012 2:13 am

margin gone wrong on first page

Post by bobonaut »

Dear community this is my first post so bear with me :D

I just started out with LaTeX and to be honest there are a lot of things i have to learn but since this document is due in a few days and i still have a lot to type i though i would ask for a solution here.

I am working on a project initiation document and somehow i managed to create a title page with tikz and some examples found on the internet. I can probably do it a lot better but that is not the point.
After finishing the title page i turned to headers. With the fancyhdr package and geometry packages i managed to create nice headers, however here is the problem that arises. The first page or second (i tried it with a barebone tex file) the margins that are supposed to press the text into the correct position are way off. Every page after that is perfectly fine.

Here is a small code example:

Code: Select all

\documentclass[pdftex, 11pt,a4paper] {article}
\usepackage[top=0cm,bottom=50px,left=2cm,right=2cm,includeheadfoot,headsep=0cm]{geometry}
\usepackage{xcolor}
\usepackage{fancyhdr}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{lipsum}

% Header en footer layout

\definecolor{customcolor}{RGB}{202,2,2}

\renewcommand{\headrulewidth}{0pt}
\lhead{\color{customcolor}\rule[0.8cm]{0.55\textwidth}{0.2pt}}
\rhead{	
	\begin{tikzpicture}	
		\node[opacity=0.8]{%
			\includegraphics[scale=0.80]{./Images/header_logo.png}
		};%
	\end{tikzpicture}
}

% Footer
\renewcommand{\footrulewidth}{0pt}
\rfoot{foobar}

\pagestyle{fancy}

\begin{document}
\newgeometry{margin=2cm,includefoot}
\lipsum[1]
\newpage
\renewcommand{\contentsname}{Inhoud}
\tableofcontents

\section{Chapter 1}

\end{document}
If you remove the lipsum text and the new page command you will notice that the table of contents shows the same issue here. Because my ToC is on the second page (after the title page) it create this problem.
I have tried \vspace and \vspace* but that does not work for me.
I am probably doing something wrong here (and this might be a rookie mistake) but i would apriciate if any of you could help me out.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

margin gone wrong on first page

Post by Stefan Kottwitz »

Hi,

welcome to the board!

Do you get any warning? Perhaps check your .log file, you could also post it here as attachment.

For example, the hight of the header could be too small, then you would notice header margin changes and you would get a warning like

Code: Select all

Package Fancyhdr Warning: \headheight is too small (12.0pt): 
 Make it at least <x>pt.
 We now make it that large for the rest of the document.
 This may cause the page layout to be inconsistent, however.
In that case you could fix it by

Code: Select all

\setlength{\headheight}{<x>pt}
Stefan
LaTeX.org admin
bobonaut
Posts: 3
Joined: Fri Mar 02, 2012 2:13 am

Re: margin gone wrong on first page

Post by bobonaut »

Wauw that was quick and it actually solved the problem.
In this case i am curious what the problem was (any tips on where i can find why the header was too small?)
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

margin gone wrong on first page

Post by Stefan Kottwitz »

In such a case check your header commands, such as \lhead and \rhead. Here, you put an image into the header, which is just too big for the default height.

Stefan
LaTeX.org admin
bobonaut
Posts: 3
Joined: Fri Mar 02, 2012 2:13 am

Re: margin gone wrong on first page

Post by bobonaut »

I see, thank you for such a quick reply. I am still a novice just started out with LaTeX and to be honest i love it. Still need to read a lot of documentation because i am pretty sure that there are things that can be done better. But i learn as i go and this is a good stepping stone for my thesis
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: margin gone wrong on first page

Post by Stefan Kottwitz »

LaTeX is great, even if there's much to read. Good luck with your thesis, and in case of questions just visit this site. ;-)

Stefan
LaTeX.org admin
Post Reply