I am writing a long document and I decided to change the headers, using fancyhdr
:
\documentclass[12pt,a4paper]{book}
\renewcommand*\thesection{\arabic{section}}
\usepackage{fancyhdr}
% Fancyhdr setup
\fancypagestyle{main}{
\fancyhead{} % clear all header fields
\fancyhead[LE]{\footnotesize{\scshape\nouppercase{Chapitre~\thechapter ~- ~\leftmark}}}
\fancyhead[RO]{\footnotesize{\scshape\nouppercase{\thesection~-~\rightmark}}}
\fancyfoot{} % clear all footer fields
\fancyfoot[LE,RO]{\thepage}
\renewcommand{\headrulewidth}{0 pt}
\renewcommand{\footrulewidth}{0 pt}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
}
\begin{document}
\end{document}
The problem is this code does not compile, and the problem is whit the two lines :
\renewcommand{\sectionmark}[1]{\markright{#1}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
To solve the problem I just put them outside the definition of main
headers, but it doesn't give the same result.
How should I fix this error without changing my headers ?
PS. I want the headers to be on right pages like "3 - Section title" and on the left pages (except at a begining of a chapter) like "Chapitre 1 - Title of chapter"
Thanks.
\sectionmark
and\chaptermark
in the code for the page style.