# How to use pagenumbering in the document?

In my Master thesis, I would like to have the title page without any page number and an acknowledgments section and the table of contents with roman numbers. The rest of the document should be numbered arabic.

I have tried this, to have roman numbers for the Table of contents and normal numbers for the rest.

\documentclass[12pt,ngerman,openany]{report}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{cite}
\usepackage[a4paper]{geometry}
%\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
%\usepackage{ngerman}{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{float}
\selectlanguage{ngerman}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{url}
\usepackage{epstopdf}
\usepackage{scrhack}
\usepackage{listings}
\usepackage{caption}
\titleformat{\chapter}{\rmfamily\huge}{\textbf\thechapter.}{25pt}{\huge\textbf}
\defcaptionname{ngerman}{\lstlistingname}{Code}
\defcaptionname{ngerman}{\lstlistlistingname
}{Codeverzeichnis}

\lstset{% general command to set parameter(s)
basicstyle=\sffamily\footnotesize, % print whole listing small
keywordstyle=\sffamily\footnotesize\bfseries, % ubold black keywords
identifierstyle=, % nothing happens
stringstyle=\sffamily\footnotesize, % typewriter type for strings
showstringspaces=false, % no special string spaces
numbers=left,
numberstyle=\sffamily\footnotesize,
stepnumber=1,
numbersep=10pt,
showspaces=false,
showtabs=false,
frame=lines,
morecomment=[l]{\%},
float=htbp,
numberbychapter=true
}

\begin{document}
\let\cleardoublepage\clearpage

\pagenumbering{roman}
\tableofcontents
\clearpage
\vspace*{75mm}
\chapter{Einleitung}
\section{Motivation}
bla bla bla
\section{Ziel}

bla bla
\chapter{Stand der Technik zur Mustererkennung}
\section{Die Zeitreihen}
bla bla
\subsection{Beschreibung}
bla bla
\subsection{Erklärung}

bla bla

\subsection{Vorhersage}
bla bla
\subsection{Kontrolle}
bla bla
\section{Feature Extraktion}
bla bla
\subsection{Autokorrelation}
\subsection{Was ist Autokorrelation?}
bla bla

\subsection{Autokorrelation und Zeitreihen}
bla bla

\subsubsection{Zeitreihe-Diagramm}

bla bla
\subsubsection{Lagged Streudiagramm}
bla bla

\subsubsection{Autocorrelation-Function (Korrelogramm)}
bla bla
\subsection{Spektralanalyse}
\subsection{Was ist Spektral-Analyse}
bla bla
\end{document}

• The simple answer is to use \renewcommand{\thepage}{\roman{page}} and \setcounter{page}[1}, etc. – John Kormylo Jul 23 '14 at 15:44

\pagenumbering{style} changes the appearance of \thepage to match style and resets the page count to one (\@one). This change in the page number can be noticed with the shipout of the next page, which is in fact the page currently typeset.

Now, where to put the \pagenumbering command? A good idea is to place this immediately after a chapter command.

\documentclass{report}
\usepackage{blindtext}
\usepackage{showframe}
\begin{document}
\chapter{standard counting}
\blindtext[8]
\chapter{roman counting}
\pagenumbering{roman}
\blindtext[5]
\end{document}


All works perfectly fine. But now, what does happen if we take the same example, but use twoside? Package showframe helps us determine what left and right pages are. The marginparcolumn is always on the outer side.

\documentclass[twoside]{report}
\usepackage{blindtext}
\usepackage{showframe}
\begin{document}
\chapter{standard counting}
\blindtext[8]
\chapter{roman counting}
\pagenumbering{roman}
\blindtext[5]
\end{document}


As you may notice, two odd (right) pages follow each other, making it very hard to bind the final output. The chapter command issues a clearpage by default (cleardoublepage if option openright is used) which isn't enough in this case. But now, we can't issue the needed cleardoublepage after chapter has been issued. That would make no sense. But we can use cleardoublepage before chapter. If the pagenumbering command is issued before or after chapter doesn't make a difference now.

\documentclass[twoside]{report}
\usepackage{blindtext}
\usepackage{showframe}
\begin{document}
\chapter{standard counting}
\blindtext[8]
\cleardoublepage
\chapter{roman counting}
\pagenumbering{roman}
\blindtext[5]
\end{document}


Is there anything to say about titlepages?

Yep, the standard classes and the KOMA-classes differ in their behaviour.

\documentclass{report}
%\documentclass{scrreprt}
\usepackage{showframe}
\title{How does pagenumbering work?}
\author{\TeX.SX}
\begin{document}
\maketitle
\chapter*{What pagenumber do we get here?}
pagenumber: \thepage
\end{document}


As we can see by running this example with the standard report, the titlepage is not counted, the next page has page number 1.
The KOMA-class differs, the titlepage is counted, the next page gets number 2.

Changing the example to twoside both classes number the pages in the same way. There is a simple reason for that, odd pages are always right-hand pages.

Why are all examples using report and its KOMA counterpart?
The behaviour described is defined in the titlepage environment. article doesn't use a titlepage per default, books use titlepage, but are printed twoside by default.

The same are working for memoir as well. But it should be mentioned, that the title of a standard memoir class uses the pagestyle title which is an alias for plain. So the titlepage gets (visibally) numbered by default.

What about pagenumbering in articles and books? If you want to change the pagenumbering in an article, you should consider switching to a class with chapters. book provides the frontmatter, mainmatter and backmatter mechanism, taking care of pagenumbering and some other stuff.

• I have read this several times and still have no idea what you're trying to tell me. after your comment on my post, I am getting an extra blank page, how to remove it. Simple question. You're always telling me to read this answer, however, I do not know what exactly is it that I should do. – Beyond-formulas Jan 31 '16 at 19:28
• @Beyond-formulas You need this blank page for later binding. If you dont have it, your document is screwed. – Johannes_B Jan 31 '16 at 19:39
• I don't want this page it is messing with my roman numbers! My roman numbers should start with "5" for the acknowledgement then "6" for the abstract, when this stupid empty page is appearing between my ack and abstract, my abstract starts at page "7" in roman! this looks terrible in ToC, you see? If twoside is screwing all this, why would I need it for? Why did the department place this as a sample tex file for all.... Can I replace this twoside by something else? – Beyond-formulas Jan 31 '16 at 19:48
• @Beyond-formulas With respect to that empty page, i can't say much but *Please ad a minimal working example (<- Link) to your latest question that led you here. About the twoside options, i cannot tel you why the guys in your department added that. Better ask them in person ;-) – Johannes_B Jan 31 '16 at 19:54
• I did a new question (minimal example), even removed the twoside and the empty page is still there... If would like to check it – Beyond-formulas Jan 31 '16 at 20:30