Sie sind hier

How to move the page number from the page footer to the header

Bild von Markus Kohm

Auf Deutsch: Wie man die Seitenzahl im Kopf statt im Fuß ausgibt

For the KOMA-Script classes scrartcl, scrreprt and scrbook and their page styles headings, myheadings and plain, pagination is done by default in the page footer outside the type area. This is quite common in European typography. However, some users explicitly request that the page number should be placed in the header instead. In double-sided documents, this should usually be done outside and flush with the text area. For single-sided documents, this should usually be done on the right, also flush with the text area.

Since the classes themselves do not have a corresponding setting option, a page style package such as scrlayer-scrpage is required. The use of scrlayer-scrpage is preferable to fancyhdr, for example, because the KOMA-Script package scrlayer-scrpage works better with the KOMA-Script classes. Only with this package, various settings offered by the classes are automatically adopted.

The easiest way with scrlayer-scrpage to get the page number in the header is to use option pagestyleset=standard. This makes the default settings largely compatible with the standard classes. However, this also includes the fact that the running heads are in rather bad (because not balanced letter-spaced) versals. To switch back to mixed case, the option markcase=used is additionally required. The option must be set after option pagestyleset, because it is used to change the setting of that option:

\documentclass{scrbook}
\usepackage[automark,pagestyleset=standard,markcase=used]{scrlayer-scrpage}
\usepackage{blindtext}
\begin{document}
\blinddocument
\end{document}

As the example shows, the page number on the first page of a chapter is missing here. This is a deviation from the standard classes. The standard classes place the page number on chapter start pages in the middle of the footer. The reason why they do not use the header on chapter start pages is that it looks very lost there in the header due to the lack of a running head; it is also annoying because it reduces the exceptional effect of the large free space above the chapter title and thus the very clear recognition of chapter beginnings. However, the jump of the page number to the middle of the foot is rather ineffective and typographically questionable. If possible, identical elements should not change their position. The reader uses the page number for searching and almost always looks only at the position where he expects the page number to appear. In this case he will therefore always look at the position in his head and ignore the foot. But if he ignores the foot, it is useless to set a page number there.

If, notwithstanding the above considerations, you still want the page number on the chapter start pages in the middle of the foot, you can do this with an additional:

\cfoot[\pagemark]{}

The mandatory argument remains empty here because you do not want to change the pagination for scrheadings. The optional argument, on the other hand, is only valid for the plain page style plain.scrheadings, which is used on the chapter start pages, among others.

\documentclass{scrbook}
\usepackage[automark,pagestyleset=standard,markcase=used]{scrlayer-scrpage}
\usepackage{blindtext}
\cfoot[\pagemark]{}
\begin{document}
\blinddocument
\end{document}

If, on the other hand, regardless of the above considerations, you want the pagination to be in the head, even with chapter start pages, you can achieve this with

\ohead*{\pagemark}

and therefore:

\documentclass{scrbook}
\usepackage[automark,pagestyleset=standard,markcase=used]{scrlayer-scrpage}
\usepackage{blindtext}
\ohead*{\pagemark}
\begin{document}
\blinddocument
\end{document}

You must not use the form

\ohead[\pagemark]{}

here, because then the page number would disappear in page style scrheadings.

Comments for "How to move the page number from the page footer to the header" abonnieren