I am writing a maths book for A level students using the class book, and I am completely new to LaTeX, so please bear with me if this is trivial. I have written a simplified version of my code down here. When I execute it, there is a blank page with the fancy header with the horizontal bar. How can make the header blank? I think the whole CONTENTS and then CONTENTS again thing looks rather silly.

\documentclass{book}
\usepackage{fancyhdr}
\title{First Year Pure Mathematics}
\author{Luke Collins and Sandro Grech}
\date{}
\fancypagestyle{front}{%
\fancyhf{}
\fancyfoot[C]{\thepage}
}
\fancypagestyle{main}{%
\fancyhf{}
\fancyfoot[C]{\thepage}
}
\fancypagestyle{plain}{%
\fancyhf{}
\fancyfoot[C]{\thepage}
}
\begin{document}
\pagenumbering{gobble}
\pagestyle{empty}
\maketitle
\pagestyle{front}
\frontmatter
\chapter{Preface}
text
\chapter{How to use this book}
text

\mainmatter
\tableofcontents
\pagestyle{main}
\chapter{Logical Foundation}
rest of book
\end{document}

• You can use \thispagestyle for specific page. in this case you can write \thispagestyle{empty} in the page that you want ... – juanuni May 25 '15 at 20:47
• Always use \cleardoublepage before changing \pagestyle (but \frontmatter and \mainmatter issue it). In my opinion the table of contents should be in the front matter, particularly if it uses the same page style as in the front matter. Also avoid \pagenumbering{gobble}, you'll regret it if you add hyperref; better removing the page number by applying a suitable page style. You may want to consider loading emptypage for making completely empty pages added by \cleardoublepage. – egreg May 25 '15 at 21:08
• I think this is basically a duplicate of the following: tex.stackexchange.com/questions/246505/… However, I'm not flagging as a duplicate because Werner's answer gives a lot of great information that the other thread doesn't. In other words, the question is a duplicate; but the answer adds a lot of value. – dgoodmaniii May 26 '15 at 3:02

This is actually due to an incorrect use of your timing in setting the \pagestyle.

Since the ToC is set under the front page style, and the main document should be processed under main, you should use

\chapter{Logical foundation}
\pagestyle{main}


rather than the other way around. That is, you chapter is first set (the heading; this actually includes a \cleardoublepage to start on an odd page under the book class), then you set the page style to be main.

In the hypothetical instance where you have a non-empty page style (header) as part of the ToC, you can issue the following to ensure a purely blank page (if it exists) at the end of the ToC:

\tableofcontents

\clearpage
\ifodd\value{page}\else
\thispagestyle{empty}
\fi


\clearpage makes sure you move to the next page where you then check whether you're on an odd/even page. If you're on an even page (the false clause when checking \ifodd\value{page}), then issue \thispagestyle{empty}.

The empty page style has no header or footer. Of course, you can create a new page style for such pages. The above is just an example of how to manage that.

This is works...

% REMOVE HEADER CONTENTS