[Tex/LaTex] Custom chapter and section header with scrlayer-scrpage

header-footerscrbookscrlayer-scrpage

I would like to customise how my odd and even header looks like in scrbook class.

Even pages should look like this:

Pagenumber (left) Chapter 1: Title of the first Chapter (center) empty (right)

Odd pages should look like this for the first section:

empty (left) 1. Title of the first Section (center) Pagenumber (right)

Odd pages should look like this for the second section:

empty (left) 2. Title of the second Section (center) Pagenumber (right)

Here is the MWE of what I have so far:

\documentclass[twoside]{scrbook}
\usepackage[]{scrlayer-scrpage}
\usepackage{lipsum}
\clearpairofpagestyles
\lehead{}
\cehead{Chapter\space\leftmark}
\lehead{\pagemark}
\lohead{}
\cohead{\rightmark}
\rohead{\pagemark}
\lefoot{}
\cfoot{}
\begin{document}
\chapter{CHTITLE}
\lipsum[1-20]
\section{STITLE}
\lipsum[21-40]
\end{document}

Note that the section number should not include number of the chapter as it does now (instead of 1.1. or 1.2 it should be just 1 or 2)

Best Answer

\documentclass[twoside]{scrbook}
\usepackage{scrlayer-scrpage}
\usepackage{lipsum}
\clearpairofpagestyles
\ohead*{\pagemark}
\chead{\headmark}

\renewcommand\sectionmarkformat{\arabic{section}.\enskip}
\renewcommand\chaptermarkformat{\chaptername\ \thechapter:\enskip}

\begin{document}
\chapter{CHTITLE}
\lipsum[1-20]
\section{STITLE}
\lipsum[21-40]
\section{SECOND STITLE}
\lipsum[41-60]
\end{document}

results in

enter image description here

Related Question