16

I'm writing something with the article class, and I'd like to have the table of contents pages numbered with roman numerals, and in addition and most importantly: to have the arabic numbers reset after the table of contents.

That's because I'm printing the document as I write, and the TOC will be ready only after the work is finish (and I don't want to change the page numbers). As it's a somewhat big article (~70 pages maybe) should I switch to a book class instead?

8
  • It's not clear why the continuous page numbering should be a issue. If you need to refer to a precise page, there's the \pageref command.
    – egreg
    Commented May 29, 2012 at 14:54
  • @egreg Yeah, I should've said it in the question more clearly, anyways that's because the TOC will grow, and then all the page numbers would eventually be incremented and all my previously printed pages would contain the wrong numbers.
    – typk
    Commented May 29, 2012 at 15:00
  • 2
    Of course not! Compiling twice guarantees that the page numbers in the TOC are correct.
    – egreg
    Commented May 29, 2012 at 15:03
  • @egreg I know, but I'm not sure if I understand. Say that I have my TOC in page 1, and page 2 contains the article start. Then I write more 20 pages and print them. Ok, now when I write the next page, the TOC is big enough to take two pages. Then my article first page will be 3 instead of the old 2 (which is already printed) as well as the next 20 pages.
    – typk
    Commented May 29, 2012 at 15:10
  • LaTeX writes the .toc file during a compilation and at the next run it reads the "old" file. If the TOC grows one page, the page numbers will be incorrect after that run, but will be correct at the next. Just give it a try adding a number of mock sections.
    – egreg
    Commented May 29, 2012 at 15:13

1 Answer 1

15

This would be automatic in book class

\frontmatter
\tableofcontents
\mainmatter
...

In other classes you could just borrow the definitions from book.cls

\makeatletter

\newif\if@mainmatter \@mainmattertrue

\newcommand\frontmatter{%
    \cleardoublepage
  \@mainmatterfalse
  \pagenumbering{roman}}
\newcommand\mainmatter{%
    \cleardoublepage
  \@mainmattertrue
  \pagenumbering{arabic}}
\makeatother

as may be seen from the above definitions, essentially all you need if you don't want to define commands is \pagenumbering{roman} at the start and \pagenumbering{arabic} at the point that you want to switch.

2
  • Thanks Mr. Carlisle. I didn't realise that switching the page numbering style resets the count. Maybe each style uses a separate counter then.
    – typk
    Commented May 29, 2012 at 15:12
  • 3
    No it's the same counter, just \pagenumberimg is defined by \def\pagenumbering#1{% \global\c@page \@ne \gdef\thepage{\csname @#1\endcsname \c@page}} so it first resets the page counter to 1 then redefines \thepage to use the specified format roman or arabic or whatever. Commented May 29, 2012 at 15:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .