Page numbers restart for preliminary pages

I have just started typesetting my PhD thesis. I am using the book class. I have a parent file where I define style, chapter header styling, page numbering, etc., and I include every chapter using \include{}. When compiled I have one single PDF file. However, I have a problem with page numbering on preliminary pages such as Abstract, List of Contents, List of Figures, etc. Page numbers restart on every preliminary page. Here is how my TeX file looks like

%Page number formatting for preliminary pages.
\fancypagestyle{preliminary}{
\fancyhf{}
\fancyfoot[C]{\thepage}
\pagenumbering{roman}
\fancypagestyle{plain}{\pagestyle{preliminary}}}

%Page number formatting for main matter.
\fancypagestyle{mainmatter}{
\fancyhf{}
\fancyfoot[C]{\thepage}
\pagenumbering{arabic}
\fancypagestyle{plain}{\pagestyle{mainmatter}}

\onehalfspacing

\newenvironment{abstract}{\chapter*{Abstract}}{}

\begin{document}

\pagestyle{preliminary}
\setcounter{page}{2}

\begin{abstract}...\end{abstract}

\tableofcontents
\listoffigures
\listoftables

\mainmatter

\pagestyle{mainmatter}
\include{chapter1}

\end{document}


Am I doing something wrong? I have a suspicion that pre-defined page number formatting at the very beginning is causing this but I am not sure. What do you guys think?

• \pagenumbering restarts the page counter at 1, so this is actually reset at page shipout, with every page. So, remove \pagenumbering{roman} and \pagenumbering{arabic} from the page styles, and include them directly in your document at the appropriate location. – Werner Jul 23 '13 at 4:34
• Thank you @Werner. It worked like a charm. Probably the fastest reply and solution at the same time. Thanks :) – Mustafa Hasanbulli Jul 23 '13 at 4:40

You define the two page styles preliminary and mainmatter to be the same, except for the numbering (roman in the former, arabic in the latter). So, for now, the following setup is what you're after:

\documentclass{book}

%... Preamble stuff

% Page style for preliminary pages.
\fancypagestyle{preliminary}{
\fancyfoot[C]{\thepage}% Footer
}

% Page style for main matter.
\fancypagestyle{mainmatter}{
\fancyfoot[C]{\thepage}% Footer
}

%...

\begin{document}

\pagestyle{preliminary}\pagenumbering{roman}
\fancypagestyle{plain}{\pagestyle{preliminary}}% Correct plain page style

%... Preliminary stuff

\mainmatter
\pagestyle{mainmatter}\pagenumbering{arabic}
\fancypagestyle{plain}{\pagestyle{mainmatter}}% Correct plain page style

%... Mainmatter stuff

\end{document}


Another common way of copying a page style into another is to use

\makeatletter
\let\ps@plain\ps@preliminary% Copy preliminary page style into plain
\makeatother

• Beautiful. Thank you. Though, I think, you forgot to add \pagestyle{} in \fancypagestyle{}{}. – Mustafa Hasanbulli Jul 23 '13 at 4:44