Premise: I'm new with fancyhdr. I defined the following fancy style:

\lhead{}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\renewcommand{\footrulewidth}{0.4pt}


which correctly draw the chapter number and name, top line, the bottom line, and the page number, in all the page except the first of each chapter.

So, I redefined the plain style in the following way:

\fancypagestyle{plain}{
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\renewcommand{\footrulewidth}{0.4pt}}


which correctly draw the top line, the bottom line, and the page number in the first page of each chapter (note: the plain style miss the chapter number and name of the fancy style)

Now, I have a problem with the table of contents. The first page of the toc has the plain style (without the chapter number and name), but the following pages have the fancy style (with chapter number and name). How can I apply the plain style to ALL the page of the toc?

• Welcome to TeX.SX! What document class are you using? – egreg Mar 26 '14 at 16:42

Since you're using the book class, I presume that everything in the front matter is intended to be under the plain pagestyle:

\documentclass[a4paper,oneside]{book}
\usepackage{fancyhdr}
\usepackage{etoolbox}
\usepackage{lipsum} % just for the example

\pagestyle{fancy}
\fancypagestyle{main}{%
\fancyhf{}%
\fancyfoot[C]{\thepage}%
\renewcommand{\footrulewidth}{0.4pt}%
}
\fancypagestyle{plain}{%
\fancyhf{}%
\fancyfoot[C]{\thepage}%
\renewcommand{\footrulewidth}{0.4pt}%
}

\appto\frontmatter{\pagestyle{plain}}
\appto\mainmatter{\pagestyle{main}}

\begin{document}

\frontmatter
\tableofcontents

\mainmatter

%%% fill with some mock text
\def\testsec{\section{B}\lipsum}
\def\test{\chapter{A}
\testsec
\testsec
\testsec
\testsec
\testsec
\testsec
\testsec
\testsec
\testsec
\testsec
}
\test
\test
\test
\test
\test
\test
\test
\test
\end{document}


However, I'd recommend against the footrule.

Try this in the preamble of your real document

\usepackage{etoc}
\renewcommand{\etocaftertitlehook}{\pagestyle{plain}}
\renewcommand{\etocaftertochook}{\thispagestyle{plain}}


(edit replaces \pagestyle with \thispagestyle in the line above)

MWE:

\documentclass{book}

\usepackage{fancyhdr}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\renewcommand{\footrulewidth}{0.4pt}
\fancypagestyle{plain}{
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\renewcommand{\footrulewidth}{0.4pt}}

\usepackage{etoc}
\renewcommand{\etocaftertitlehook}{\pagestyle{plain}}
\renewcommand{\etocaftertochook}{\thispagestyle{plain}}

\begin{document}

\tableofcontents

\chapter{ONE}

\section {A}

\chapter{TW0}

\section {B}

\newcount\cnta
\loop
\chapter{\the\cnta}

\ifnum\cnta<50

• @Bernard this is an artefact due to the succession of almost empty chapters. Each \chapter modifies the page style. By the way, I should have intialized the \ctna counter at 3. – user4686 Mar 26 '14 at 21:52
• I have this error: \etocaftertochook undefined on this line: \renewcommand{\etocaftertochook}{\thispagestyle{plain}} – Andrea Mar 27 '14 at 8:39
• @Andrea \etocaftertochook is available since release 1.07g of 2013/10/13. Perhaps you have TexLive2013 from a year ago, without subsequent updates. In that case just insert \thispagestyle{plain} immediately after \tableofcontents, or update your installation. – user4686 Mar 27 '14 at 11:16