6

I have a problem with the number of the page that appears on the first page of ToC (I don't want it, of course), but only when I have at last two page of ToC. When ToC takes only one page, footer and header is clear, but when I extend it on another page the page number appears in the footer. Here is my MWE:

\documentclass{book}

\usepackage[
centering,
%showframe,
top=14mm,
headheight=11pt,
headsep=12pt,
includeheadfoot,
papersize={148mm,210mm},
text={90mm,150mm},
dvips=false,
pdftex=false,
vtex=false
]{geometry}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{} % clear all header fields 
\newcommand{\TheAuthor}{} 
\newcommand{\Author}[1]{\renewcommand{\TheAuthor}{#1}} 
\rhead{\small\TheAuthor}
\newcommand{\TheTitle}{} 
\newcommand{\Title}[1]{\renewcommand{\TheTitle}{#1}} 
\lhead{\small\scshape\TheTitle}
\fancyfoot{} % clear all footer fields 
\fancyhead[RO,LE]{\thepage} 

\usepackage{titlesec}
\titleformat{\chapter}{\normalfont\Large\scshape}{\thechapter}{1em}{}[\vspace{6pt}]

\usepackage{lipsum}
\renewcommand{\contentsname}{whatever}

%-------------------------------------------------------------------------

\begin{document}


\newpage
\thispagestyle{empty}
\tableofcontents
\thispagestyle{empty}
\newpage
\thispagestyle{empty}


\setcounter{footnote} {0}\chapter*{{\fontsize{11}{14}\selectfont \normalfont{Author1} \\
{\scshape\Large Title}}}
\addcontentsline{toc}{chapter}{\normalsize\normalfont{Author1} \\ \normalfont\scshape{Title}}
\thispagestyle{empty}
\Author{Author1}
\Title{Title}
\lipsum
\newpage
\thispagestyle{empty}

\end{document}

Please, just copy this section a few times

 \setcounter{footnote} {0}\chapter*{{\fontsize{11}{14}\selectfont  \normalfont{Author1} \\
 {\scshape\Large Title}}}
 \addcontentsline{toc}{chapter}{\normalsize\normalfont{Author1} \\  \normalfont\scshape{Title}}
 \thispagestyle{empty}
 \Author{Author1}
 \Title{Title}
 \lipsum
 \newpage
 \thispagestyle{empty}
3
  • 1
    Your 'MWE' doesn't compile with pdflatex here.
    – raphink
    Sep 15, 2011 at 9:21
  • @Raphink, you're right. Now it seems to be ok.
    – kotsport
    Sep 15, 2011 at 9:30
  • i changed the phrasing of the question. ams has received questions on how to remove the page numbers from entries in the toc, and that's how i read the original version. (for details of the "alternate" meaning, see the ams author faq. this will give a long list; the relevant question will be outlined in red, 'way down the page.) Sep 15, 2011 at 13:16

1 Answer 1

10

Instead of

\pagestyle{fancy}
...<settings>...
\fancyhead[RO,LE]{\thepage} 

I would define a new page style: change those lines into

\newcommand{\TheAuthor}{}
\newcommand{\Author}[1]{\renewcommand{\TheAuthor}{#1}}
\newcommand{\TheTitle}{}
\newcommand{\Title}[1]{\renewcommand{\TheTitle}{#1}}

\usepackage{fancyhdr}
\fancypagestyle{fancymain}{%
  \fancyhead{}%
  \rhead{\small\TheAuthor}%
  \lhead{\small\scshape\TheTitle}%
  \fancyfoot{}%
  \fancyhead[RO,LE]{\thepage}}

Then the start of your document can be

\begin{document}
\pagestyle{empty}
\tableofcontents

\cleardoublepage

\pagestyle{fancymain}

<all the rest>

Less code. I advise you also to reconsider writing for each chapter all that complicated code and define a personal command for it.

However this still leaves the page number in the first page of the ToC. Here's a hack: redefine temporarily the page style. So, instead of the simple \tableofcontents command, write

\begingroup
  \makeatletter \let\ps@plain\ps@empty \makeatother
  \tableofcontents
\endgroup

There's another way to solve the problem, if, as it seems, you don't want the page number also at chapter beginning.

After \usepackage{fancyhdr} put the two lines

\fancypagestyle{plain}{\fancyhf{}%
  \renewcommand{\headrulewidth}{0pt}}

Then the simple \tableofcontents will do (no magic code involving @ characters).

4
  • Thanks! It works great, even though I don't understand what exactly happened. I mean the last code (I'm still like a monkey in LaTeX... copy, paste, copy, paste). Nevermind. Thanks!
    – kotsport
    Sep 15, 2011 at 10:18
  • And what do you mean by "reconsider writing for each chapter all that complicated code and define a personal command for it"?
    – kotsport
    Sep 15, 2011 at 10:21
  • @kotsport The last code is just a trick for doing the business at hand. I'll add another solution, which may be simpler for you.
    – egreg
    Sep 15, 2011 at 10:22
  • Thank you again. It also works great and is easier to understand (for me). :)
    – kotsport
    Sep 15, 2011 at 10:40

You must log in to answer this question.

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