# Fancyhdr displaying wrong chapter

I'm currently writing my dissertation and used this template; https://www.sharelatex.com/templates/thesis/graduate-thesis

However I'm getting the most unusual error when using fancyhdr to display the chapter name in the header.

I want it so on the left side it displays the chapter name, and the page number on the right. Previously in the template the following was used;

\lhead{\emph{Contents}}  % Set the left side page header to "Contents"


So I copied this syntax when including the chapters like so ;

\input{Chapters/Chapter1} % Introduction

\input{Chapters/Chapter2} % Background Research
\lhead{\emph{Background Research}}  % Set the left side page header to "Background Research"


The problem I am getting is that the chapter names are messing up, for example: Chapter 4 = Project Planning, and chapter 5 = Design, but for chapter 5 it wont display 'Design' in the header at all and carry on displaying 'Project Planning'.

Something else that is baffling me is that I originally had a chapter named 'Development' , and another named 'Testing', however I merged the two into one (just deleted the testing chapter and put the content into the development chapter), and renamed the lhead to 'Development & Testing', however when compiling and viewing the PDF, some pages will show 'Development' in the header, and others 'Development & Testing'.

I don't know why this is happening, the compiling I am doing is;

PdfLaTeX + Bib(la)tex + PdfLaTeX (x2) + View Pdf

If more code is required, I can supply it, but I thought If I were to link the template I am using, it would show what the code would look like.

• Welcome. I have troubeling news for you. This template is very very bad and you shouldn't use it. There are several better templates around. If you go on working with this template, you will get more issues. Sorry. – Johannes_B Apr 30 '17 at 11:52
• Your issue: you input some file and then set the header afterwards. It is not astonishing that your "error" occurs. Try putting the header information at the right place, before. – TeXnician Apr 30 '17 at 11:55
• If you are interested in the history of the template: github.com/johannesbottcher/templateConfusion/blob/master/… – Johannes_B Apr 30 '17 at 12:00
• Even having the header information before the chapter inclusion, I get a similar problem. As for this template, I dreaded hearing this, are there any templates you would recommend? – Richard G Apr 30 '17 at 12:00
• Hi Richard - welcome to tex.stackexchange. A better solution than manual use of \lhead (or whatever) is to get latex to keep track of your chapter names (and/or section names) itself. There are examples around that show how to use \leftmark and \rightmark to keep track of these. – Andrew Kepert Apr 30 '17 at 12:02

https://github.com/johannesbottcher/templateConfusion/blob/master/ourFamousThesisTemplate.md

A quick fix to the solution is to include the following in each chapter file (providing you remove the \lhead{chapter name goes here} from the main file);

\chapter{Background Research}
\label{Chapter2}

• I recommend starting with the book class – Moriambar Apr 30 '17 at 12:25
• Using \lhead still is wrong. The whole template does strange things. – Johannes_B Apr 30 '17 at 12:30