I would like to have the chapter’s and section’s name appearing in the same line, one coming from the left, the other from the right end. My solution works perfectly fine as long as the chapters and sections aren’t too long. If this is the cause they are overlaid.
I am looking for a solution to put the section’s name in a second line if its name is too long, so it would interfere with the chapter’s name.
I am aware of Chapter title in header too long but I don’t want to use \chapter[<short title>]{<long title>} or \section[<short title>]{<long title>} since I don’t want to change the appearance in the table of contents.
Consider the following MWE:
\documentclass[
twoside=false,
open=right,
]{scrbook}
\usepackage{ragged2e}
\usepackage[
headsepline,
autooneside=false,
automark,
draft=false,
]{scrlayer-scrpage}
\pagestyle{scrheadings}
\clearscrheadfoot
\rofoot{\bfseries\thepage}
\automark*[subsection]{}
\addtokomafont{pageheadfoot}{\normalfont\footnotesize\sffamily}
\lohead{\RaggedRight\leftmark}
\rohead{\RaggedLeft\rightmark}
\begin{document}
\chapter{Normal chapter title in a common document}
\clearpage
\section{No problem here}
\clearpage
\section{Very big problem here since the section title is too long for the line}
\end{document}


