+5 votes
74 views
in Office by (242k points)
reopened
Insert header in LaTeX

1 Answer

+3 votes
by (1.6m points)
 
Best answer

Import package scrlayer-scrpage
Insert content in the header
Automatic page numbers and title of the current section
Insert lines

A header can be inserted in LaTeX using the page style "scrheadings". Read here how it works..

image image

In order to provide the reader with orientation in larger text documents, you can insert the header with important information at the top of the pages. Enter, for example, the chapter number, the title of the respective chapter or the page numbering. In LaTeX you can use the "scrlayer-scrpage" package to customize the header according to your needs. In this tipps + tricks article, we will show you how to import the package and edit the header.

Note: We use the package scrlayer-scrpage that has been an integral part of KOMA-Script (from version 3.12) since 2013. But you can also use the package in other document classes without any problems.

Import package scrlayer-scrpage

To be able to customize the header, you have to scrlayer-scrpage import the package . We also use the page style scrheadings . Simply enter the two commands in the preamble of your LaTeX document:

\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}

Insert content in the header

The header is divided into three areas in LaTeX: inside, middle and outside. The reason for this is that with two-sided printing, for example in the document class, book the page number should always appear on the outside or inside of the page. You can fill the three commands for this with content as you wish. The use of all three commands is optional. You can also just use or .

\ihead{Kopfzeile innen}

\chead{Kopfzeile Mitte}
\ohead{Kopfzeile außen}

\ihead \chead

Automatic page numbers and title of the current section

In order to insert the current page number, use the following command: If you want to have the running title in the header, for example, or this works with the following command: You can also convey to LaTeX what you want to have displayed as the running title. To do this enter the following command: You can replace the arguments for the right and left sides with: , , or .

\pagemark

\chapter \section

\headmark



\automark[rechte Seite]{linke Seite}

\chapter \section \subsection \paragraph

Example:

If you now want to display the page number as "Page N" and the title of the respective section inside, enter the following commands:

\chead{Seite \pagemark}
\ihead{\headmark}
\automark{section}

Insert lines

Optionally, you can also insert a line below or above the header. To do this, when you scrlayer-scrpage import the package, you must enter the following option:

headtopline ⟶ inserts a line above the header
headsepline ⟶ inserts a line below the header In

summary, you can insert the following command to create a line above and below the header:

\usepackage[headsepline]{scrlayer-scrpage}


...