# Continuing page number in LaTeX

I want to continue the roman numbering of the front matter of my document after the main matter is finished. The following, unfortunately, does not work. The counter start over with 1.

\pagenumbering{roman}
...

\setcounter{savepage}{\number\value{page}}
\newpage
\pagenumbering{arabic}

\section{Introduction}
\lipsum{}

\newpage
\setcounter{page}{\number\value{savepage}}
\pagenumbering{roman}

\begin{appendix}
\section*{Appendix}

\end{appendix}


## migrated from stackoverflow.comFeb 14 '17 at 20:44

This question came from our site for professional and enthusiast programmers.

• BTW, \setcounter{page}{\number\value{savepage}} can be shortened to \setcounter{page}{\value{savepage}}. \value addresses the count register of the specified counter and it can directly be used in \setcounter. – Heiko Oberdiek Feb 14 '17 at 21:21
• BTW: appendix is no environment, so \appendix, not \begin{appendix}...\end{appendix}. If you use the appendix package, then it's \begin{appendices}...\end{appendices}. – user31729 Feb 14 '17 at 21:46

\pagenumbering does the following two things (from latex.ltx):

\def\pagenumbering#1{%
\global\c@page \@ne
\gdef\thepage{\csname @#1\endcsname \c@page}}


• The page number is set to one (\global\c@page \@ne)
• The page number representation is changed to use the argument (\gdef\thepage{\csname @#1\endcsname \c@page})

Since it's resetting the page number to one, your saving and restoring of the page number doesn't stick. So, instead, use the following order of coding:

\pagenumbering{roman}
\setcounter{page}{\value{savepage}}


Note that this will make the first page within the appendix be equivalent to the last page in your front matter. If you want it to start one page further, use

\setcounter{page}{\numexpr\value{savepage}+1}

• I'd prefer \stepcounter{savepage} after the \setcounter in the front matter. – egreg Feb 14 '17 at 21:55

A little bit more complicate than Werner's solution, but with the possibility of storing whole 'counter' trees.

Use the package xassoccnt, define a backup counter group, say pagebackup, populate it with the page counter, store the state into some id (say, roman) and restore it later on, after changing the counter output to roman again with \pagenumbering.

In the example of usage below, the first five pages are numbered with roman figures and the appendix numbering continues with vi, as requested.

I agree, that this is 'too' much for such one occasion, but good to know for other issues.

\documentclass{article}

\usepackage{xassoccnt}

\DeclareBackupCountersGroupName{pagebackup}
\AssignBackupCounters[name=pagebackup]{page}

\usepackage{blindtext}
\begin{document}

\pagenumbering{roman}

\blindtext[20]

\clearpage
\BackupCounterGroup[backup-id=roman]{pagebackup}
\pagenumbering{arabic}

\section{Introduction}
\blindtext[10]

\clearpage
\pagenumbering{roman}
\RestoreBackupCounterGroup[backup-id=roman]{pagebackup}

\appendix
\section*{Appendix}
\blindtext[50]

\end{document}


• Thanks to all of you! @Werner, switching lines worked perfectly! – Tobi1990 Feb 16 '17 at 17:58
• @Tobi1990: I think your line should be under Werner's post, not mine ;-) – user31729 Feb 19 '17 at 9:52