# Generate header of sections by keeping the page numbers at the bottom right throughout the whole document

I am using Easy thesis template to write my thesis.

I want the page numbers to be at the bottom right in all pages including, \frontmatter, \mainmatter, and \backmatter. (also chapter title page)

So after some search in the Internet, I use the code below:

\pagestyle{fancy}
% Clear the header and footer
\fancyfoot{}
% Set the right side of the footer to be the page number
\fancyfoot[R]{\thepage}

\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyfoot[RO,RE]{\thepage} %RO=right odd, RE=right even
\renewcommand{\footrulewidth}{0pt}}


After type the above code in the preamble, I added the code \pagestyle{plain} at the beginning of every chapter.

By doing this steps, I get the page numbers to be at the bottom right.

Since I am using single page (one column) format, I want the \section titles to be printed at the top left on every page.

I tried to play around with the options to get the header but the page number positions somehow go out of the way.

Can anyone give a hand to this issue?

• Do you want chapter titles to be printed somewhere? – Bernard Sep 16 '15 at 17:55
• I want the effect something like if I use \pagestyle{headings}. When I use this I get the section titles at the top left of each page. – Vijay Sep 16 '15 at 18:02
• In that case, did you try:\AtBeginDocument{\pagestyle{headings}}? – Bernard Sep 16 '15 at 18:19
• I tried to place \AtBeginDocument{\pagestyle{headings}} in the preamble of Thesis.tex. And I placed the command \pagestyle{plain} at the begining of chapter. But there is no any effect. – Vijay Sep 16 '15 at 18:29
• What is still not quite clear to me is this: you want section titles at the left of every header (odd page and even page), even the first page of a chapter. Nothing at the right (even though you have chapters). Page number at the the right footer (even at the beginning of a chapter). Nothing else in the footer. Is my guess correct? – Bernard Sep 16 '15 at 18:35

This code seems to do what you want:

\documentclass[12pt, a4paper]{Thesis}%

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{lipsum}

\renewcommand{\chaptermark}[1]{}%
\renewcommand{\sectionmark}[1]{\markboth{\thesection\enspace #1}{\thesection\enspace#1}}
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\rfoot{\thepage}
}
\pagestyle{plain}
\usepackage{etoolbox}
\pretocmd{\chapter}{\protect\thispagestyle{plain}}{}{}

\begin{document}
\chapter{Introduction}

\section{Motivation}
\lipsum[1-4]

\section{Another section}
\lipsum[5-8]

\section{Still another section}
\lipsum[9-12]

\end{document}