Page LayoutRemove Headers from blank Pages

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
User avatar
Mohsen Avaji
Posts: 16
Joined: Mon Aug 27, 2012 12:06 am

Remove Headers from blank Pages

Post by Mohsen Avaji »

Hi.

How to remove headers for pages between chapters?
Yours faithfully,
Mohsen Avaji.

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

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

Remove Headers from blank Pages

Post by localghost »

Kindly prepare a self-contained and minimal example to give an adequate problem description.


Thorsten
User avatar
Mohsen Avaji
Posts: 16
Joined: Mon Aug 27, 2012 12:06 am

Remove Headers from blank Pages

Post by Mohsen Avaji »

Following is the minimal example about removing headers for pages between chapters. Thank you for your cooperation.

Code: Select all

\documentclass[12pt,a4paper]{book}
\usepackage{amsmath,amssymb,amsthm}

\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength{\headheight}{16.4pt}
\lhead{}
\rhead{}
\fancyhead[RE,LO]{\bfseries\thepage}
\fancyhead[CE]{ \leftmark }
\fancyhead[CO]{\rightmark}
\cfoot{}

\begin{document}
\chapter{Integral}
\begin{equation}
(f*g)(t)=\int_{0}^{t}f(t)g(x-t)\ dt
\end{equation}

\chapter{Matrix}
\begin{equation}
AX=B
\end{equation}

\chapter{Linear Algebra}
\end{document}
Yours faithfully,
Mohsen Avaji.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Remove Headers from blank Pages

Post by localghost »

It needs a little modification of the \cleardoublepage command. We take its definition from the LaTeX kernel and supplement it with the command that enables the empty page style.

Code: Select all

\documentclass[12pt,a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\geometry{
  headheight=15pt
}

\usepackage{fancyhdr}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE]{\leftmark}
\fancyhead[LO]{\rightmark}
\pagestyle{fancy}

\usepackage{lipsum}  % only for dummy text, not for use in actual document

%% Patch for blank pages between chapters
%% which disables the current page style
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
  \hbox{}\thispagestyle{empty}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother

\begin{document}
  \chapter{Foo}
    \lipsum[1-3]  % only for dummy text, not for use in actual document

  \chapter{Bar}
    \lipsum[4-6]  % only for dummy text, not for use in actual document

  \chapter{Baz}
    \lipsum[7-9]  % only for dummy text, not for use in actual document
\end{document}
Remarks:
  • Users of a class from KOMA-Script should use the built-in mechanisms as described in Section 3.13 of the user guide.
Post Reply