LaTeX forum ⇒ Page LayoutTwo 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

Postby TexTux » Sat Jul 15, 2017 1:55 pm

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:

User avatar
Johannes_B
Site Moderator
Posts: 3584
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sat Jul 15, 2017 2:33 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

Postby TexTux » Sat Jul 15, 2017 2:46 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.

User avatar
Johannes_B
Site Moderator
Posts: 3584
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sun Jul 16, 2017 7:59 am

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.

  1. \documentclass[twoside]{article}
  2. \usepackage{blindtext}
  3. \usepackage{showframe}
  4. \usepackage{scrextend}
  5. \KOMAoption{cleardoublepage}{current}
  6. \usepackage[automark,markcase=ignoreupper]{scrlayer-scrpage}
  7. \ifoot{Normal page}
  8. \newpairofpagestyles{sheet}{}
  9. \newcounter{savepage}
  10. \newenvironment{sheet}{%
  11. \setcounter{savepage}{\value{page}}
  12. \cleardoublepage
  13. \pagestyle{sheet}\pagenumbering{arabic}
  14. \ofoot*{\pagemark}
  15. \ihead{This is a Sheet}
  16. \ohead{\leftmark}
  17. \setcounter{secnumdepth}{-1}
  18. }{
  19. \KOMAoption{cleardoublepage}{empty}
  20. \cleardoublepage\setcounter{page}{\value{savepage}}
  21. \refstepcounter{page}
  22. \ifodd\value{page}\else\refstepcounter{page}\fi
  23. \setcounter{secnumdepth}{1}
  24. }
  25. \begin{document}
  26. \section{Wombat}
  27. \blindtext[8]
  28. \begin{sheet}
  29. \section{Pendulum}
  30. \blindtext[8]
  31. \end{sheet}
  32. \section{Capybara}
  33. \blindtext
  34. \section{Mara}
  35. \begin{sheet}
  36. \section{Waves}
  37. \blindtext
  38. \end{sheet}
  39. \section{Koala}
  40. \cleardoublepage t
  41. \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

Postby TexTux » Mon Jul 17, 2017 7:53 am

Thanks a lot. Works perfectly! Thank you!!


Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 3 guests