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

raf
  • 633

2 Answers2

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}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • This solution isn't affected by \pagestyle{fancy}, right?. – raf Oct 23 '18 at 07:23
  • 1
    \pagestyle{fancy} seems to have no effect whatsoever. – John Kormylo Oct 23 '18 at 13:28
  • Can you please tell me how to bookmark the 'table of contents' page so that I can return to the content page easily? (according to your given answer) @John Kormylo – raf Mar 28 '20 at 06:41
  • Bookmarking the TOC really has nothing to do with page style. If you are using hyperref, just use \hypertarget (possibly with \addtocontents or \contentsname) and \hyperlink. – John Kormylo Mar 28 '20 at 19:54
  • Ok. I am doing it in this way: https://tex.stackexchange.com/a/65547/114006 – raf Mar 30 '20 at 05:01
1

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

esdd
  • 85,675