Page Layouthow to remove header & footer only on \part pages ?

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
latexian
Posts: 19
Joined: Wed Aug 05, 2009 7:57 am

how to remove header & footer only on \part pages ?

Post by latexian »

Hi all,

I want to remove header and footer on \part pages only.
But header and footer on \chapter pages must not be affected.

I used fancyhdr package in this case and any modification using \fancypagestyle{plain}{...} will modify \chapter pages too.


Is there anybody knowing this solution?

Thank you in advance.


regards,

latexian

Recommended reading 2024:

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

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

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: how to remove header & footer only on \part pages ?

Post by gmedina »

what document class are you using? Simply modify the coresponding code... (of course, not on the .cls file itself)
1,1,2,3,5,8,13,21,34,55,89,144,233,...
latexian
Posts: 19
Joined: Wed Aug 05, 2009 7:57 am

how to remove header & footer only on \part pages ?

Post by latexian »

gmedina wrote:what document class are you using? Simply modify the coresponding code... (of course, not on the .cls file itself)
here is my code :

Code: Select all

\documentclass[a4paper,twoside,10pt,final]{book}
\usepackage[margin=35mm]{geometry}
\usepackage{index}
\makeindex
\usepackage{lipsum}


\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO,LE]{\small\sf \rightmark}
\fancyhead[LO,RE]{\small\tt \leftmark} %chapter label
\fancyfoot[RO,LE]{\thepage}


% modification for default plain
\fancypagestyle{plain}{%
\fancyhf{}%
\fancyfoot[RO,LE]{\thepage}%
\renewcommand{\headrulewidth}{0pt}%
}

% making sure chapters or parts begin on odd pages.
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\begin{center}
{\bf\huge intentional left blank.}%
\end{center}
\vspace{\fill}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother


\title{I love mathematics jokes}
\author{latexian}
\date{\today}

\begin{document}
\frontmatter
\maketitle
\tableofcontents

\mainmatter

\part{Introduction}

\chapter{AAA}
\lipsum[1-18]

\chapter{BBB}
\lipsum[1-18]


\part{Advanced}

\chapter{CCC}
\lipsum[1-18]

\chapter{DDD}
\lipsum[1-18]

\appendix
\chapter{\LaTeX\ for beginner}
\lipsum[1-18]

\backmatter
\printindex
\end{document}
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

how to remove header & footer only on \part pages ?

Post by gmedina »

Hi,

add this to the preamble:

Code: Select all

\makeatletter
\renewcommand\part{%
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  \thispagestyle{empty}%
  \if@twocolumn
    \onecolumn
    \@tempswatrue
  \else
    \@tempswafalse
  \fi
  \null\vfil
  \secdef\@part\@spart}
\makeatother 
1,1,2,3,5,8,13,21,34,55,89,144,233,...
latexian
Posts: 19
Joined: Wed Aug 05, 2009 7:57 am

Re: how to remove header & footer only on \part pages ?

Post by latexian »

@gmedina,

Thanks for the code. It works.

I need a help more.
I already put the code, provided by fancyhdr, in the preamble to write "intentionally left blank." on even-numbered page for chapters ending on odd-numbered page.

However this setting does not work for the blank page right after the \part page. I want the blank page also contains the sentence "intentionally left blank." .

Thank you.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

how to remove header & footer only on \part pages ?

Post by gmedina »

Hi,

add the following code

Code: Select all

\renewcommand\@endpart{
  \if@twoside
    \if@openright
      \ifodd\c@page\else
        \cleardoublepage
      \fi
    \fi
  \fi
  \if@tempswa
    \twocolumn
  \fi}
just before the \makeatother command in the code of my previous reply.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
latexian
Posts: 19
Joined: Wed Aug 05, 2009 7:57 am

Re: how to remove header & footer only on \part pages ?

Post by latexian »

@gmedina,

thank you for your help.

it works the way i want.
Post Reply