With the KOMA-Script classes scrbook
and scrreprt
you can use \chaptermark{...}
, \sectionmark
, \chaptermarkformat{...}
, \sectionmarkformat{...}
to set and format the running headings. A little example:
\documentclass[11pt,a4paper,BCOR10mm,DIV11,toc=listof]{scrbook}
\usepackage[nouppercase,headsepline]{scrpage2}
\pagestyle{scrheadings}
\clearscrheadfoot
\automark[section]{chapter}
\chead{\headmark}
\usepackage{lipsum}
\begin{document}
\chapter{A numbered chapter}
\section{Test section}
\lipsum[1-5]
\chapter*{A chapter without number}
\renewcommand*{\chaptermarkformat}{}
\renewcommand*{\sectionmarkformat}{}
\chaptermark{}
\sectionmark{A chapter without number}
\lipsum[1-30]
\end{document}
The page style of first page of a chapter of most book classes, distinguishes from the page style of the other pages. Standard class book
uses hard coded \thispagestyle{plain}
for the first page of a \chapter
. KOMA-Script class scrbook
uses \thispagestyle{\chapterpagestyle}
and the default of \chapterpagestyle
is plain
too.
And if you have a look at the result of your scrlayer-scrpage
example:
there are several differences between the first page of the chapter (left side) and other pages (right side):
- no head separation line/rule on first page vs. head separation line/rule in other pages
- no running head on first page vs. running head on other pages
- no page number on first page vs. page number on other pages
This first is, because option headsepline
does not set a head separation rule on page style plain. You could switch it on using plainheadsepline
. But I think, you do not want it. So this is good
The second is, because you have removed the defaults for page style scrheadings
and plain.scrheadings
(which is the same like plain
after the \pagestyle{scrheadings}
, that is done while loading scrlayer-scrpage
) using \clearpairofpagestyls
and you've added \headmark
only to scrheadings
but not to plain.scrheadings
. That is absolutely correct.
The third has almost the same reason as the second, but you've added \pagemark
only to scrheadings
. So if you like to have a page number on the first page of a chapter, you have to add \pagemark
to plain.scrheadings
. This could be done replacing \ihead
by \ihead*
. But this would add the page number to the head. I think, you want the page number at the middle of the foot. So you have to use
\cfoot[\pagemark]{}
Note, the optional argument of \cfoot
etc. does change the corresponding element of the plain page style.
So with:
\documentclass[oneside, openany, headsepline]{scrbook}
\usepackage{lipsum}
\usepackage[]{scrlayer-scrpage}
\clearpairofpagestyles
\ihead{\pagemark}
\ohead{\headmark}
\usepackage{etoc}
\renewcommand{\etocaftertitlehook}{\pagestyle{plain}}
\renewcommand{\etocaftertochook}{\thispagestyle{plain}}
\begin{document}
\title{title}
\maketitle
\tableofcontents
\thispagestyle{empty}
\addtocontents{toc}{\protect\thispagestyle{empty}}
\addchap{Copyright}
\pagenumbering{roman}
\chapter{Chapter}
\pagenumbering{arabic}
\section{hello}
\lipsum[1-20]
\end{document}
You will get
You could even remove using etoc
and use \BeforeStartingTOC
and \AfterStartingTOC
to set the first page of the table of contents using page style empty
but the rest of the table of contents with page style plain
:
\documentclass[oneside, openany, headsepline]{scrbook}
\usepackage{lipsum}
\usepackage{scrlayer-scrpage}
\clearpairofpagestyles
\ihead{\pagemark}
\ohead{\headmark}
\cfoot[\pagemark]{}
\BeforeStartingTOC{\pagestyle{plain}\thispagestyle{empty}}
\AfterStartingTOC{\clearpage}
\begin{document}
\title{title}
\maketitle
\tableofcontents
\addchap{Copyright}
\pagenumbering{roman}
\chapter{Chapter}
\pagenumbering{arabic}
\section{hello}
\lipsum[1-20]
\end{document}
BTW: Your fancyhdr
definition distinguish from your description. It does also set a separation line on the plain
pages. I would not recommend this, but you can do it:
\documentclass[oneside, openany, headsepline,footlines=1]{scrbook}
\usepackage{lipsum}
\usepackage[plainfootsepline]{scrlayer-scrpage}
\clearpairofpagestyles
\ihead{\pagemark}
\ohead{\headmark}
\cfoot[\pagemark]{}
\BeforeStartingTOC{\pagestyle{plain}\thispagestyle{empty}}
\AfterStartingTOC{\clearpage}
\AddToLayerPageStyleOptions{plain.scrheadings}{% whenever page style plain.scrheadings is selected
onselect={\KOMAoptions{footsepline}}% activate footsepline
}
\AddToLayerPageStyleOptions{scrheadings}{% whenever page style scrheadings is selected
onselect={\KOMAoptions{footsepline=false}}% deactivate footsepline
}
\begin{document}
\title{title}
\maketitle
\tableofcontents
\addchap{Copyright}
\pagenumbering{roman}
\chapter{Chapter}
\pagenumbering{arabic}
\section{hello}
\lipsum[1-20]
\end{document}
Here I've used \AddToLayerPageStyleOptions
to set KOMA-Script option footsepline
depending on the selected page style
If you also want to have upper case running head see option markcase
in the KOMA-Script manual. If you want the prefix CHAPTER
see \chaptermarkformat
. If you want to change the font, see elements pageheadfoot
, pagehead
, pagenumber
and commands \setkomafont
and \addtokomafont
.
Best Answer
For the part entries in the page header I will modify my example from scrpage2: Three “marks” for headings. Note that there must be no unstarred
\automark
command after the redefinition of\partmark
because this would reset this definition.To get serif font in the section titles you can change font element
disposition
or you can use the undocumented option
If also font elements like
descriptionlabel
should use the serif font you can set the undocumented optionegregdoesnotlikesansseriftitles
which was a result of this question and needs KOMA version 3.20 or newer.If your part, chapter or section titles are to long for the header, you can use option
headings=optiontohead
orheadings=optiontoheadandtoc
to use a short title in head and the long (or an other) version in TOC. See the explanations for\part[short version ]{heading
etc. in the KOMA-Script documentation section "3.16. Structuring of Documents".