0

How to add the document title in the header in scrbook using scrlayer-scrpage. Right now by default one gets the chapter name on the even pages and section name in odd pages as the header. I want to the document title as the replacement for section. I have managed to have the title in the header, but the chapter name is not there. Also, I have used cfoot for the page numbering, it works fine except for the pages where the chapter starts, it goes to ohead and formatting of italics is missing.

enter image description here

enter image description here

MWE

\documentclass[twoside]{scrbook}

\usepackage[markcase=noupper]{scrlayer-scrpage}
\setkomafont{pageheadfoot}{\normalfont\itshape\small}
\ohead{}
\ihead{}
\ofoot{}
\ifoot{}
\cfoot{\thepage}
\Ifthispageodd{\chead{The title}}{\chead{\thechapter}}

\usepackage{lipsum}

\title{The title}

\begin{document}


\chapter{To start with}

\section{Firstly}
\lipsum

\lipsum

\section{Secondly}
\lipsum

\lipsum


\end{document}
2
  • Did I understand you correctly that you want the chapter on the left page and the title on the right? Isn't that highly confusing? Wouldn't it be better to have the title to the left and the chapter to the right? Aug 12, 2020 at 10:04
  • Ohkay, thanks for the suggestion. Have changed it,
    – Damitr
    Aug 12, 2020 at 10:09

2 Answers 2

2

Like this? Since your document is twosided, there are odd and even pages. This is reflected in the commands you can use to set headers and footers:

  • \cohead{} aka centered head on odd pages (read: page on the right side)
  • \cehead{} aka centered head on even pages (read: pages on the left side)
  • \cfoot*{} aka centered foot on pages which are supposed to have headers (headings) with addition of the asterisk * also including pages usually left empty (like plain chapter pages)
\documentclass[twoside]{scrbook}

\usepackage[automark,markcase=noupper]{scrlayer-scrpage}
\setkomafont{pageheadfoot}{\normalfont\itshape\small}

\renewcommand{\chaptermark}[1]{\markleft{#1}}
\clearpairofpagestyles 

\cehead{Book Title}
\cohead{\leftmark}
\cfoot*{\pagemark}

\usepackage{lipsum}

\title{The title}

\begin{document}

\chapter{To start with}

\section{Firstly}
\lipsum
\lipsum

\section{Secondly}
\lipsum
\lipsum

\end{document}

title and chapter in the head

4
  • This produces "1 Chapter-title" in the header. I do not want the chapter number "1" just the title of the chapter "Chapter-title"
    – Damitr
    Aug 12, 2020 at 9:50
  • @Damitr, got it. Did the edit solve it? Aug 12, 2020 at 9:55
  • \renewcommand{\chaptermark}[1]{\markleft{#1}} does it, \renewcommand{\sectionmark}[1]{\markleft{#1}} produces a blank header
    – Damitr
    Aug 12, 2020 at 9:58
  • @Damitr, yes, of course, got confused whether you wanted the chapter or the section... will edit Aug 12, 2020 at 10:00
2

Here is a suggestion:

\documentclass[%
  %twoside% default
]{scrbook}

\usepackage[markcase=noupper]{scrlayer-scrpage}
\automark[chapter]{chapter}% chapter sets both left and right mark
\setkomafont{pageheadfoot}{\normalfont\itshape\small}
\setkomafont{pagenumber}{}% page number should use the same font as other elements in header and footer
\clearpairofpagestyles
\cfoot*{\pagemark}
\cohead{The title}% odd page
\cehead{\headmark}% even page
\renewcommand*{\chaptermarkformat}{}% to remove the chapter number in header

\usepackage{lipsum}% only for dummy text
\title{The title}
\begin{document}
\chapter{To start with}
\section{Firstly}
\lipsum
\lipsum
\section{Secondly}
\lipsum
\lipsum
\end{document}

If the title should be on plain pages too, use the starred version of \cohead: \cohead*{The title}.

enter image description here

You can also switch \cohead and \cehead:

\cehead{The title}% even page
\cohead{\headmark}% odd page

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .