Chapter name on the left and section name on the right in the header

fancyhdrheader-footer

I am trying to add a header on the top of each page of my document. I want to have each chapter's name on the left and section name on the right (flushrigt).

\documentclass[12pt, a4paper]{report}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[R]{\itshape \nouppercase \rightmark}
\fancyhead[L]{\itshape \nouppercase Chapter \arabic{chapter}}

\setlength{\headheight}{14.5pt}

\begin{document}
\chapter{This is a chapter}
\section{This is a section}
\eject
ABC
\eject
def
\eject
ghi
\end{document}

Also, I want to have the header starting from the first chapter (no header on the list of figures and similar pages), and no chapter name (but a header with 'bibliography') on bibliography pages.

Thank you.

Best Answer

You have to redefine \chaptermark and \sectionmark to use only the chapter/section name.

Also for the second part of the question, start with \pagestyle{plain}, and after the TOC,LOF,LOT use \pagestyle{fancy} (after a \newpage).

\documentclass[12pt, a4paper]{report}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[R]{\bfseries \rightmark}
\fancyhead[L]{\bfseries \leftmark}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}}

\setlength{\headheight}{14.5pt}

\begin{document}

\pagestyle{plain}
\tableofcontents
\listoffigures
\listoftables

\newpage
\pagestyle{fancy}
\chapter{This is a chapter}
\section{This is a section}
\newpage
ABC
\newpage
def
\newpage
ghi
\end{document}

enter image description here