# Text over the header with figure

I'm putting a figure in the header of my article, but the text is getting superimposed in the header only on the first page. I think that the problem is with the figure because when I remove it, the problem disappears.

I tried this answer but it did not help me with the problem

The code is above this line:

\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{subfig}% http://ctan.org/pkg/subfig
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
SERVIÇO PUBLICO FEDERAL\\
\title{[RASCUNHO] Brincando com cabeçalhos}
\date{November 2018}

\setlength{\parindent}{1.5cm}
\setlength{\parskip}{0.2cm}
\makeindex

\begin{document}

% \maketitle

\section{First Section}

\lipsum
\lipsum[3-16]

\newpage

\section{Second Section}
\lipsum
\section{Second Section}

\lipsum

\end{document}


To clarify my question, a print screen of the problem is presented below:

• Welcome to TeX.SE! How do you think anyone can resolve the clash between the tiny headheight=.4in and your bulky header? – user121799 Nov 29 '18 at 21:14

The headheight is too small. To increase it with \setlength{\headheight}{...}

The necessary size will depend on the image and can be found as a warning in the .log file of your document. For a dummy image I used I for example got

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


so I rounded up and used \setlength{\headheight}{67pt}

\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{subfig}% http://ctan.org/pkg/subfig
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
SERVIÇO PUBLICO FEDERAL\\
\title{[RASCUNHO] Brincando com cabeçalhos}
\date{November 2018}

\setlength{\parindent}{1.5cm}
\setlength{\parskip}{0.2cm}
\makeindex

\begin{document}

% \maketitle

\section{First Section}

\lipsum
\lipsum[3-16]

\newpage

\section{Second Section}
\lipsum
\section{Second Section}

\lipsum

\end{document}


• Actually, I've tried this strategy, but because of the margins, I thought that I was in the wrong direction. To set the margins, I'm using \usepackage[a4paper,left=3cm,right=3cm,top=2.5cm,bottom=2.5cm,headheight=.4in,headsep=12pt,heightrounded]{geometry}, but I'm can't see any difference. Is it related to the header? – José Joaquim Nov 29 '18 at 21:22
• @JoséJoaquim You make the headheight veryyyyyyyyy small. Best is to read your .log file, it clearly says what to do – book Nov 29 '18 at 21:25