[Tex/LaTex] Get sectionmark in fancyhdr without chapter number

fancyhdr

I have been trying to get this done for hours, but I can't get it to work.

I want the left header in my document to appear as the name of the chapter, no numbers. The right one (the one causing trouble) to be the section number + the section name.

For example:

INTRODUCTION
4. Planet formation

This is what I have so far

\renewcommand{\chaptername}{}
\renewcommand{\chaptermark}[1]{\uppercase{\markboth{#1}{}}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}

And I am using the following commands to print the headers

\lhead[\thepage]{\leftmark} 
\rhead[\nouppercase{\rightmark}]{\thepage}

But the output is
INTRODUCTION
1.4. Planet formation

Could you give me some help with this?

Best Answer

Using

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}

you'll get the chapter title in the leftmark, and using

\renewcommand{\sectionmark}[1]{\markright{\arabic{section}.\ #1}}

you'll get the section number (without the chapter number prefix) and title for the rightmark.

A complete example:

\documentclass{book}
\usepackage[a6paper]{geometry}
\usepackage{fancyhdr}
\usepackage{lipsum}
\pagestyle{fancy}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\arabic{section}.\ #1}}

\lhead[\thepage]{\leftmark} 
\rhead[\nouppercase{\rightmark}]{\thepage}

\begin{document}

\chapter{Test chapter}
\section{Test section}
\lipsum[1-4]

\end{document}

The result:

enter image description here

Your \lhead, \rhead commands can be replaced with the "more modern"

\fancyhead[EL,OR]{\thepage}
\fancyhead[ER]{\rightmark}
\fancyhead[OL]{\leftmark}