# Calculate the page number

I'm writing an article where I start the "formal" part (TOC, etc.) with roman page numbering. For the main text part I switch to arabic numbers, starting from zero. No issue so far. Now, at the end of the document, I have a few "formal" sections left, resuming the roman numbering from before. Right now I do that manually with \setcounter{page}{5}. I thought there might be a way to do that with a variable like \newcommand{\x}{\thepage} on the last page before I switch to arabic page numbers, and then later use \setcounter{page}{\x}, but that gives me the following error: Missing number, treated as zero. \setcounter{page}{\x+1}.

Does anyone have an approach to that? Is that even possible?

Cheers

• Have you tried \setcounter{page}{\numexpr\value{\x}+1\relax}?
– Mico
Jan 23 '20 at 21:41
• It is possible but don't do it. Such a numbering system is nonsense. How should a reader know where page v or ix is? Who ever invented this system (and it is not very old) has obviously no idea idea what page numbers are for. Jan 23 '20 at 21:42
• @Mico Thanks, just tried your example, still doesn't work... Jan 23 '20 at 21:45
– Mico
Jan 23 '20 at 21:47
• Well I simply rejected jobs asking me to implement this. Jan 23 '20 at 21:51

This shows in the terminal

[1] [2] [1] [2] [3] [3] [4]


reflecting roman 1 2, arabic 1,2,3, roman 3,4

\documentclass[a5paper]{article}

\newcounter{savepage}

\begin{document}

\pagenumbering{roman}

zzzz \newpage zzz

\clearpage
\setcounter{savepage}{\value{page}}

\pagenumbering{arabic}

zzzz \newpage zzz

zzzz \newpage zzz

\clearpage

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

zzzz \newpage zzz

\end{document}

• This seems to be a very confusing numbering system, it would be better to start again from one in the end matter and use Roman , I II,.. or alphabetic A,B, or prefix A1,A2, etc... Jan 23 '20 at 21:49
• It is madness -- and I suspect invented in Germany somewhere. The last two years it is wandering like a disease through german tex groups and it seems not to be possible to get rid of it again. If you tell people to drop it, they simply say "but it is required". Grr Jan 23 '20 at 22:04
• given the geographic location it is natural that: I blame @UlrikeFischer Jan 23 '20 at 22:10
• You're right, I'm based in Germany, and this is a University requirement, nothing I can just "reject". So the answers were really helpful with my problem, in contrary to comments telling me I shouldn't do it! Feb 7 '20 at 2:10

This gives the expected result: three blank pages numbered with roman numbers, then three pages numbered with arabic numbers, and then a single blank page numbered "iv".

\documentclass{article}
\newcounter{x}
\newcommand{\blankpage}{\null\newpage}
\begin{document}
\pagenumbering{roman}
\blankpage\blankpage\blankpage
\setcounter{x}{\value{page}}
\pagenumbering{arabic}
\blankpage\blankpage\blankpage
\pagenumbering{roman}
\setcounter{page}{\value{x}}
\blankpage
\end{document}


Here's a screenshot of the bottom of the pages.

• You are very nice user. Best regards. Can you put, please, if possible, a screenshot? Jan 23 '20 at 22:13
• Thanks! Yes, I usually like to add screenshots, but I was not sure at first. I think what I added should show the essential. Jan 23 '20 at 23:21