# Chapter number on page header is not updated in LaTeX document

I have a small technical problem but I have been unable to find a solution to it so far.

In my thesis document, the chapter numbers that are displayed on page headers are not updated. It keeps on showing "Chapter 1. Some_Chapter_Name" as header. The reason I don't understand is that the chapter numbers on the first page of each chapter is properly incremented but not as page headers for next pages.

Any help will be much appreciated. I am attaching the complete style code for my LaTeX document later on. I believe this is the relevant section to the problem:

=============== SHORTER VERSION =================

% Set up the document
\documentclass[a4paper, 11pt, oneside]{Thesis}  % Use the "Thesis" style, based on the ECS Thesis style by Steve Gunn

\renewcommand{\chaptermark}[1]{\btypeout{\thechapter\space #1}\markboth{\@chapapp\ \thechapter\ #1}{\@chapapp\ \thechapter\ #1}}

\usepackage{amsmath,amsfonts,amssymb,amscd,amsthm,xspace}
\theoremstyle{plain}
\newtheorem{example}{Example}[chapter]
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{axiom}[theorem]{Axiom}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
\usepackage[centerlast,small,sc]{caption}
\setlength{\captionmargin}{20pt}

\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage[scriptsize]{subfigure}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{listings}
\usepackage{lstpatch}
\usepackage{lscape}
\usepackage{longtable}
\usepackage{supertabular}
\usepackage{algorithmic}
\usepackage{algorithm}

\usepackage[pdfpagemode={UseOutlines},bookmarks=true,bookmarksopen=true,
bookmarksopenlevel=0,bookmarksnumbered=true,hypertexnames=false,
plainpages=false,pdfpagelabels,
pagebackref]{hyperref}


The Thesis template and an example document can be found on http://www.sunilpatel.co.uk/thesis-template/.

-
Could you please try to make your example a little more minimal? Cut stuff out of the files that isn't related to the problem. –  Seamus Dec 31 '10 at 19:30
Hi, I actually posted smaller examples before and the solutions people suggested didn't work..So this time, i have posted the complete version. –  Omer Khalid Dec 31 '10 at 19:31
I have added the shorter version of the latex code as well. I hope this will help. –  Omer Khalid Dec 31 '10 at 19:35
Preparing a minimal example is an important part of the detection process. It might actually eliminate the need to ask a question. Don't ask the community to do this for you. –  Matthew Leingang Dec 31 '10 at 20:21
To minimize your example, I suggest first using the lipsum package, rip out the content of your thesis, and make some chapters with enough filler text to show your problem. Next, remove one half of the packages you are using, and check if the problem remains. Repeat until the problem goes away. Then you know the problem lies with the packages you just removed. Put half of them back in … I hope you get the idea, which is really one of performing a binary search. Much more efficient than removing one feature at the time. –  Harald Hanche-Olsen Dec 31 '10 at 22:24

Your document is oneside, but Thesis.cls expects twoside. This can be seen in these two lines of Thesis.cls:

\lhead[\rm\thepage]{\fancyplain{}{\sl{\rightmark}}}


That class uses old-fashioned fancyheading commands. For twoside mode, the optional argument refers to even pages, the mandatory argument refers to odd pages. Here, in oneside mode, \rhead overwrites the right mark with the page number.

## Solution:

Change to twoside mode or, if you would really like to use oneside: call \lhead and \rhead without optional arguments or use recent commands of fancyhdr.

Note: since you did not post a minimal working example, it took me a lot of time to work out the solution. I've done this because you don't know the importance of minimal working examples yet or don't know how to create them. Have a look at What is a minimal working example? and at I've just been told I have to write a minimal example, what is that?. Next time please provide a small compilable code example which shows the problem.

-
@Stefan: where do you get the Thesis.cls? –  Herbert Jan 1 '11 at 16:17
@Herbert: I got it from sunilpatel.co.uk/thesis-template , I added that link to the question and removed the embedded class source. –  Stefan Kottwitz Jan 1 '11 at 16:19
Hi Stephan, thank you for comments and efforts; I really appreciate them. Actually the reason I placed lot more code, because I was unable to locate the problem. –  Omer Khalid Jan 1 '11 at 22:21
@Stefan: I tried both twoside or oneside without \rhead and \lhead options. Unfortunately, it didn't work. You mentioned using recent command of fancyhdr. Could you please elaborate more on that? Which precise commands I could use? –  Omer Khalid Jan 1 '11 at 22:22
@Omer: Changing oneside to twoside immediately works for me. In contrast, if I use onside, I could fix it by \lhead{\fancyplain{}{\sl{\rightmark}}}\rhead{\fancyplain{}{\sl{\leftmark}}}. Page numbers could go to the footer because in oneside theres no space if left head and right head are used for marks already. Just take a look at the [fancyhdr manual](http://tug.ctan.org/tex-archive/macros/latex/contrib/fancyhdr/fancyhdr.p‌​df) for explanation of commands like fancyhead` etc. –  Stefan Kottwitz Jan 1 '11 at 23:47