145

I have two sections before the table of contents.

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\thispagestyle{empty}
\section*{First random title} \lipsum[1]
\section*{Second random title} \lipsum[2]
\clearpage
\tableofcontents
\section{First section} \lipsum[3]
\section{Second section} \lipsum[4]
\section{Last section} Wombat \lipsum[5]
\end{document}

The problem is, that LaTeX starts the page numbering on the first page and I don't want that. I want the page numbering to start after the table of contents. How can I do this?

Johannes_B
  • 24,235
  • 10
  • 93
  • 248
Chris
  • 4,965
  • 8
  • 22
  • 19

1 Answers1

150

\pagenumbering can be helpful in removing page numbers and resetting it, at the same time. The following minimal example, using the article document class, removes the page numbers until the ToC, and then starts it again at 1 (set using \arabic):

enter image description here

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\begin{document}
\pagenumbering{gobble}% Remove page numbers (and reset to 1)
\clearpage
\thispagestyle{empty}
\section*{First random title} \lipsum[1]
\section*{Second random title} \lipsum[2]
\clearpage
\pagenumbering{arabic}% Arabic page numbers (and reset to 1)
\tableofcontents
\section{First section} \lipsum[3]
\section{Second section} \lipsum[4]
\section{Last section} \lipsum[5]
\end{document}

\pagenumbering{gobble} sets the "page number printing macro" to \@gobble, which eats its argument/contents. \pagenumbering{arabic} resets this to \arabic{page}.

The principle holds for other (standard) document classes as well.

Andrew Swann
  • 95,762
Werner
  • 603,163
  • 11
    This however can cause problem when hyperref is used. – egreg May 04 '12 at 08:41
  • There is one problem left. Between the last section and the table of contents, I get one blank page with a horizontal bar at the top. The horizontal bar comes from fancyhdr. How can I clear also fancyhdr styles before the table of contents? See: http://i49.tinypic.com/23mvg3t.jpg – Chris May 05 '12 at 14:53
  • @Chris: Use \renewcommand{\headrulewidth}{0pt} to remove the header rule, and \renewcommand{\headrulewidth}{.4pt} to re-insert it. If this doesn't solve your problem completely, please update your original post with a complete, minimal example. – Werner Jun 26 '12 at 01:10
  • 3
    @egreg: So how can this be done if the hyperref package is used? I'm using that package and I'm getting the warning destination with the same identifier (name{page.}) has been already used, duplicate ignored<to be read again>... – StrawberryFieldsForever Apr 26 '13 at 13:40
  • 8
    @StrawberryFieldsForever Use \pagenumbering{Alph}, for instance, and \pagestyle{empty} for the duration. – egreg Apr 26 '13 at 13:44
  • @egreg: I'm already using \thispagestyle{fancy} to enable the functionality in the fancyhdr package, so I guess using \pagestyle{empty} as well would be a bad idea? – StrawberryFieldsForever Apr 26 '13 at 21:15
  • @StrawberryFieldsForever Please make a followup question – egreg Apr 26 '13 at 21:27
  • @egreg: I solved it, thanks. I figured \pagestyle{empty} had to be used just in order not to display the page number (which is still actually there when using \pagenumbering{Alph}) — this is effectively achieved when using \thispagestyle{fancy}. However, I found that the titlepage environment automatically resets the page number when it ends, which leads to a collision in the page number which in turn generates a warning when using the hyperref package. So in my case the solution was to not use the titlepage environment (In fact, I don't know why I would actually need it). – StrawberryFieldsForever Apr 28 '13 at 11:17
  • I also found that the abstract-environment reset the page number, so I had to redefine it not to (see this answer). – StrawberryFieldsForever Apr 30 '13 at 15:48
  • The original solution in the post works perfectly fine for me, using hyperref... – Noldorin Jul 25 '13 at 21:17
  • The Adobe reader will still think page 1 is actual page 1. – Ma Ming Jun 03 '14 at 22:55
  • \thispagestyle{empty} is necessary and may be used without gobble. – mcp Sep 08 '22 at 19:24