2

I am using packages fancyhdrand fancyto customize header and footer.

.....
\usepackage{fancyhdr} 
\pagestyle{fancy}
\lhead{Team no.}
\rhead{Problem no.}
\cfoot{Page \thepage}
\renewcommand{\headrulewidth}{0pt}
\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
3

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
  \lhead{Team no.}
  \rhead{Problem no.}
  \renewcommand{\headrulewidth}{0pt}
  \renewcommand{\footrulewidth}{0pt}
}
\fancypagestyle{foot}{%
  \fancyhf{}% clear all header and footer fields
  \lhead{Team no.}
  \rhead{Problem no.}
  \cfoot{Page \thepage}
  \renewcommand{\headrulewidth}{0pt}
  \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
0

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}
\setlength{\headheight}{14.5pt}% <- suggested by fancyhdr
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancyplain}

\fancyhf{}
\fancyhead[L]{Team no.}
\fancyhead[R]{Problem no.}
\fancyfoot[C]{\fancyplain{}{Page \thepage\ of \pageref{LastPage}}}% no pagenumber on plain pages
\renewcommand{\headrulewidth}{0pt}

\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:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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