How to Set Headers and Fonts in KOMA-Script
At a glance
- 1. Choose the header tool
Use scrlayer-scrpage to define running-header and footer contents.
- 2. Set the running mark
Choose which section or chapter title should appear in the header.
- 3. Change header typography
Use KOMA-Script’s pageheadfoot font element.
- 4. Style section headings
Set disposition or an individual heading font element.
KOMA-Script separates the contents of a running header from its font. Use scrlayer-scrpage to decide what text or page number appears in the header and footer, then use KOMA-Script’s font commands to style them. Section and chapter headings are controlled separately from running headers.
The example below uses scrartcl, places the current section mark at the inner side of the header, and puts the page number at the outer side. It also changes the running-header font and the section-title font.
Complete example
\documentclass[11pt]{scrartcl}
\usepackage[automark]{scrlayer-scrpage}
\usepackage{xcolor}
\clearpairofpagestyles
\automark{section}
\ihead{\headmark}
\ohead{\pagemark}
\pagestyle{scrheadings}
% Font used for running headers and footers
\setkomafont{pageheadfoot}{\normalfont\sffamily\small}
% Font for sectioning headings in general
\setkomafont{disposition}{\normalcolor\bfseries}
% Override the general setting for section titles
\setkomafont{section}{\normalfont\Large\bfseries\color{blue}}
\begin{document}
\section{A section heading}
This section title is blue. Its text also appears in the running header
when the page style displays the section mark.
\newpage
This page shows the running header and page number.
\end{document}
The example needs the KOMA-Script classes and packages (usually included with a TeX distribution) and xcolor for the blue section title. The page marks in this example are produced during the same run; rerun LaTeX when changes affect auxiliary-file data such as references or a table of contents.
How the header commands work
\usepackage[automark]{scrlayer-scrpage} loads the package that provides KOMA-Script’s page-style commands. \clearpairofpagestyles clears the existing header and footer fields so that only the fields you specify remain.
\automark{section} tells KOMA-Script to update the running mark when a new section begins. In an article, \headmark then provides the current mark for use in the header. The commands \ihead and \ohead place content at the inner and outer sides of the header. In a one-sided document, these correspond to the left and right sides. \pagemark prints the page number.
For a report or book, the mark is often based on chapters, with sections used as a secondary mark. For example, you can use \automark[section]{chapter} in a class with chapters. The exact mark arrangement depends on whether your document is one-sided or two-sided.
Change the running-header font
This line changes the font used for page headers and footers:
\setkomafont{pageheadfoot}{\normalfont\sffamily\small}
Here, \normalfont selects the document’s normal font family and shape, \sffamily switches to sans serif, and \small reduces the size. Replace these declarations with the font choices you want. For example, \normalfont\itshape gives an italic header in the normal family.
This only changes typography. It does not decide whether the header contains a section title, chapter title, page number, or other text. Set that content with commands such as \ihead, \ohead, \chead, \ifoot, and \cfoot.
Change section and chapter heading fonts
KOMA-Script also provides font elements for headings. \setkomafont{disposition}{...} sets a general style for sectioning headings. A command for a more specific element, such as \setkomafont{section}{...}, can override the general setting for that heading level.
Use \addtokomafont instead of \setkomafont when you want to add a style without replacing the existing declarations. For example, \addtokomafont{section}{\color{blue}} adds a color while retaining the other section-heading settings. The example uses \setkomafont for the section element, so its explicit font declarations replace that element’s existing font setup.
Common mistakes
- Changing the heading font when you meant the running header. A section title printed at the top of a page may be a running mark, while the large title in the document body is a section heading. They use different font settings.
- Setting a font but not header content.
\setkomafont{pageheadfoot}{...}does not create a header. Add content with\ihead,\ohead, or another header-field command. - Using the wrong mark for the class.
\automark{section}suitsscrartcl; chapter-based classes commonly use\automark[section]{chapter}instead. - Mixing KOMA-Script with a competing page-style setup. Packages or manual definitions that also control page styles can override or conflict with
scrlayer-scrpage. Prefer its commands when working with KOMA-Script. - Expecting a font-family switch to load a new font.
\sffamilyselects the sans-serif family configured for the document. It does not install or select a particular font file.
If you only want a different section-title font, you do not need scrlayer-scrpage; use \setkomafont or \addtokomafont for the relevant heading element. If you want to change what appears in the page header, use scrlayer-scrpage and set the header content separately.
References
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.