The scrlayer-scrpage package
Defines headers and footers for KOMA-Script and standard classes with \ihead, \chead, \ohead, \ifoot, \cfoot and \ofoot.
Loading the package
\usepackage{scrlayer-scrpage}The package belongs to KOMA-Script and is its counterpart to fancyhdr. Loading it activates the page style scrheadings. Header and footer have three fields each: inner, centre and outer. In a one-sided document inner is left and outer is right; in a two-sided one the fields swap on even pages.
Pages that start a chapter, and the title page, use the second style plain.scrheadings. The starred form of a field command, such as \cfoot*{\pagemark}, fills the field in both styles.
Main commands
\clearpairofpagestyles | Clears all fields of both page styles. |
\ihead{text}, \chead{text}, \ohead{text} | Inner, centre and outer field of the header. |
\ifoot{text}, \cfoot{text}, \ofoot{text} | The same three fields of the footer. |
\cfoot*{\pagemark} | Page number in the centre of the footer, also on plain pages. |
\automark{section} | Makes \headmark hold the current section title. |
\KOMAoptions{headsepline=true} | Rule below the header; footsepline draws one above the footer. |
\setkomafont{pageheadfoot}{\small\sffamily} | Font of header and footer. |
Complete example
\documentclass{scrartcl}
\usepackage{scrlayer-scrpage}
\clearpairofpagestyles
\automark{section}
\ihead{\headmark}
\ohead{Project report}
\cfoot*{\pagemark}
\KOMAoptions{headsepline=true}
\begin{document}
\section{Introduction}
The header shows the section title on the inner side and a fixed text
on the outer side. The page number sits in the centre of the footer.
\end{document}Compiled with pdfLaTeX from TeX Live 2023.
Pitfalls
- Do not load it together with
fancyhdr; both packages redefine the page styles. - Without the star, a field command fills only
scrheadings. A page number set with\cfoot{\pagemark}is then missing on the first page of each chapter. - The older KOMA-Script package
scrpage2is obsolete;scrlayer-scrpagereplaces it and keeps the command names.
Related pages
- How-to Headers and footers in LaTeX
- How-to Page numbers in LaTeX
- Package
fancyhdr