h1

Get rid of page number on 1st page of ToC in LaTeX!

February 28, 2008

LaTeX, or more generally TeX, is undoubtly the best typesetting tool available, and what’s more, it’s for free (for Windows users – check out MiKTeX!). Yet, there are few things that should work in a certain “obvious” way, yet they don’t (fortunately, there’s very few of them).

One of them is quite a surprising thing – pagestyle{empty} command does not affect first page of the table of contents. Yet, all the other pages of ToC it does! The same holds for list of figures and list of tables.
This is quite an annoyance, especially if you put ToC at the beginning of the document, and want to have all the pages, before the real contents starts, without the page numbering.

So, how to get rid of the page number on the first page of table of contents in LaTeX? You have to dig into the header and footer setting for this.

First thing is to use fancyhdr package – put usepackage{fancyhdr} command anywhere before the begin{document}.

Second, right before issuing the tableofcontents command, redefine the “plain page style” to an empty one, like this:

fancypagestyle{plain}
{
    fancyhead{}
    fancyfoot{}
}	% clear header and footer of plain page because of ToC

And after the ToC, just get back to the “classical” plain page style (this is important – even if you use your “fancy” page style, each page containing first page of chapter is “plain”, unless you redefine this behaviour), like this:

fancypagestyle{plain}
{
    fancyhead{}
    fancyfoot[C]{thepage}
}	% re-define plain page after the ToC

This block has to be “on a new page” – either after you issue newpage or cleardoublepage command, or after your first chapter{...} command.

11 comments

  1. Nice!

    Thanks for the info, i’ve been cracking my head open on this one…
    it’s also possible to do clear the plain pagestyle within an encapsulating environment, so you don’t have to redefine it afterwards

    {
    \fancypagestyle{plain}
    {
    \fancyhead{}
    \fancyfoot{}
    } % clear header and footer of plain page because of ToC
    \tableofcontents
    }


  2. You’re welcome, I’m glad I could be of any help!

    Thanks for the snippet, I found it later also, yet I was lazy to update the post to include it…

    Cheers!


  3. This also worked for me:

    \renewcommand\thepage{}
    \tableofcontents
    \newpage
    \renewcommand\thepage{\arabic{page}}

    Cheers


  4. Thanks for the tip!

    Now we have here 3 available solutions… Neat :)


  5. How do you get rid of page numbers without getting rid of the footer?


  6. I’m not quite sure what exactly you mean; you can blank-out just parts of footer and header, like this:

    \fancyfoot[C]{} % clears central part of footer

    Cheers


  7. This did the trick for me (without needing fancyhdr)

    \renewcommand\thepage{}
    \tableofcontents
    \listoffigures
    \newpage
    \renewcommand\thepage{\arabic{page}}


  8. Forgot to mention: I did this to reset the page counter before my first page of content.

    \setcounter{page}{1}


  9. This also seems to work:
    put \addtocontents{toc}{\protect\thispagestyle{empty}}
    before the \tableofcontents command.


  10. thanks for the tips! :)


  11. This works too:

    \makeatletter
    \let\ps@plain\ps@empty
    \makeatother

    :-)



Leave a Comment