2

I'm currently using \pagenumbering{gobble} because I don't want page numbers at the bottom of my pages. But I still want them to appear in the \tableofcontents.

What is a method of removing page numbers from the pages without removing them from \tableofcontents?

I can't use \pagestyle{empty} since I am using \pagestyle{fancy}.

user2763361
  • 435
  • 2
  • 11
  • WHat about using \pagestyle{empty}? – Guido Oct 18 '13 at 06:11
  • @Guido because my pagestyle is already fancy – user2763361 Oct 18 '13 at 06:14
  • 4
    What about something like \fancyfoot[C]{} in the definition of your fancy pagestyle... (assuming your page number is in the center? Cf. to the definition of pagestyles e.g. here http://tex.stackexchange.com/questions/24137/fancyhdr-headings-how-to-remove-the-number-of-the-section?rq=1 – Ronny Oct 18 '13 at 06:49

2 Answers2

2

I assume that your target is not to remove all bottom numbers in a document, but to remove those bottom numbers associated with the particular pages that are listed on the table of contents (with page numbers intact).

The \fancypagestyle{nopagenum}{...} command is used to define a new page style, and then issue the command \thispagestyle{nopagenum} right below those commands that will write contents to TOC.

To demonstrate, I write up a test.tex using typical fancy header setting

enter image description here

You will see that pages 3, 5, 7 and 9 are removed if the file is complied. (Sorry there are a total of 9 pages and I did not post them all to save space.)

Code:

\documentclass[]{book}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{} % clear all header fields
\fancyhead[LE]{\footnotesize{\scshape\nouppercase{\leftmark}}}
\fancyhead[RO]{\footnotesize{\scshape\nouppercase{\rightmark}}}
\fancyfoot{} % clear all footer fields
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{1 pt}
\renewcommand{\footrulewidth}{1 pt}
%
\fancypagestyle{nopagenum}{%         % This is what you need
\fancyfoot[C]{}                      % page number at center is assumed
}

\begin{document}

\tableofcontents

\chapter{Chapter1}
\thispagestyle{nopagenum}            % called to remove bottom page number
\lipsum[1-5]
\newpage
\section{Section 1.1}
\thispagestyle{nopagenum}            %
\lipsum[1]
\newpage
\lipsum[1]
\chapter{Chapter2}
\thispagestyle{nopagenum}            %
\lipsum[1]
\newpage
\lipsum[1]
\newpage
\lipsum[1]
\section{Section 2.1}
\thispagestyle{nopagenum}            %
\lipsum[1]
\end{document}
karlkoeller
  • 124,410
Jesse
  • 29,686
  • Well you could also just ommit the \thepage in line 9 instead of the nopagenum stuff :) – Ronny Oct 18 '13 at 14:31
  • @Ronny -- I did do that when I was attacking the problem. But that will disable the numbering of regular pages (i.e., those not on TOC). – Jesse Oct 18 '13 at 14:48
  • Well, the OP just states, he doesn't want “pagenumbers at the bottom of the page” (as I understand, no pagenumbers in foot) but his \gobble does of course also produce a TOC without pagenumbers (and just setting the foot to empty keeps numbers in TOC) - therefore - IMHO - just one pagestyle should be enough, that uses your line 14 :) – Ronny Oct 18 '13 at 15:12
  • Oh..OK, for that case, line 14 suffices. Thanks. – Jesse Oct 18 '13 at 15:54
1
\documentclass{article}
\makeatletter
\let\@oddfoot\@empty\let\@evenfoot\@empty
\makeatother
\begin{document}
\tableofcontents
\section{First}
This is a test
\clearpage
\section{Next}
This continues the test
\end{document}

Output


Ludovic C.
  • 8,888