To explain my problem let me start with my MWE:
\documentclass[a4paper,10pt]{book}
\usepackage{lipsum}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{extramarks}
\makeatletter
\renewcommand\chapter{\@startsection%
{chapter}{0}{0mm}%
{2.5\baselineskip}{1.5\baselineskip}%
{\centering\normalfont\large\scshape
}%
}
\makeatother
\newcommand{\mychap}[1]{
\chapter*{#1}
\markboth{#1}{#1}}
\renewcommand{\sectionmark}{}
\renewcommand{\chaptermark}{\markboth{\thechapter}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead{}
\fancyhead[LE]{{\thepage}}
\fancyhead[RE]{ {\itshape \nouppercase \firstleftmark}}%higher level \scshape \MakeUppercase
\fancyhead[LO]{ {\itshape \nouppercase \lastrightmark}}
\fancyhead[RO]{ {\thepage}} %odd page
\begin{document}
\mychap{one}
\lipsum
\mychap{two}
aaa
\mychap{five halves}
\mychap{three}
\lipsum
\mychap{fourth}
\lipsum[5]
\mychap{five}
d
\end{document}
Notice that:
- I want to treat chapters as sections (no page break, simple title)
- In the header I want the name of the chapter
I was able to get these features
BUT
I would like to get also
- On the header of the odd pages I want the last chapter appearing in the page (this seems to work using
\lastrightmark) - On the header of the even pages I don't want the first chapter beginning on the page but, the current chapter, i.e. the chapter I'm reading while turning the page.
In my example
- On page 2 I would like to have "one" since chapter two begins after the pagebreak between page 1 and page 2;
- On page 4 I would like to have "four" since chapter five begins after the pagebreak between page 3 and page 4.
How can I get this?



