Edited
I am new to LaTeX and I have just compiled my thesis using twoside (previously I had used oneside). I had to use \sectionmark{} to shorten some of the section titles so they fit in the header. But there are three places where the section starts on the page which shows the section header and on those occasions the full title appears and overruns, rather than the shorter title, which appears on the following pages. Where the section starts on a page with a chapter header, the next page shows the short section header.
I am using
\section{When and where conditions for precipitation are met}
\label{condmet}
\sectionmark{When and where conditions are met}
where I need to shorten the header. When I changed this to
\section[When and where conditions are met]{When and where conditions for precipitation are met}
that solved the problem on the page but using this also puts the short title in the table of contents and I need the full title there.
The code to set up the document and to show the problem is:
\documentclass[12pt,twoside]{book} %,PageStyleII,times,numbering,print,custombib
\usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots.
\geometry{a4paper} % ... or a4paper or a5paper or ...
\usepackage{floatrow}
\usepackage{setspace}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{lscape}
%\usepackage{float}
\usepackage{booktabs}
\captionsetup[figure]{font={small}, skip=1pt, singlelinecheck=false}
\captionsetup[subfigure]{font={small}, skip=1pt, singlelinecheck=false}
\captionsetup{labelfont=bf}
\captionsetup[table]{font={small}, skip=1pt, singlelinecheck=false}
\raggedbottom
\usepackage{lineno}
\usepackage{mathtools}
\usepackage[all]{nowidow}
\usepackage{tocloft}
\usepackage{xpatch}
\usepackage{enumitem}
%\usepackage{amssymb}
\usepackage{cite}
\usepackage{natbib}
\renewcommand\bibname{References}
\usepackage[nottoc]{tocbibind}
\usepackage{appendix}
\usepackage{chngcntr}
\usepackage{longtable}
\usepackage{color, colortbl}
\definecolor{lightgray}{gray}{0.9}
\floatsetup[table]{capposition=top}
\usepackage{makecell}
\begin{document}
% ******************************** Main Matter *********************************
\mainmatter
\chapter{Assessing the evidence for microenvironments in craters}
\label{chap:micro}
\chaptermark{Microenvironments in craters}
\newpage
%********************************** %5th Section **************************************
\section{The environment at Kaiser crater}
Blah blah blah
\newpage
%********************************** %First Section **************************************
\section{When and where conditions for precipitation are met}
\label{condmet}
\sectionmark{When and where conditions are met}
The blah blah
\end{document}
So for the last page, the header is the full one, rather than the shorter one given in \sectionmark{}. It only does this when the section starts on a page with a section header. Is there a reason it does this and can it be fixed? Thanks
\sectionmark{…}inside the mandatory argument of\sectionwould help. – cabohah Sep 15 '23 at 10:38