# Page numbering issue on part and chapter pages

I want to have my pages on the top right corner of all of my pages. However, for every \part and \chapter the page number is on the bottom middle.

My code (the numbering part) is:

\documentclass[a4paper,twoside,12pt]{report}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot{}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}{0pt}{0pt}{10pt}
\pagenumbering{arabic}

\begin{document}
\setcounter{page}{1}
\pagenumbering{arabic}
\part{aaaaaaaa}
\chapter{bbbbbb}
\chapter{ccccc}
\section{ddddd}
\end{document}


There is way more code and of course lots of stuff written everywhere. On this example, the page number is on the bottom middle for the page with \part{aaaaaaaa}, \chapter{bbbbbb}, \chapter{ccccc}, on the top right for the rest of the document and I would like to have it on the top right corner for every pages.

First pages of chapters use the plain page style. To also move the page number on these pages, you can redefine the pagestyle using \fancypagestyle{plain}{\fancyhead{}\fancyfoot{}\fancyhead[R]{\thepage}}. (See also "10 Redefining page style plain" in the fancyhdr package manual.) To additionally get rid of the warning Package Fancyhdr Warning: \headheight is too small (12.0pt): I have added \setlength{\headheight}{15pt}to your example.

\documentclass[a4paper,twoside,12pt]{report}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyfoot{}

\fancypagestyle{plain}{%
\fancyfoot{}
}

\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}{0pt}{0pt}{10pt}

\pagenumbering{arabic}

\begin{document}
\part{aaaaaaaa}
\chapter{bbbbbb}
\chapter{ccccc}
\section{ddddd}

\end{document}


Sincoe you are using twoside you might also be interested to use \fancyhead[RO]{\thepage}\fancyhead[LE]{\thepage} instead of \fancyhead[R]{\thepage}

• Thank you very much, it works perfectly. What does \fancyhead[RO]{\thepage}\fancyhead[LE]{\thepage} does? Jul 8 '19 at 7:30
• R and L stand for right and left, while O and E stand for odd and even. RO and LE ensure that your page numbers will always be at the outer margin if you print your document double sided. Jul 8 '19 at 8:29