[Tex/LaTex] package fancyhdr: Chapter number on the left and section name on the right

fancyhdrheader-footer

I'm using the fancyhdr package to customize the header of my thesis. I want to have Chapter + chapter number on the left of the page and section name on the left of each page. I'm using the following command, but it didn't quite work

\usepackage{fancyhdr}
\fancyhf{}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter\ #1}{}}
\fancyhead[LE]{\bfseries\nouppercase{\leftmark}} 
\fancyhead[RO]{\nouppercase{\rightmark}\chaptermark}

The document class I'm using is report.

Could anyone help me to achieve what I want?

Best Answer

\documentclass{report}

\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{nameref}
\makeatletter
\newcommand*{\currentname}{\@currentlabelname}
\makeatother

\pagestyle{fancy}
\lhead{Chapter \thechapter}
\rhead{\currentname}

\begin{document}
    \chapter{Foo}

    \section{Bar}

    \lipsum
    \lipsum
\end{document}