Page Layoutfancyhdr | Page Numbers on empty Pages before Chapters

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
djlobina
Posts: 1
Joined: Thu Feb 09, 2012 8:14 pm

fancyhdr | Page Numbers on empty Pages before Chapters

Post by djlobina »

Hello, everyone.

I'm using the 'book' class to write a long manuscript, and I followed someone else's instructions in order to modify the headers and footers of this class. In particular, I didn't like the style of these headers, the fact that the page numbers are placed in a header instead than in a footer, and the silly habit of producing headers on an empty page before a new chapter.

The following code was suggested in some forum. It does a nice job with the headers and footers, and also with the page numbers, at least up to the mainmatter. That is, it doesn't include the page number on the empty page before the TOC or the preface, but it does for every section afterwards (namely, before the 'introduction', and before every new chapter). I'm not sure why it's doing that, but it sure is annoying me a great deal. I like this pagestyle, but I just want to get rid of those annoying page numbers on the empty pages. Can you help?

Below, I copy the specific piece of code aforementioned, and then the remainder of the preamble. Many thanks in advance.

Code: Select all

% Code for creating empty pages

% No headers on empty pages before new chapter

\makeatletter

\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else

    \hbox{}

    \thispagestyle{plain}

    \newpage

    \if@twocolumn\hbox{}\newpage\fi\fi\fi}

\makeatother \clearpage{\pagestyle{plain}\cleardoublepage}

% Define pagestyle

\pagestyle{fancy}

\fancyhf{}

\renewcommand{\chaptermark}[1]{\markboth{ \emph{#1}}{}}

\fancyhead[LO]{}

\fancyhead[RE]{\leftmark}

\fancyfoot[LE,RO]{\thepage}

Code: Select all

\documentclass[11pt,a4paper,leqno]{book}

\usepackage{mathptmx}
\usepackage[UKenglish]{babel}
\usepackage{apacite}
\usepackage[round]{natbib}

\usepackage{covington}
\usepackage{paralist}

\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{latexsym}
\usepackage{graphics}
\usepackage{epic,eepic}

\usepackage{appendix}

\usepackage{setspace}

\usepackage{fancyhdr}

\newcommand\bookepigraph[4]{
\vspace{1em}\hfill{}\begin{minipage}{#1}{\begin{spacing}{0.9}
\small\noindent\textit{#2}\end{spacing}
\vspace{1em}
\hfill{}{#3}\\
\vspace{-1em}\begin{flushright}{#4}\end{flushright}}\vspace{2em}
\end{minipage}}

% Code for creating empty pages
% No headers on empty pages before new chapter
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
    \hbox{}
    \thispagestyle{plain}
    \newpage
    \if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother \clearpage{\pagestyle{plain}\cleardoublepage}

% Define pagestyle
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\chaptermark}[1]{\markboth{ \emph{#1}}{}}
\fancyhead[LO]{}
\fancyhead[RE]{\leftmark}
\fancyfoot[LE,RO]{\thepage}

\title{}

\author{}

\date{}

\begin{document}

\maketitle

\renewcommand\thepage{}
\tableofcontents
\listoffigures

\frontmatter

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

fancyhdr | Page Numbers on empty Pages before Chapters

Post by localghost »

The modification is derived from the suggestion in Section 15 of the fancyhdr manual. And of course the sample code suggests the »empty« page style to get real empty pages without any page numbers.

Code: Select all

\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
  \hbox{}
  \thispagestyle{empty}
  \newpage
  \if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother

Best regards and welcome to the board
Thorsten
Post Reply