0

I am just learning LaTeX, so this might be a very obvious question, but unfortunetely I haven't found any answer on this forum, or anywhere else.

I have a document (book) with multiple parts and chapters, but when a new part starts the page numbering goes back to 1. Is there an option to disable this automatic reset?

I am looking forward to your respons!

Kind regards

enter image description here


I think I found the problem! I created a few days ago a function to create new parts without the page numbering on the whitepage of the new part. So it turns the page numbering off creates the page and then turns it on again. But it probably turns it on back to 1.

Is there an easy way to store the page number before it is turned off? Or is there in general an easier way to do this?

\newcommand{\createpart}[2]
  {
  \pagenumbering{gobble}
  \ifthenelse{\equal{#2}{with}}
    {\part{#1}}
    {\part*{#1}\addcontentsline{toc}{part}{#1}}
  \pagenumbering{arabic}
  }
  • 2
    Which class are you using? book class does not reset page numbers after part. – Sigur Feb 12 '18 at 15:46
  • 1
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – samcarter is at topanswers.xyz Feb 12 '18 at 15:48
  • 1
    (1) welcome, (2) this is not normal behaviour so please post a full minimal example giving this kind of out put. – daleif Feb 12 '18 at 15:48
  • 2
    \pagenumbering always resets the page number to 1 – user31729 Feb 12 '18 at 21:39
4

Don't fiddle with page numbers, just use \pagestyle{empty} (or \thispagestyle{empty}) for the \part page. This has worked for me:

\part[Title]{Title\thispagestyle{empty}}

which puts Title in the ToC and Title plus \thispagestyle{empty} in the document body. However, if you use the memoir class just put:

\aliaspagestyle{part}{empty}

in your preamble (without fiddling with each \part{...})

  • Well, either me or you seem to have misunderstood the question -- isn't the question about preventing page number reset with every \part? If that is true, I don't see how the empty pagestyle comes in... Please correct me, if I am wrong -- I will delete this comment then – user31729 Feb 18 '18 at 9:15
  • 2
    @ChristianHupfer I don't know of any class where \part resets the page numbering. The asker said that a new definition of \part was used to turn off page number printing on \part pages which resulted in page number resetting. I responded to what I thought was the underlying question of how to turn off the printing of the page number. If you think I'm right please upvote my answer. – Peter Wilson Feb 19 '18 at 19:55
  • In some sense we're both right ;-) – user31729 Feb 19 '18 at 20:06
  • @ChristianHupfer The question was not the clearest that I have seen. I have expanded my answer and thanks for the vote. – Peter Wilson Feb 19 '18 at 20:45
-3

I found an answer!

With the \newcounter command you can save a variable temporarily. So the code below saves the page nubmer temporarily and than sets the pagenumber back when the arabic pagenumbering is reinstated. :)

\newcommand{\createpart}[2]
  {
  \newcounter{tempPageNumber}
  \setcounter{tempPageNumber}{\thepage}
  \pagenumbering{gobble}
  \ifthenelse{\equal{#2}{with}}
    {\part{#1}}
    {\part*{#1}\addcontentsline{toc}{part}{#1}}
  \pagenumbering{arabic}
  \setcounter{page}{\value{tempPageNumber}}
  }
  • 1
    Again, this is useless to anyone else without knowing what document class you are using. – John Kormylo Feb 12 '18 at 17:20
  • 2
    Why create a new counter each time this macro is executed? Again information about the class would help a lot. For example in the memoir class, removing the page number from all part pages is a one liner in the preamble. – daleif Feb 12 '18 at 17:32
  • 1
    Also to second @daleif's comment: You can't use your \createpart macro twice or even more, since \newcounter is a macro that defines counters globally -- it will complain about tempPageNumber being defined already. Also, don't rely on \thepage printing pure numbers only, so \setcounter{tempPageNumber}{\thepage} may fail miserably – user31729 Feb 12 '18 at 19:48
  • 1
    Each time you are using \pagnumbering the page counter is reset to one. Adding an auxiliary counter to store a value and revode it later is kind of pointless since resetting the pagecounter is unwanted and unneeded in the first place. – Johannes_B Feb 24 '18 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.