# How to avoid page numbering being re-started by titlepage?

See the MWE below. How can I avoid that page numbering in the frontmatter is re-started by \titlepage? I would like the preface to have page number V.

\documentclass{book}

\usepackage{lipsum}
\usepackage[plainpages=false,pdfpagelabels]{hyperref}
\hypersetup{pageanchor=false}
\usepackage{bookmark}

\title{Lipsum}
\author{lpdbw}

\begin{document}

\frontmatter
\pagenumbering{Roman}

\lipsum

\begin{titlepage}
\maketitle
\end{titlepage}

\chapter*{Preface}
\lipsum

\mainmatter

\chapter{Introduction}
\lipsum

\end{document}


PS: Question edited and reformulated.

-
just put \setcounter{4} before \chapter*{Preface}. (won't work if you have the preface in a separate file, and \include{preface} because of a built-in asynchronicity. but \clearpage after the \setcounter should take care of that, with no blank pages as long as nothing is on the page.) –  barbara beeton Aug 25 '12 at 12:23

With book.cls you can't avoid at user level that the page numbering restarts at titlepage: \setcounter{page}{1} is hard wired. So you would have to redefine titlepage or reset the page counter after \begin{titlepage} manually.

In the KOMA class scrbook, the page counter is not reset by titlepage but by \maketitle, and \maketitle has an optional argument to override the page counter. So you can do something like this:

\documentclass{scrbook}
\usepackage{lipsum}
\usepackage[plainpages=false,pdfpagelabels]{hyperref}
\title{Lipsum Here page: \thepage}
\author{lpdbw}

\begin{document}
\frontmatter
\pagenumbering{Roman}
abc

\begin{titlepage}
\maketitle[\value{page}]
\end{titlepage}

\mainmatter
\chapter{Introduction}
\lipsum

\end{document}

-
I don't want to change the documentclass in an already finished document and hence I would rather stick to book. Is it possible to store the value of the counter of the last page before the titlepage? This would enable me to set the counter manually after the titlepage to this value. –  lpdbw Aug 25 '12 at 9:45
... and what's about chaning the behaviour of titlepage? It shouldn't be too diffcult to insert some lines in the preamble preventing book to restart page numbering at the titlepage ... –  lpdbw Aug 25 '12 at 9:57
Sure, you can store the value in a counter. But imho the easiest is to set a concrete (odd!) number like this: \begin{titlepage}\setcounter{page}{3} – you can't have so many pages before titlepage. Btw: You should use the [notitlepage] in the book options. Without it \maketitle inserts a titlepage environment too, which will reset the numbering again and this makes it arkward to find the correct place to reset the numbering. –  Ulrike Fischer Aug 25 '12 at 10:06
The problem with setting a concrete value is if I change something before the titlpage I migh forget to adjust that manually. I have changed the definition of titlepage now --> have put that in an answer (see below) since not enough space in comment. What's your opinion on that solution? –  lpdbw Aug 25 '12 at 10:16

The titlepage environment restarts the page counter at 1. Therefore you have two pages with page number I, the very first page and the first title page.

\pagenumbering{Alph} would work, but the previous page is not yet finished and therefore also the previous page would be A. This is fixed by starting a new page explicitly:

\clearpage
\pagenumbering{Alph}


Also the method with disabled page anchors work, page anchors can be disabled for some pages only, e.g.:

\hypersetup{pageanchor=false}
\frontmatter
....
\begin{titlepage}...\end{titlepage}
\hypersetup{pageanchor=true}

-
Not sure whether there is a misunderstanding: How does your answer solve the problem of page numbering starting anew with the titlepage? I would like the preface (see edited question) to have page number V ... –  lpdbw Aug 25 '12 at 9:21
@lpdbw: You edited your question quite a lot. Heiko is answering to the first version. –  Ulrike Fischer Aug 25 '12 at 9:43
Oh, sorry. Thought his answer was already referring to the edited question. –  lpdbw Aug 25 '12 at 9:47

One possible solution: Remove the lines with \setcounter{page} in the titlepage definition.

\documentclass{book}

\usepackage{lipsum}
\usepackage{hyperref}
\usepackage{bookmark}

\makeatletter
\if@compatibility
\renewenvironment{titlepage}
{%
\cleardoublepage
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse\newpage
\fi
\thispagestyle{empty}%
%\setcounter{page}\z@
}%
{\if@restonecol\twocolumn \else \newpage \fi
}
\else
\renewenvironment{titlepage}
{%
\cleardoublepage
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse\newpage
\fi
\thispagestyle{empty}%
%\setcounter{page}\@ne
}%
{\if@restonecol\twocolumn \else \newpage \fi
\if@twoside\else
% \setcounter{page}\@ne
\fi
}
\fi
\makeatother

\title{Lipsum}
\author{lpdbw}

\begin{document}

\frontmatter
\pagenumbering{Roman}

\lipsum

\begin{titlepage}
\maketitle
\thispagestyle{empty}
\end{titlepage}

\chapter*{Preface}

\mainmatter

\chapter{Introduction}
\lipsum

\end{document}


Alternatively, one can just do it without titlepage:

\documentclass[notitlepage]{book}

\usepackage{lipsum}
\usepackage{emptypage}
\usepackage{hyperref}
\usepackage{bookmark}

\title{Lipsum}
\author{lpdbw}

\begin{document}

\frontmatter
\pagenumbering{Roman}

\lipsum

\cleardoublepage

\maketitle
\thispagestyle{empty}

\cleardoublepage

\chapter*{Preface}

\mainmatter

\chapter{Introduction}
\lipsum

\end{document}

-
This can be done by xpatch easier. –  Marco Daniel Aug 25 '12 at 10:31