[Tex/LaTex] Chapter title in RE header and section title on LO for <\fancyhdr>

double-sidedfancyhdr

I am writing my thesis using reportdocumentclass. I want to have current chapter title as 1. Chapter Name on right side of the even page header and section title on left side of the odd page header. I also want to have these headers as smaller cases. Below is my MWE which does not work as I want. On both pages it prints only section names. Can someone tell me what is the problem?

\documentclass[12pt, a4paper, twoside]{report}

\usepackage{fancyhdr}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\fancyhead[RE]{\chaptermark}
\fancyhead[LO]{\sectionmark}
\renewcommand{\headrulewidth}{1pt}

\begin{document}
\pagestyle{fancy}
\include{Chapter}
.
.
.
\end{document}

I also referred this question which did not help. Chapter title on even header and section title in odd header

Best Answer

Insert a \pagestyle{fancy} before the redefinition of \chaptermark and \sectionmark. The \chaptermark in your code sets a left mark and cleans the right mark. The \sectionmark sets a new right mark. So you can use

\documentclass[12pt, a4paper, twoside]{report}

\setlength\headheight{15pt}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\fancyhead{}% remove default header entries
\fancyhead[RE]{\leftmark}
\fancyhead[LO]{\rightmark}
\renewcommand{\headrulewidth}{1pt}

\usepackage{lipsum}% dummy text
\begin{document}
\chapter{Chapter}
\section{Section}
\lipsum
\lipsum
\end{document}

enter image description here

Related Question