[Tex/LaTex] Why do \pagenumbering and \setpagecounter break \cleardoublepage

double-sidedpage-numbering

It had taken me a few hours to hunt down a bug with my Thesis when I discovered \cleardoublepage does not have the correct behaviour for twosided documents. It should force a page following the command to begin on an odd page so that when printed for book binding, the inner margin is on the left hand side.

I have sort of identified the cause. In the following MWE, two lines make \cleardoublepage fail if either of the line is set in the state in the following code.

To remedy this, firstly one must have the first page with an odd number, and secondly one must also remove the \pagenumbering{roman} line.

\documentclass[a4paper,10pt,twoside,english]{book}
\usepackage{lipsum}

\begin{document}
\setcounter{page}{0} %Title page must start from an odd number for \cleardoublepage later to work!?
\centering\Huge Testing \texttt{\textbackslash cleardoublepage}
\clearpage\pagenumbering{roman} %The roman numbering here breaks \cleardoublepage too
\normalsize\lipsum[2-7]\clearpage 
\cleardoublepage
\chapter{I need to begin on an odd page}
\end{document}

In my Thesis, I would like my title page label to be p.0, then next page starts from roman i, ii, iii… then switch to arabic. I am having no luck getting the chapters to appear as odd pages. I can sort of guess the reason, by switching pagenumbering number system and page number counter arbitrarily, one may turn a even page label to an odd and vice versa. However, I see no merit in \cleardoublepage checking the oddness of the page label, but not the actual page number (number of pages as appears in the output, page label p. ii may actually be the third page, for example). Any way to fix this?

Best Answer

Your problem is essentially due to setting the page number to 0 on the first physical page which means that the parity of all pages are out. Essentially none of the \clear(double)page commands in your example are having any effect as the page numbering and chapter commands are already issuing those commands.

\documentclass[a4paper,10pt,twoside,english]{book}
\usepackage{lipsum}

\begin{document}

\begin{titlepage}
\centering\Huge Testing \texttt{\string\cleardoublepage}
\end{titlepage}

\frontmatter

\lipsum[2-7]

\chapter{I need to begin on an odd page}
\end{document}

Keeps the parity of the physical page and printed page

1  -    Title
2  2    blank before front matter (you could use a thispagestyle if 2 not needed
3  i    front matter
4  ii
5  iii  first chapter