[Tex/LaTex] Header and footer for a book using: part on even page and chapter on odd page

book-designbooksfancyhdrheader-footer

My goal is to realize this layout for a book (possibly using fancyhdr, but I'm open to everything):

enter image description here

where the current layout is represented in grey. In other words, I want :

  • to put the page numbering on the footer of each page (except part title pages)
  • to put the name of the current part on even (non-special) pages (with the format shown in the picture: PART I: XXX) + a line under it
  • to put the name of the current chapter on odd (non-special) pages (with the format shown in the picture: CHAPTER I: XXX) + a line under it

What I name "special pages" are the pages of part title or the first page of each chapter.

  1. How to do that?
  2. From a professional editor point of view, what alignments should I choose for the header on even pages (part title on the left/center/right?) and for the header on odd pages (chapter title on the left/center/right?) (is there a prefered/more "natural" alignment?)

Here is an example of a basic document:

\documentclass[11pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{hyperref}
\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
\usepackage{fancyhdr}
\usepackage{lipsum}

%Note: this is a very preliminary attempt..., 
%Fancier solutions are welcome
%The page numbering does not work correctly
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhead[LE]{\thepart} %How do I get the part name in capital letters
\fancyhead[RO]{\thechapter} %How do I get the chapter name in capital letters

\begin{document}
\mainmatter

\part{Premiere partie}
\chapter{Premier chapitre}
\lipsum
\lipsum
\lipsum
\lipsum
\chapter{Second chapitre}
\lipsum
\lipsum
\lipsum
\lipsum
\part{Deuxieme partie}
\chapter{Troisieme chapitre}
\lipsum
\lipsum
\lipsum
\lipsum
\chapter{Quatrieme chapitre}
\lipsum
\lipsum
\lipsum
\lipsum

\end{document}

Best Answer

You can try with

\documentclass[11pt,a4paper]{book}

\usepackage[utf8]{inputenc}
%\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{hyperref}
\usepackage[head=15pt, top=1in, bottom=1in, left=1in, right=1in]{geometry}
\usepackage{lipsum}

\newcommand*\parttitle{}
\let\origpart\part
\renewcommand*{\part}[2][]{%
\ifx\\#1\\% optional argument not present?
  \origpart{#2}%
  \renewcommand*\parttitle{#2}%
\else
  \origpart[#1]{#2}%
  \renewcommand*\parttitle{#1}%
\fi
}

\usepackage{fancyhdr}\pagestyle{fancy}
\fancyhead{}
\fancyhead[RO]{\leftmark}
\fancyhead[LE]{Partie \thepart: \parttitle}
\fancyfoot{}
\fancyfoot[C]{\thepage}

\begin{document}

\part{Premiere partie}
\chapter{Premier chapitre}
\lipsum
\lipsum
\lipsum
\lipsum
\chapter{Second chapitre}
\lipsum
\lipsum
\lipsum
\lipsum
\part{Deuxieme partie}
\chapter{Troisieme chapitre}
\lipsum
\lipsum
\lipsum
\lipsum
\chapter{Quatrieme chapitre}
\lipsum
\lipsum
\lipsum
\lipsum

\end{document}

You must edit the font style in \fancyhead[RO]{\leftmark} and \fancyhead[LE]{Partie \thepart: \parttitle}. Moreover, you maybe need works with \thispagestyle{empty} for white pages before new chapter and new part.

I put % before \usepackage[T1]{fontenc} due problems with online latex compiler. Also

Related Question