# Problem with header, footer and page number

I am using packages fancyhdrand fancyto customize header and footer.

.....
\usepackage{fancyhdr}
\pagestyle{fancy}
\cfoot{Page \thepage}
\renewcommand{\footrulewidth}{0pt}

\begin{document}
\title{Problem Name}
\author{Team no. \\ Problem no.}
\maketitle
\pagenumbering{gobble}
\begin{abstract}
\end{abstract}
\newpage
\tableofcontents
\newpage
\pagenumbering{arabic}
\section{Introduction}
....


I wanna remove only the footer(here 'page number') from the 'table of contents' pages. Also, I like to use 'page number' in the format of "Page x of y". How can I do?
TIA

• All of the pages with the \tableofcontents should have its page number removed? – Werner Oct 22 '18 at 19:56
• You second question is answered here: How can I add "page # of ##" on my document? – Werner Oct 22 '18 at 19:56
• yes, @Werner . All of the pages with the \tableofcontents should have its page number removed. – raf Oct 22 '18 at 20:03
• What \documentclass are you using? – Werner Oct 22 '18 at 20:18
• \documentclass[a4paper,12pt]{article} – raf Oct 22 '18 at 20:21

For some reason I had trouble turning \pagestyle{fancy} off and on again. It was easier to create two new pagestyles instead.

\documentclass[a4paper,12pt]{article}
\usepackage{fancyhdr}

\fancypagestyle{nofoot}{%
\fancyhf{}% clear all header and footer fields
\renewcommand{\footrulewidth}{0pt}
}
\fancypagestyle{foot}{%
\fancyhf{}% clear all header and footer fields
\cfoot{Page \thepage}
\renewcommand{\footrulewidth}{0pt}
}
\usepackage{lipsum}

\begin{document}
\title{Problem Name}
\author{Team no. \\ Problem no.}
\maketitle
\pagenumbering{gobble}
\begin{abstract}
\end{abstract}
\newpage
\pagestyle{nofoot}
\tableofcontents
\newpage
\pagestyle{foot}
\pagenumbering{arabic}
\section{Introduction}
\lipsum[1-6]
\end{document}

• This solution isn't affected by \pagestyle{fancy}, right?. – raf Oct 23 '18 at 7:23
• \pagestyle{fancy} seems to have no effect whatsoever. – John Kormylo Oct 23 '18 at 13:28

Here is another suggestion using \pagestyle{fancyplain} after loading package fancyhdr. Then both pagestyles fancy and plain under control of fancyhdr and \fancyplain{settings for plain style}{settings for fancy style} can be used in the argument of \fancyhf, \fancyhead etc.

\documentclass[a4paper,12pt]{article}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancyplain}

\fancyhf{}
\fancyfoot[C]{\fancyplain{}{Page \thepage\ of \pageref{LastPage}}}% no pagenumber on plain pages

\usepackage{lipsum}% only for dummy text
\begin{document}
\pagestyle{plain}
\pagenumbering{roman}

\title{Problem Name}
\author{Team no. \\ Problem no.}
\maketitle
\thispagestyle{empty}
\begin{abstract}
\lipsum[1]
\end{abstract}

\clearpage
\tableofcontents
\clearpage
\pagestyle{fancy}
\pagenumbering{arabic}
\section{Introduction}
\lipsum[1-6]
\end{document}


Result: