# fancyhdr: How get part on even and chapter on odd pages

I am trying to use `fancyhdr` to set the part no. and name on my left pages and chapter no and name on the right pages.

My document is

``````\documentclass[11pt,a4paper,twoside,openright,bibliography=totocnumbered]{scrbook}
``````

I use the following code (which looks wrong and doesn't work too well):

``````\usepackage{fancyhdr}
\pagestyle{fancy}

\renewcommand{\partmark}[1]{\markboth%
{\color[gray]{.0}\thepart. #1}{}}

\renewcommand{\chaptermark}[1]{\markright%
{\color[gray]{.0}\thechapter.\ #1}}
``````

The effect is: I get the part alright but the chapter only makes it to the head as long as I haven't used a section. Once there's a section in my text, it seems to overrule the chapter.

-
Perhaps this question is helpful, or this one. –  Thorsten Donig Mar 24 '12 at 11:00
Hi Thorsten, Thanks for the links. However, I had looked at both questions before posting and they couldn't solve my problem (which is with chapter rather than part). –  Seul Mar 24 '12 at 11:04

You have to redefine `\sectionmark` to do nothing (and also to clear the fields):

``````\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[RO,LE]{\thepage}

\renewcommand{\partmark}[1]{\markboth
{\color[gray]{.0}\thepart. #1}{}}

\renewcommand{\chaptermark}[1]{\markright
{\color[gray]{.0}\thechapter.\ #1}}

\renewcommand{\sectionmark}[1]{}
``````

However, I would put formatting instructions into `\fancyhead` and not in the `\markright` and `\markboth` commands:

``````\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}