Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
1  
Your 'MWE' doesn't compile with pdflatex here. –  ℝaphink Sep 15 '11 at 9:21
    
@Raphink, you're right. Now it seems to be ok. –  kotsport Sep 15 '11 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.) –  barbara beeton Sep 15 '11 at 13:16
add comment

1 Answer

up vote 8 down vote accepted

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).

share|improve this answer
    
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 '11 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 '11 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 '11 at 10:22
    
Thank you again. It also works great and is easier to understand (for me). :) –  kotsport Sep 15 '11 at 10:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.