1

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.

Header

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
 % por utf8 si no funciona (depende de cada ordenador)

 %\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
 \usepackage[left=3.00cm, right=2.50cm, top=2.50cm, bottom=2.50cm, includeheadfoot]{geometry}

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

 %interliniado para especificar en cada parte: titulos, subtitulos, y parrafos
 \usepackage{setspace}

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

 %Encabezado y pie de pagina
 \usepackage{fancyhdr}
 \pagestyle{fancy}
 \fancyhf{} 

 \fancyhead[L]{Dimensionamiento de un contradique y muelle para remolcadores}

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

 \renewcommand{\headrulewidth}{0.5pt}
 \renewcommand{\footrulewidth}{0.5pt}

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

\begin{document}


\section{Resumen}

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


\end{document}

Header

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.

  • 1
    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
1

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.

Also, I added the correct header size for this font.

\documentclass[11pt,a4paper]{book}

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

%\usepackage[latin1]{inputenc} % Paquete que permite las tildes, cambiar latin1
% por utf8 si no funciona (depende de cada ordenador)

%\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,
            includeheadfoot,
            showframe
]{geometry}

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

%interliniado para especificar en cada parte: titulos, subtitulos, y parrafos
\usepackage{setspace}

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

%Encabezado y pie de pagina
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\setlength{\headheight}{13.6pt} %% <-- added, change headheight to suit image

\fancyhead[L]{Dimensionamiento de un contradique y muelle para remolcadores}
\fancyhead[R]{Your Image \raisebox{-.3\baselineskip}{\includegraphics[height=\headheight]{example-image}}} %% <-- added

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

\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0.5pt}

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

\begin{document}


    \section{Resumen}

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


\end{document}

result

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.