# My LaTeX header only affects the first page of each chapter, why?

I have made a heading for my final degree project where an image appears, my name and the name of the project, but it only appears on the first page of each chapter, in the others the heading that LaTeX puts by default appears. This is the code for my header:

\fancypagestyle{plain}{
% Nombre del documento
% Nombre de la Unidad en concreto
\newcommand{\autor}{\textsc{Juan Francisco Molina Pérez}}
% Nombre del módulo (asignatura)
\newcommand{\seccion}{\leftmark}
{\color{light-gray} \footnotesize \titulo} \\
{\color{light-gray} \footnotesize \autor}  \\
\color{light-gray} \seccion
}
\rfoot{Página \thepage\ de \pageref{LastPage}}  % Número de página
\cfoot{} %para vaciar número de página que viene por defecto

}


It should be noted that I have divided the work into parts in LaTeX, making a file only for the header and calling it in the general file of the TFG.

• Hello and welcome to Text.Se. The common language used here is english. So please ask your question in english so that other people can help you with your problem. Mar 13 at 13:30
• ¿Puede por favor, hacer su pregunta en Inglés? Mar 13 at 13:31
• I run your text in an online translator. Next time please do it yourself. Mar 13 at 14:04
• Please specify at least what document class you are using. Most document classes specify the plain style only for the first page of a chapter, and a different style (often headers) for all other pages. Mar 13 at 16:05

You are making the adjustments only to the pagestyle plain, which by default appears on title and chapter pages only. There are two options to change where the header appears.

### 1.

If you want to use your header definition as it is for every page, you can add

\pagestyle{plain}


after the definition, to make 'normal' pages also use the plain style.

### 2.

If you want the header to appear on all pages, except at the beginning of a chapter (wich is the default and usually the desired behavior), you can set your header definition for a different style, like in this MWE:

\documentclass{book}
\usepackage{blindtext}

\usepackage{fancyhdr}

\fancypagestyle{fancy}{%
\rfoot{\thepage}
\cfoot{}
}
\pagestyle{fancy}

\begin{document}
\Blinddocument
\end{document}

• Thank you very much for your help! Mar 16 at 18:29

I prepared a document with two chapters and seven pages. Usually you define two styles: plain and fancy.

With the standard classes every \chapter invokes the plain style. The fancy style is applied to the normal pages.

You can also define others styles (I used the name withphoto for the third) that can be called in particular pages using \thispagestyle{withphoto}

Choice one: you want your photo at the beginning of every chapter.

You need to define two pagestyles: plain, that is invoked by chapter, and fancy for rest of the pages.

Choice two: you want your photo only at the beginning of the first chapter.

You need three styles: withphoto to be invoked once as \thispagestyle{withphoto}, plain called by every other chapter and fancy the style used by normal pages.

This is the code for the second choice. Note he use of the package geometry to create space for the photo.

\documentclass[12pt,a4paper]{report}

\usepackage[utf8]{inputenc}
\usepackage{graphicx}

\usepackage{lastpage}
\usepackage{fancyhdr}

\usepackage[spanish]{babel}
\usepackage{xcolor}

\usepackage{kantlipsum} % dummy texto

% Nombre del documento
% Nombre de la Unidad en concreto
\newcommand{\autor}{\textsc{Juan Francisco Molina Pérez}}
% Nombre del módulo (asignatura)
\newcommand{\seccion}{\textsc{Asignatura}}

\fancypagestyle{plain}{% first page of chapters after the first
\fancyhf{}
\fancyfoot[R]{Página \thepage\ de \pageref{LastPage}}  % Número de página
}

\fancypagestyle{fancy}{% normal pages
\fancyhf{}
}

\fancypagestyle{withphoto}{% only first chapter
\fancyhf{}
{\color{gray} \footnotesize \titulo} \\
{\color{gray} \footnotesize \autor}  \\
{\color{gray} \footnotesize \seccion }
}
\fancyfoot[R]{Página \thepage\ de \pageref{LastPage}}  % Número de página
}

\pagestyle{fancy} % set fancy headers for normal pages

\begin{document}
\chapter{El primero}
\thispagestyle{withphoto}
1.  \kant[1-3]
\section{A}
2.  \kant[4-8]
\section{B}
3.  \kant[2-5]
\chapter{El segundo}
4.  \kant[9-12]
\section{C}
5. \kant[15-20]
\end{document}


If want the Choice one convert withphoto in plain and comment \thispagestyle{withphoto}.

• Thank you very much for your help! Mar 16 at 18:30
• I have remake the header how you said to me, but now I have a new probblem. With the new code, Latex say to me this: Timed out. Sorry, your compile took too long to run and timed out. This may be due to a LaTeX error, or a large number of high-res images or complicated diagrams. I have convert the image in the header to pdf, but this not solved the problem. ¿What can I do?. Thanks. Mar 16 at 18:53
• I think you should ask a new question. The problem you mention is not coming from the image of the header, but form the code you are running. Meanwhile comment it part by part to try to pinpoint the origin. Mar 16 at 20:28