[Tex/LaTex] Report document class with upper right page numbers and modifying chapter title format

chaptersheader-footerpage-numberingtable of contents

I'm writing a lengthy masters thesis paper and am requiring some annoying editing of my TeX document. I need to have all of my main headers (table of contents, list of figures, list of tables, bibliography, and chapter headers) to be centered and at the top of their respective pages. Also, I must have the page numbers in the upper right corner of all pages. Unfortunately at the moment I'm not able to do both simultaneously. Here is my MWE:

\documentclass[12pt]{report}
\usepackage{fancyhdr}
\usepackage{setspace}
\usepackage[top=1in,bottom=1in,right=1in,left=1.5in]{geometry}
\usepackage{geometry}
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{float}
\usepackage[hang, raggedright]{subfigure}
\usepackage{amsmath}
\usepackage{xfrac}
\usepackage{indentfirst}
\usepackage{caption}
\usepackage{tabu}
\usepackage{siunitx}
\usepackage[subfigure]{tocloft}
\usepackage{caption}
\usepackage{titlesec}

\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{2}

\renewcommand\cftchapfont{\mdseries}
\renewcommand\cftchappagefont{\mdseries}

\captionsetup[table]{labelsep=space}
\captionsetup[figure]{labelsep=space}

\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\rhead{\thepage}
\pagestyle{fancy}
\assignpagestyle{\chapter}{fancy}
\setlength{\headheight}{15pt}

\renewcommand{\contentsname}{\hfill {\bf{\large TABLE OF CONTENTS}} \hfill}
\renewcommand{\listtablename}{\hspace{2in}\bf\large LIST OF TABLES}
\renewcommand{\listfigurename}{\hspace{2in}\bf\large LIST OF FIGURES}
\renewcommand{\bibname}{\hspace{2.1in}\bf\large REFERENCES}

\titleformat{\chapter}[display]{\normalfont\Large\bfseries\centering}{CHAPTER \thechapter}{-12pt}{\Large}
\titlespacing*{\chapter}{0pt}{-12pt}{24pt}
\titleformat{\section}{\large\bfseries}{\thesection}{1em}{}

\begin{document}

\tableofcontents
\clearpage
\listoftables
\clearpage
\listoffigures

\doublespacing
\chapter{A Chapter}
some text

\clearpage
some text on another page
\end{document}

This is of course part of a much larger document (my thesis paper is currently 114 pages long…) but here I've included all of my preamble and a small working document to show my problem.

If I remove this line:

 \titleformat{\chapter}[display]{\normalfont\Large\bfseries\centering}{CHAPTER \thechapter}{-12pt}{\Large}

from the code then I do in fact get a page number in the upper right corner of the page (for just chapter headers), but of course I still need to have my headers centered and at the top. And I'm not sure how to get the table of contents, list of figures, and list of tables at the top right corner of the page.

I appreciate any and all help I can get on this matter and please ask if you need more information about my code.

Best Answer

You should try to insert the following code in your preamble:

\setlength{\headheight}{15pt}
\fancypagestyle{plain}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[R]{\thepage}
\fancyhead[C]{\leftmark}}
\pagestyle{plain}

This will print on all your pages the "title" (ToC, LoF, LoT, Chapter name) in the centre of the header and the page number on the upper right of the page. If you want to disable it for one page, use the \thispagestyle{empty} command.

Remark Do not forget to remove this part of your preamble

\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\rhead{\thepage}
\pagestyle{fancy}
\assignpagestyle{\chapter}{fancy}
\setlength{\headheight}{15pt}

Note You have redefined the labels for the ToC, LoF and LoT which leads to some awkward alignment in the corresponding headers. It is then up to you to decide whether you want to keep them or redefine them.

Edit As suggested by egreg, it is not optimal to redefine the plain style with the \leftmark command. A better way to go is to use the following code in the preamble:

\setlength{\headheight}{15pt}
\pagestyle{fancy}
\fancypagestyle{mystyle}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[R]{\thepage}
\fancyhead[C]{\leftmark}}
\pagestyle{mystyle}

and to call \thispagestyle{mystyle} after the ToC, LoF, LoT and each chapter calls if you want to have this style even on these pages. However if the ToC, the LoF or the LoT is longer than one page you will have some problem using this new style because it won't be used on the first page of the concerned table (see this question and answer). In that case one workaround is to redefine the plain style as suggested previously.

Related Question