# Header and Footer (Fancyhdr) don't work

I want to configure the header and footer: the header I want to be fixed (the title of the project on the left and an image on the right), but that the foot change according to it is even or odd page, and that this one that includes the section and the page number.

The header I want to make (imitating Word) is the previous one. I will read carefully what you have answered me.

The header and the foot should be within the margins.

I don't know what is wrong with the code that makes it not work and looks bad.

\documentclass[11pt,a4paper]{book}

\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

%\usepackage[latin1]{inputenc} % Paquete que permite las tildes, cambiar latin1

%\usepackage[spanglish]{babel} % Para tener los textos automáticos en castellano

\usepackage{lipsum}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx} %Permite importar imagenes
\usepackage{float}    %Permite controlar la posicion de imagenes

\usepackage{subfigure}
\usepackage{fullpage}
\usepackage{hyperref}
\usepackage{pdfpages}
\usepackage[none]{hyphenat}
\usepackage{xcolor}

%margenes del documento

%interliniado para todo el documento, incluyendo titulos
%\parindent 0ex
\renewcommand{\baselinestretch}{1.5}

\usepackage{setspace}

%\doublespacing
%\onehalfspace
%\singlespace
%\spacing{1.5}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}

\fancyfoot[LE,RO]{\thepage}
\fancyfoot[RE,LO]{\rightmark}

\renewcommand{\footrulewidth}{0.5pt}

%------------------------------------------------------------------------------------

\begin{document}

\section{Resumen}

\lipsum[1]
\lipsum[2-8]

\end{document}


Thanks for the answers. I just met to know this field.

The header I want to make (imitating Word) is the previous one. I will read carefully what you have answered me.

The header and the foot should be within the margins.

• Note that subfigure is obsolete and ought not be used. hyperref is loaded too early and should be loaded last. It makes no sense to set \baselinestretch and then load setspece. It makes no sense to load fullpage and then load geometry. – cfr Jul 29 '18 at 4:01
• See my updated answer, I added an image. Is this what you want? And +1 to cfr's comment, I haven't included it in my MWE, but you should heed it. – nox Jul 30 '18 at 23:12

Why do you use the package fullpage? The description reads:

This pack­age sets all 4 mar­gins to be ei­ther 1 inch or 1.5 cm, and spec­i­fies the page style.

This is obviously not what you want. Delete it, and everything looks fine. Also you should think about whether you want to use the option includeheadfoot in geometry. Have a look at the geometry user's manual.

I added the option showframe to the geometry package in order to show the current frames. You can safely comment it out or delete it.

\documentclass[11pt,a4paper]{book}

\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

%\usepackage[latin1]{inputenc} % Paquete que permite las tildes, cambiar latin1

%\usepackage[spanglish]{babel} % Para tener los textos automáticos en castellano

\usepackage{lipsum}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx} %Permite importar imagenes
\usepackage{float}    %Permite controlar la posicion de imagenes

\usepackage{subfigure}
\usepackage{hyperref}
\usepackage{pdfpages}
\usepackage[none]{hyphenat}
\usepackage{xcolor}

%margenes del documento
\usepackage[left=3.00cm,
right=2.50cm,
top=2.50cm,
bottom=2.50cm,
showframe
]{geometry}

%interliniado para todo el documento, incluyendo titulos
%\parindent 0ex
\renewcommand{\baselinestretch}{1.5}

\usepackage{setspace}

%\doublespacing
%\onehalfspace
%\singlespace
%\spacing{1.5}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}

\fancyfoot[LE,RO]{\thepage}
\fancyfoot[RE,LO]{\rightmark}

\renewcommand{\footrulewidth}{0.5pt}

%------------------------------------------------------------------------------------

\begin{document}

\section{Resumen}

\lipsum[1]
\lipsum[2-8]

\end{document}


edit: I added an image. You can specify the header height and the image scales automatically. I shifted the image down a bit, to really fit the header. Maybe you have to try different values to get your desired result. If you want to place the image higher, you might have to adjust the value for the image height, as the line has a height of 0.7\baselineskip and a depth of 0.3\baselineskip. If you want to lower it only by .2\baselineskip, you should set the image height to .9\headheight (=.7+.2).