0

I am writing a thesis using the LaTeX template files that seem to have been used at my department for a while. The problem is, when I compile the code, I get a header with chapter number and title on the page where chapter 2 starts.

Chapter 2 Title and Header

It doesn't happen though on the page where chapter 1 begins.

Chapter 1 Title and Header

I want to remove the header from the start page of chapter 2 but despite trying a lot, I could not figure out what is causing it to appear there (and not on start page of chapter 1) and how to get rid of it. Will appreciate any help. Here is the MWE for the main LaTeX file:

\documentclass[11pt,a4paper,twoside]{report}
\usepackage[top=3cm, bottom=3cm, left=2.5cm, right=2.5cm]{geometry}
\usepackage[latin1]{inputenc}

% Page number must be in the upper righthand corner
\usepackage{fancyhdr}
\fancypagestyle{phdthesis}{
\fancyhf{} %clear all headers and footers fields
\rhead{\thepage} %prints the page number on the right side of the header
\renewcommand{\headrulewidth}{0pt}
 }
\fancypagestyle{plain}{\pagestyle{phdthesis}}

% to remove page numbers on empty pages (before chapter start)
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

 %% TITLE PAGE AND DECLARATION
 \pagestyle{empty}
 \begin{titlepage}
 \end{titlepage}

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% CONTENTS
 \tableofcontents

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% CHAPTERS
 \newpage
 \pagenumbering{arabic}

 %% INCLUDE TEXT OF CHAPTER 1 IN THE FILE chp1.tex 
 \include{chp1}

 %% INCLUDE TEXT OF CHAPTER 2 IN THE FILE chp2.tex 
 \include{chp2}

 %% INCLUDE TEXT OF CHAPTER 3 IN THE FILE chp3.tex 
 \include{chp3}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% BIBLIOGRAPHY
\bibliography{mybib}

\end{document}

Here is the code for all the 3 chapters which are saved separately as chp1.tex, chp2.tex and chp3.tex in the same directory:

\chapter{{\it Chapter 1 Title}}\label{chp1}
\thispagestyle{myheadings}
{\it Text for Chapter \ref{chp1}}

\chapter{{\it Chapter 2 Title}}\label{chp2}
\thispagestyle{myheadings}
{\it Text for Chapter \ref{chp2}}

\chapter{{\it Chapter 3 Title}}\label{chp3}
\thispagestyle{myheadings}
{\it Text for Chapter \ref{chp3}}

Please help.

  • I can not reproduce the issue using your code. Maybe there is a \pagestyle{fancy} before the chapters. Remove \thispagestyle{myheadings} after the \chapter commands. Then pagestyle plain is used on the chapter pages. Off topic: \it is deprecated for a long time and do not use font commands inside the argument of sectioning commands. – esdd May 19 at 11:33
  • Thanks a lot for taking time to look at my problem. Commenting out \thispagestyle{myheadings} after \chapter command worked for the header on chapter 2 start page but there was no \pagestyle{fancy} before the chapters. I don't understand but I very much want to, why it was this way? When I comment out \thispagestyle{myheadings} from chapter 2 LaTeX file, the header goes away but the same command appears on LaTex files for chapter 1 and 3 too and there no header appears whether or not I comment out this command. There's really no significant chunk of code that I didn't show here. – V Kahn May 19 at 12:06
  • @esdd, you said you can't reproduce the issue using my code. Can I do something to make it more reproducible? All I want to do is it to understand why \thispagestyle{myheadings} command on chapter 2 start page creates a header but the same command does not do it for chapter 1 and 3. – V Kahn May 19 at 13:19
  • Test your code example in a new folder. Then you can see what we get. There could also be a \pagestyle{phdthesis} or \pagestyle{plain} in your real code. Note that your code redefines plain using \fancypagestyle. They all activate the automatic setting of a \leftmark by \chapter and cleaning \rightmark. I am sure that your issue does not depend on the chapter number, but on the page number. You will get header entries only on even chapter pages, but not on odd chapter pages. – esdd May 19 at 18:33
  • Thanks a lot @esdd. You were right, I tested the code with 4 chapters and this time I got headers on chapters 2 and 4 (which start on even pages), but not on chapters 1 and 3 (which begin on odd pages). I checked my complete code and found that just before table of contents, there is a page for disclaimer and there \pagestyle{phdthesis} does appear. So you are are right in all cases. I work almost all the time with article class. Here, why does this \pagestyle{phdthesis} class produce headers on odd pages? I looked at how it was defined in the document preamble but could not figure it. – V Kahn May 19 at 18:44
1

Remove the \thispagestyle{myheadings} after the \chapter commands.

Then your own pagestyle phdthesis will be used on chapter pages, because of

\fancypagestyle{plain}{\pagestyle{phdthesis}}

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.