The following example uses package zref
, in especially zref-abspage
, which provides a counter for the absolute page number. \mainmatter
writes a reference mainmatter
with property abspage
, the absolute page number, into the .aux
file. In the next run, the page number is set at the beginning in \frontmatter
to the negative number:
\documentclass{book}
\usepackage{zref-abspage}
\makeatletter
% Add label to \mainmatter for the absolute page number
\g@addto@macro\mainmatter{%
\zref@labelbyprops{mainmatter}{abspage}%
}
\g@addto@macro\frontmatter{%
% Overwrite \pagenumbering{roman} of the original \frontmatter
\pagenumbering{arabic}%
% Set the page number to the number of pages in the frontmatter
% with reverted sign.
\setcounter{page}{-\zref@extractdefault{mainmatter}{abspage}{0}}%
% The label is already on page n + 1, the first page of the main matter.
\stepcounter{page}%
% Also page number 0 is available:
\stepcounter{page}%
% Ensure, that the first page is odd-numbered.
\ifodd\value{page}%
\else
\addtocounter{page}{-1}%
\fi
\zref@refused{mainmatter}%
}
\makeatother
\begin{document}
\frontmatter
\tableofcontents
\chapter{Introduction}
\mainmatter
\chapter{Main chapter}
\end{document}
Result:
- Page -3: Contents
- Page -2: Empty page because of \cleardoublepage of the following
\chapter
- Page -1: Chapter "Introduction"
- Page 0: Empty page because of \cleardobulepage of the following
\mainmatter
- Page 1: Chapter "Main chapter", the first page in main matter