My question is essentially a follow-up to Sectionmark command ignored in running head of first section page. The solution was to replace, in the definition of \sectionmark, a higher-level command \markright with a lower-level command \rightmark. It worked like a charm for the MWE of that question. However, it does not work for me, as in my book some chapters start with a long preamble before any section commands appear. The result is that the running head prints the number and heading of the last section of previous chapter (whereas with a standard definition of \sectionmark, no headers appear on those sectionless pages). Note that issuing \sectionmark after \chapter command does not solve the problem as the running head still contains wrong section number. Here is an MWE adopted from the above question:
\documentclass[10pt]{book}
\usepackage{kantlipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\gdef\rightmark{\thesection.\ #1}} %
\fancyhead[LO]{\rightmark}
\fancyhead[RE]{\leftmark}
\fancyhead[RO]{\thepage}
\fancyhead[LE]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\begin{document}
\chapter{One}
\section{First section of chapter one}
\kant[1-3]
\section{Second section of chapter one}
\kant[8-15]
\chapter{Two}
\kant[1-10]
\section{First section of chapter two: Too much text for a running head}
\sectionmark{First section of chapter two}
\kant[11-15]
\end{document}
Furthermore, running heads in the biblatex bibliography are also distorted by this definition of \sectionmark, but these are harder to reproduce in MWE. Thanks a lot in advance for your help.
Here is a further MWE demonstrating the problem that if the \section command falls on an odd page, the running head on that page shows the full heading rather than the shortened one given in \sectionmark.
\documentclass[10pt]{book}
\usepackage{kantlipsum}
\usepackage{fancyhdr,etoolbox}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]
{\markboth{\chaptername\ \thechapter.\ #1}{\chaptername\ \thechapter.\ #1}}
\fancyhead[LO]{\rightmark}
\fancyhead[RE]{\leftmark}
\fancyhead[RO]{\thepage}
\fancyhead[LE]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\begin{document}
\chapter{One}
\section{First section of chapter one}
\kant[1-3]
\section{Second section of chapter one}
\kant[8-15]
\chapter{Two}
\kant[1-15]
\section{First section of chapter two: Too much text for a running head}
\sectionmark{First section of chapter two}
\kant[11-15]
\end{document}
\sectionthen what would you want the running head to show? Perhaps "No section yet specified"? --- GOM – Peter Wilson Nov 06 '22 at 18:50\chapterinput,\markright{<chapter title>}. – barbara beeton Nov 06 '22 at 18:58\sectionmark). Or, as @barbarabeeton suggested, the chapter title... Thank you! – Boris Nov 07 '22 at 01:06