## LaTeX forum ⇒ Page Layout ⇒ Two different page numbers in one document Topic is solved

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
TexTux
Posts: 3
Joined: Sat Jul 15, 2017 1:34 pm

### Two different page numbers in one document

Hello everybody,

I've searched two hours now for a solution on the net, but all that was coming up so far, was the shift of page numbering.

I try to integrate worksheets into another latex document which results in a book mixed of information and sheets. Now I want the pages in the book numbered regularly for what I'm using the usual page numbering.

The worksheets however can consist of multiple pages and should therefor have an own page numbering which leaves the page numbering of the surrounding book untouched. Which page number is shown on the sheet shall be changed by using page styles.

So for example:
Chapter 1 - Text five pages long (page number 1-5)
Sheet 1 - 2 pages long (page number 1-2)
Sheet 2 - 4 pages long (page number 1-4)
Chapter 2 - Text 12 pages long (5 pages text and 6 pages sheets before, so these pages should be numbered 12-24)

What I did so far is that I created a new environment for the worksheets and reset the page number whenever this new environment is used:
\newenvironment{SHEET}{\setcounter{page}{1}\newpage\pagestyle{SHEETpagestyle}}{\newpage\pagestyle{fancy}}

Result:
Chapter 1 - Text five pages long (page number 1-5)
Sheet 1 - 2 pages long (page number 1-2)
Sheet 2 - 4 pages long (page number 1-4)
Chapter 2 - Text 12 pages long (1-12 instead 12-24)

All I should have to do (naively thinking) is replacing the page counter within this SHEET-environment by an extra defined page counter which works exactly like the other, like:
\newenvironment{SHEET}{\setcounter{sheetpage}{1}\newpage\pagestyle{SHEETpagestyle}}{\newpage\pagestyle{fancy}}

Is that possible? If yes, how can I define the sheetpage counter which increases on every new page and if not, how can I achieve this goal with another solution?
Last edited by TexTux on Sat Jul 15, 2017 4:18 pm, edited 1 time in total.

Tags:

Johannes_B
Site Moderator
Posts: 3492
Joined: Thu Nov 01, 2012 4:08 pm
Do really want to do this? This will be highly confusing to your readers. If i am counting correctly, wouldn't the second chapter start on page twelve, instead of eleven?

I would use a different scheme, counting the chapter pages continously and having each sheet numbered with 1-1 to 1-n for the first sheet and 2-1 to 2-n for the second sheet (and so on for others). All you have to do is to store the number of the last chapter page and reset it at the start of the next non-sheet page (make a command for it). You will need another new counter for the sheet number. This is also more clear when crossreferencing.

By the way, if you realy want to fiddle with page numbers, keep in mind that LaTeX treats every odd page as a right hand page. So with every change of pagenumbering, you need a \cleardoubleoage.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

TexTux
Posts: 3
Joined: Sat Jul 15, 2017 1:34 pm
Yes I really want to do it that exact way: The sheets are serving as copy master for school students so they should not contain anything other than their own page number, because it would confuse them. They don't know anything about the chapters when receiving the sheets and usually not all sheets will be handed out, chapters may be taught in different order ...

And you have counted correctly, sorry for that mistake!

Your solution should work as well to achieve what I want. I need to store the old page number, restart it at one, and after ending the environment I need to reset it and add the actual sheet-page number.

Unfortunately I don't know how to make a command like that...

You have a point there with left and right pages which makes the additional page counter "SHEETpage" like suggested at first for the sheets only a better plan as it does not change anything for left and right pages because the counter "page" remains untouched. And this would have the advantage that in the table of contents these pages have still the continuous numbering and not appearing 1 in the middle of nowhere all the time.

So I still think the easiest way would be to define a counter for the sheet pages as mentioned above.

Johannes_B
Site Moderator
Posts: 3492
Joined: Thu Nov 01, 2012 4:08 pm
What i gone for now is the following, using package scrlayer-scrpage for the page styles (i find it a bit more attractive than fancyhdr, but this is a matter of taste).
I am not sure what you really want, but thinking about student worksheets, this might be a suitable solution.

The code below ensures that a possible blank left page of a sheet does have an empty page style, so the page will be completely empty. It also ensures that resuming with non-sheet-stuff always happens on a right hand page.

You can click on Open in Overleaf to directly test the presented code.

\documentclass[twoside]{article}\usepackage{blindtext}\usepackage{showframe}\usepackage{scrextend}\KOMAoption{cleardoublepage}{current}\usepackage[automark,markcase=ignoreupper]{scrlayer-scrpage}\ifoot{Normal page}\newpairofpagestyles{sheet}{}\newcounter{savepage}\newenvironment{sheet}{%	\setcounter{savepage}{\value{page}}	\cleardoublepage	\pagestyle{sheet}\pagenumbering{arabic}	\ofoot*{\pagemark}	\ihead{This is a Sheet}	\ohead{\leftmark}	\setcounter{secnumdepth}{-1}}{	\KOMAoption{cleardoublepage}{empty}	\cleardoublepage\setcounter{page}{\value{savepage}}	\refstepcounter{page}	\ifodd\value{page}\else\refstepcounter{page}\fi	\setcounter{secnumdepth}{1}}\begin{document}\section{Wombat}\blindtext[8]\begin{sheet}	\section{Pendulum}	\blindtext[8]\end{sheet}\section{Capybara}\blindtext\section{Mara}\begin{sheet}	\section{Waves}	\blindtext\end{sheet}\section{Koala}\cleardoublepage t\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

TexTux
Posts: 3
Joined: Sat Jul 15, 2017 1:34 pm
Thanks a lot. Works perfectly! Thank you!!