# Book fancyhdr confusion

I am writing my master's thesis and would like to have my headers as in this book. I would like my even pages with the page number in the left margin and the chapter aligned to the left. My odd pages should have the page number in the right margin, and the section number aligned to the right.

Somewhat opposite to the example presented in the fancyhdr manual (p. 13):

\documentclass{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{calc}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhf{}
\fancypagestyle{plain}{%
}


However, I am unable to edit this code to my liking, after having fiddled with it for an hour. Can you guys and gals help a fella out?

Left page:

Right page:

• So you'd like that the chapter title on even pages is aligned with the left margin of the text block, and the section title flush with the right margin of the text block? – egreg Jun 4 '13 at 20:14
• Yup, I added images explaining what I want too, see my question again! – Viktor Jun 4 '13 at 20:24

The offset you're using seems too much; but that's irrelevant. Here's a way: just tell LaTeX that you want to reserve for the page number the exact amount of the offset.

Using a parameterized length ensures that changes, if any, are made in only one place, namely where you set the \pageoffset parameter.

\documentclass{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{calc}
\newlength{\pageoffset}
\setlength{\pageoffset}{2cm}% use whatever you like
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhf{}
\fancypagestyle{plain}{%
}

\usepackage{kantlipsum}
\begin{document}
\mainmatter
\chapter{Chapter title}
\section{Section title}
\kant[1-15]
\end{document}


## Odd page

• I think that was exactly what I needed, thank you! – Viktor Jun 4 '13 at 20:38