Menu

HowTo_ChapterNumberSeparatorInPageHeader

How to insert a horizontal bar, colon or other separator between the chapter number and title in the page header

The KOMA-Script classes scrbook and scrreprt normally set the chapter markers in the head of the page as number + title in the page style headings. Depending on the setting of the options numbers and headings or chapterprefix, the number can also be terminated with a dot and preceded by ”Chapter“ or ”Appendix“. The \chaptermarkformat command is responsible for this formatting. This can be easily redefined:

\documentclass{scrbook}
\renewcommand*{\chaptermarkformat}{%
  \chapappifchapterprefix{\ }\thechapter\autodot{} -- }
\usepackage{blindtext}

\begin{document}
\blinddocument
\end{document}

for example, sets the header on the left-hand pages as ”1 – Heading on level 0 (chapter)“. When using the option chapterprefix:

\documentclass[chapterprefix]{scrbook}
\renewcommand*{\chaptermarkformat}{%
  \chapappifchapterprefix{\ }\thechapter\autodot{} -- }
\usepackage{blindtext}

\begin{document}
\blinddocument
\end{document}

it automatically becomes ”Chapter 1 – Heading on level 0 (chapter)“. The \chapappifchapterprefix command is responsible for the dependency on the chapterprefix option (or headings=chapterprefix). It also ensures that ”Appendix“ is automatically used in the appendix instead of ”Chapter“.

To use a colon (followed by a space) instead of a horizontal bar (framed by spaces), change the definition of \chaptermarkformat as follows:

\documentclass[chapterprefix]{scrbook}
\renewcommand*{\chaptermarkformat}{%
  \chapappifchapterprefix{\ }\thechapter\autodot: }
\usepackage{blindtext}

\begin{document}
\blinddocument
\end{document}

You can also insert a prefix only at this point if you want to have the chapter headings themselves without a prefix. To do this, replace the \chapappifchapterprefix{\ } with \chapapp\:

\documentclass{scrbook}
\renewcommand*{\chaptermarkformat}{%
  \chapapp\ \thechapter\autodot\ --\ }
\usepackage{blindtext}

\begin{document}
\blinddocument
\end{document}

You can of course proceed in a similar way if you do not want the dot at this point due to the colon despite the setting numbers=withenddot. You then simply remove \autodot:

\documentclass[numbers=withenddot]{scrbook}
\renewcommand*{\chaptermarkformat}{%
  \chapapp\ \thechapter\ --\ }
\usepackage{blindtext}

\begin{document}
\blinddocument
\end{document}

Related

Wiki (English): HowTo_PageHeadFoot

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.