[Tex/LaTex] Customising left/right page headers

fancyhdrheader-footer

I'm completely new to using headers and am struggling to understand the options of the packages I'm using.

I took this header setup from a friend:

\documentclass[11pt,onecolumn]{book}
\usepackage{geometry}
\usepackage{fancyhdr,textcase}

\pagestyle{fancy}

\fancyhead{}
\fancyhead[L]{\nouppercase\leftmark}
\fancyhead[R]{\nouppercase\rightmark}
\geometry{a4paper,inner=40mm,outer=15mm,top=15mm,bottom=15mm,footskip=5mm,headsep=3mm,headheight=15mm,twoside}

\begin{document}
\title{Some title}
\maketitle

\chapter{The first chapter}
some text!
\section{The first section}
Some more text!

\end{document}

This file is a {book}, and what I'd like is for the left-page header to give only the current chapter, and the right-page header to give only the current section.

However, the header is currently the same on both pages and shows both the chapter and the section.

I'm sure this is a simple fix, but I'm having trouble knowing where to look for info.

thanks!

Best Answer

Maybe you are looking for

\documentclass[11pt,onecolumn]{book}
\usepackage{geometry}
\usepackage{fancyhdr}

\geometry{a4paper,inner=40mm,outer=15mm,top=15mm,bottom=15mm,footskip=5mm,headsep=3mm,headheight=15mm,twoside}

\pagestyle{fancy}
\fancyhead{}
\fancyhead[LE]{\nouppercase\leftmark}% LE -> Left part on Even pages
\fancyhead[RO]{\nouppercase\rightmark}% RO -> Right part on Odd pages

\usepackage{blindtext}% dummy text
\begin{document}
\title{Some title}
\author{Author}
\maketitle
\blinddocument
\end{document}

Note that I have used \geometry before \pagestyle{fancy}.

enter image description here