I have customized my headers to display section numbers and section names.
However: (a) The section number (\thesection) in my header often shows up with the next page's value. (b) The section name for the first page in a chapter needs to be manually set.
In the following example code, (a) the section numbers of pages 1-3 display the next page's section number. (b) Also the first page's section name needs to be manually set with \markright, or it displays as empty text.
Btw, my assumption is that all of my chapters start on odd pages. (I'm currently doing this manually by using \ensuredoublepage, though one could certainly amend the \chapter command.)
This problem seems to stem from the timing of page breaking, sectioning, and writing the header (with the section numbers/names). What is an easy way to fix this?
Note that the example code looks long (in order to fill multiple pages required to demonstrate this effect) but is actually very simple. For understanding the problem, only the code up till the \chapter command is important, and the problem must lie there as well.
\documentclass{memoir}
\makeoddhead{myheadings}{\textit{\rightmark}}{}{\textit{\thesection} {\ } -- {\ } \thepage}
\makeevenhead{myheadings}{\thepage {\ \ } -- {\ \ }\textit{\thesection}}{}{\textit{\leftmark}}
\makeheadrule{myheadings}{\textwidth}{\normalrulethickness}
\makepagestyle{chapter}
\makeoddhead{chapter}{\textit{\rightmark}}{}{\textit{\thesection} {\ } -- {\ } \thepage}
\makeheadrule{chapter}{\textwidth}{\normalrulethickness}
\begin{document}
\pagestyle{myheadings}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\markright{Section one (Without this macro, there'd be no text here!)}
\chapter{The only chapter}
This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text. This is introductory text.
\section{Section one}
This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section.
This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section. This is the first section.
\section{Section two}
This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section.
This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section.
This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section. This is the second section.This is the second section. This is the second section.
\section{Section three}
This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section.
This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section.
This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section. This is the third section.This is the third section. This is the third section.
\section{Section four}
This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section.
This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section.
This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section. This is the fourth section.This is the fourth section. This is the fourth section.
\end{document}
lipsumpackage when in need of dummy text. – Werner Jul 26 '12 at 06:59\thesectionin the header. Due to the asynchronous page builder the nummer is often not correct at the time the page is build. The information must go through a\markcommand and then be inserted with a\leftmarkor\markright. What header do you want on chapter pages and on the other pages? – Ulrike Fischer Jul 26 '12 at 07:29