% ======================================================================
% scrpage2.tex
% Copyright (c) Markus Kohm, 2001-2013
%
% This file is part of the LaTeX2e KOMA-Script bundle.
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c of the license.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX 
% version 2005/12/01 or later and of this work.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The Current Maintainer and author of this work is Markus Kohm.
%
% This work consists of all files listed in manifest.txt.
% ----------------------------------------------------------------------
% scrpage2.tex
% Copyright (c) Markus Kohm, 2001-2013
%
% Dieses Werk darf nach den Bedingungen der LaTeX Project Public Lizenz,
% Version 1.3c, verteilt und/oder veraendert werden.
% Die neuste Version dieser Lizenz ist
%   http://www.latex-project.org/lppl.txt
% und Version 1.3c ist Teil aller Verteilungen von LaTeX
% Version 2005/12/01 oder spaeter und dieses Werks.
%
% Dieses Werk hat den LPPL-Verwaltungs-Status "author-maintained"
% (allein durch den Autor verwaltet).
%
% Der Aktuelle Verwalter und Autor dieses Werkes ist Markus Kohm.
% 
% Dieses Werk besteht aus den in manifest.txt aufgefuehrten Dateien.
% ======================================================================
%
% Chapter about scrpage2 of the KOMA-Script guide
% Maintained by Jens-Uwe Morawski (and sometimes Markus Kohm)
%
% ----------------------------------------------------------------------
%
% Kapitel ueber scrpage2 in der KOMA-Script-Anleitung
% Verwaltet von Jens-Uwe Morawski (unterstuetzt von Markus Kohm)
%
% ============================================================================

\KOMAProvidesFile{scrpage2.tex}
                 [$Date: 2013-12-13 12:11:01 +0100 (Fr, 13. Dez 2013) $
                  KOMA-Script guide (chapter:scrpage2)]

\translator{Jens-Uwe Morawski\and Karl-Heinz Zimmer\and Christoph Bier\and
  Gernot Hassenpflug\and Markus Kohm}

% date of translated german file: 2013/07/22

\chapter{Adapting Page Headers and Footers with \Package{scrpage2}}
\labelbase{scrpage}

%
\BeginIndex{Package}{scrpage2}%
As already mentioned in the two previous chapters, {\KOMAScript} includes a
package to customise the document page header and footer.  As of 2001, this
package is no longer \Package{scrpage}\IndexPackage{scrpage} but the much
improved and enhanced successor \Package{scrpage2}.  Therefore, this
documentation describes only \Package{scrpage2}.  The package
\Package{scrpage} is deprecated.

\begin{Explain}
  In place of \Package{scrpage2} you can of course make use of
  \Package{fancyhdr} (see \cite{package:fancyhdr}). However,
  \Package{scrpage2} integrated markedly better with the {\KOMAScript}
  bundle. For this reason, and because at the time the forerunner to
  \Package{fancyhdr} was missing many features, \Package{scrpage2} was
  developed. Naturally, \Package{scrpage2} is not limited to use only
  with the {\KOMAScript} classes, but can just as easily be used with
  other document classes.
\end{Explain}


\section{Basic Functionality}\label{sec:scrpage.basics}

\begin{Explain}% Introduction to headings
  To understand the following description, an overview of {\LaTeX}'s fairly
  involved header and footer mechanism is needed.  The {\LaTeX} kernel defines
  the page styles \Pagestyle{empty}, which produces a completely empty header
  and footer, and \Pagestyle{plain}, which produces usually only a page number
  in the footer and an empty header.  Apart from these, many document classes
  provide the style \Pagestyle{headings}, which allows more complex style
  settings and running
  headings\Index{headings>running}\Index{headings>automatic}.  The
  \Pagestyle{headings} style often has a related variant,
  \Pagestyle{myheadings}, which is similar except for switching off the
  running headings\Index{headings>manual} and reverting them to manual control
  by the user.  A more detailed description is given in
  \autoref{sec:maincls.pagestyle} where it is also noted that some {\LaTeX}
  commands automatically switch to another page style\,---\,usually page style
  \Pagestyle{plain}\,---\,for the current page.
\end{Explain}


Package \Package{scrpage2} does not distinguish between page styles with
automatic, running headings and page styles with manual headings. The way to
deal with automatic and manual headings is independent from the page style and
so the page style is independent from the choice of automatic or manual
headings. More information about this in \autoref{sec:scrpage.basics.mark}.

  
\subsection{Predefined Page Styles}\label{sec:scrpage.basics.buildIn}

One of the basic features of \Package{scrpage2} is a set of predefined,
configurable page styles.

% \lehead ...
% scrheadings
% \headmark \pagemark 

\begin{Declaration}
  \Pagestyle{scrheadings}\\
  \Pagestyle{scrplain}
\end{Declaration}%
\BeginIndex{Pagestyle}{scrheadings}%
\BeginIndex{Pagestyle}{scrplain}%
\Index{page>style}%
%
Package \Package{scrpage2} delivers its own page style, named
\Pagestyle{scrheadings}, which can be activated with the
\Macro{pagestyle}\PParameter{scrheadings}. When this page style is in use, an
appropriate \Pagestyle{scrplain} page style is used for the plain page style.
In this case \emph{appropriate} means that this new plain page style is also
configureable by the commands introduced in
\autoref{sec:scrpage.basics.format}, which, for example, configure the header
and footer width and complies within the basic layout. Neither the activation
of \Pagestyle{scrheadings} nor the attendant change to the appropriate plain
page style, \Pagestyle{scrplain}, influences the mode of manual or automatic
headings\Index{headings>automatic}\Index{headings>manual} (see
\autoref{sec:scrpage.basics.mark}). The \Pagestyle{scrplain} page style can
also be activated directly with \Macro{pagestyle}.

\begin{Declaration}
  \Macro{lehead}%
    \OParameter{scrplain-left-even}\Parameter{scrheadings-left-even}\\
  \Macro{cehead}%
    \OParameter{scrplain-center-even}\Parameter{scrheadings-center-even}\\
  \Macro{rehead}%
    \OParameter{scrplain-right-even}\Parameter{scrheadings-right-even}\\
  \Macro{lefoot}%
    \OParameter{scrplain-left-even}\Parameter{scrheadings-left-even}\\
  \Macro{cefoot}%
    \OParameter{scrplain-center-even}\Parameter{scrheadings-center-even}\\
  \Macro{refoot}%
    \OParameter{scrplain-right-even}\Parameter{scrheadings-right-even}\\
  \Macro{lohead}%
    \OParameter{scrplain-left-odd}\Parameter{scrheadings-left-odd}\\
  \Macro{cohead}%
    \OParameter{scrplain-center-odd}\Parameter{scrheadings-center-odd}\\
  \Macro{rohead}%
    \OParameter{scrplain-right-odd}\Parameter{scrheadings-right-odd}\\
  \Macro{lofoot}%
    \OParameter{scrplain-left-odd}\Parameter{scrheadings-left-odd}\\
  \Macro{cofoot}%
    \OParameter{scrplain-center-odd}\Parameter{scrheadings-center-odd}\\
  \Macro{rofoot}%
    \OParameter{scrplain-right-odd}\Parameter{scrheadings-right-odd}\\
  \Macro{ihead}%
    \OParameter{scrplain-inside}\Parameter{scrheadings-inside}\\
  \Macro{chead}%
    \OParameter{scrplain-centered}\Parameter{scrheadings-centered}\\
  \Macro{ohead}%
    \OParameter{scrplain-outside}\Parameter{scrheadings-outside}\\
  \Macro{ifoot}%
    \OParameter{scrplain-inside}\Parameter{scrheadings-inside}\\
  \Macro{cfoot}%
    \OParameter{scrplain-centered}\Parameter{scrheadings-centered}\\
  \Macro{ofoot}%
    \OParameter{scrplain-outside}\Parameter{scrheadings-outside}
\end{Declaration}%
\BeginIndex{Cmd}{lehead}%
\BeginIndex{Cmd}{cehead}%
\BeginIndex{Cmd}{rehead}%
\BeginIndex{Cmd}{ihead}%
\BeginIndex{Cmd}{chead}%
\BeginIndex{Cmd}{ohead}%
\BeginIndex{Cmd}{lohead}%
\BeginIndex{Cmd}{cohead}%
\BeginIndex{Cmd}{rohead}%
\BeginIndex{Cmd}{lefoot}%
\BeginIndex{Cmd}{cefoot}%
\BeginIndex{Cmd}{refoot}%
\BeginIndex{Cmd}{ifoot}%
\BeginIndex{Cmd}{cfoot}%
\BeginIndex{Cmd}{rfoot}%
\BeginIndex{Cmd}{lofoot}%
\BeginIndex{Cmd}{cofoot}%
\BeginIndex{Cmd}{rofoot}%
The page style of \Package{scrpage2} are defined to have flexible configurable
header and footer. To achieve this, the page styles include three boxes in
both the header and the footer. The contents of these boxes may be modified
easily. The commands modifying the content of these boxes can be seen in
\autoref{fig:scrpage.leheadetall}.  Commands in the middle column modify the
box contents on both odd and even pages. All of the commands have an optional
and a mandatory argument. The option Argument influences the content of
corresponding box of the plain page style, \Pagestyle{scrplain}. The mandatory
argument influences the content of the corresponding box of the page style
\Pagestyle{scrheadings}.

\begin{figure}
%  \centering
  \setcapindent{0pt}%
  \begin{captionbeside}
    [Commands for modification of \Package{scrpage2} page styles elements]%
    {Commands for modification of page styles \Pagestyle{scrheadings} and
      \Pagestyle{scrplain} and their relationship to header and footer
      elements}
    [l]
  \setlength{\unitlength}{.95mm}\begin{picture}(100,65)(0,8)\small
    \put(0,12){\dashbox{2}(40,56){even page}}
    \put(60,12){\dashbox{2}(40,56){odd page}}
                                % items top left
    \put(1,63){\framebox(8,4){~}}
    \put(16,63){\framebox(8,4){~}}
    \put(31,63){\framebox(8,4){~}}
                                % items top right
    \put(61,63){\framebox(8,4){~}}
    \put(76,63){\framebox(8,4){~}}
    \put(91,63){\framebox(8,4){~}}
                                % items bottom left
    \put(1,13){\framebox(8,4){~}}
    \put(16,13){\framebox(8,4){~}}
    \put(31,13){\framebox(8,4){~}}
                                % items bottom right
    \put(61,13){\framebox(8,4){~}}
    \put(76,13){\framebox(8,4){~}}
    \put(91,13){\framebox(8,4){~}}
                                % commands and arrow
                                % for twoside
                                % 
    \put(50,65){\makebox(0,0){\Macro{ihead}}}
    \put(44,65){\vector(-1,0){4}}\put(56,65){\vector(1,0){4}}
    \put(50,58){\makebox(0,0){\Macro{chead}}}
    \put(44,58){\line(-1,0){24}}\put(56,58){\line(1,0){24}}
    \put(20,58){\vector(0,1){4}}\put(80,58){\vector(0,1){4}}
    \put(50,51){\makebox(0,0){\Macro{ohead}}}
    \put(44,51){\line(-1,0){40}}\put(56,51){\line(1,0){40}}
    \put(4,51){\vector(0,1){11}}\put(96,51){\vector(0,1){11}}
                                %
    \put(50,15){\makebox(0,0){\Macro{ifoot}}}
    \put(56,15){\vector(1,0){4}}\put(44,15){\vector(-1,0){4}}
    \put(50,22){\makebox(0,0){\Macro{cfoot}}}
    \put(44,22){\line(-1,0){24}}\put(56,22){\line(1,0){24}}
    \put(20,22){\vector(0,-1){4}}\put(80,22){\vector(0,-1){4}}
    \put(50,29){\makebox(0,0){\Macro{ofoot}}}
    \put(44,29){\line(-1,0){40}}\put(56,29){\line(1,0){40}}
    \put(4,29){\vector(0,-1){11}}\put(96,29){\vector(0,-1){11}}
                                % commands for oneside
    \put(5,69){\makebox(0,0)[b]{\Macro{lehead}}}
    \put(20,69){\makebox(0,0)[b]{\Macro{cehead}}}
    \put(35,69){\makebox(0,0)[b]{\Macro{rehead}}}
                                %
    \put(65,69){\makebox(0,0)[b]{\Macro{lohead}}}
    \put(80,69){\makebox(0,0)[b]{\Macro{cohead}}}
    \put(95,69){\makebox(0,0)[b]{\Macro{rohead}}}
                                %
    \put(5,11){\makebox(0,0)[t]{\Macro{lefoot}}}
    \put(20,11){\makebox(0,0)[t]{\Macro{cefoot}}}
    \put(35,11){\makebox(0,0)[t]{\Macro{refoot}}}
                                %
    \put(65,11){\makebox(0,0)[t]{\Macro{lofoot}}}
    \put(80,11){\makebox(0,0)[t]{\Macro{cofoot}}}
    \put(95,11){\makebox(0,0)[t]{\Macro{rofoot}}}
  \end{picture}
  \end{captionbeside}
%  \caption[Commands for modification of \Package{scrpage2} page styles
%  elements]%
%  {Commands for modification of page styles \Pagestyle{scrheadings} and
%    \Pagestyle{scrplain} and their relationship to header and footer
%    elements}
  \label{fig:scrpage.leheadetall}
\end{figure}

\begin{Example}
  If one wants the page number within \Pagestyle{scrheadings} be placed in the
  middle of the footer, then following can be used:
\begin{lstcode}
  \cfoot{\pagemark}
\end{lstcode}
  The next example shows how to place both running heading and page
  number\Index{page>number}\Index{pagination} in the header; the running
  heading\Index{headings} inside and the page number outside:
\begin{lstcode}
  \ohead{\pagemark}
  \ihead{\headmark}
  \cfoot{}
\end{lstcode}
  The command \Macro{cfoot}\PParameter{} is only required in order to
  empty the item in the middle of the footer, which normally contains
  the page number.
\end{Example}

The commands which are associated with only one item can be used for
more advanced settings.

\begin{Example}
  Assuming one has the order to write an annual report of a company, one could
  use commands like this:
\begin{lstcode}
  \ohead{\pagemark}
  \rehead{Annual Report 2001}
  \lohead{\headmark}
  \cefoot{TheCompanyName Inc.}
  \cofoot{Department: Development}
\end{lstcode}
  In order to keep the data in the footer synchronized with the content
  of the document, the footer has to be updated using \Macro{cofoot}
  when a new department is discussed in the report.
\end{Example}

As mentioned above, there is a new plain page style which corresponds to
\Pagestyle{scrheadings}. Since it should also be possible to customize this
style, the commands support an optional argument with which the contents of
the appropriate fields of this plain page style can be modified.

\begin{Example}
  The position of the page number for the page style \Pagestyle{scrheadings}
  can be declared as follows:
\begin{lstcode}
  \cfoot[\pagemark]{}
  \ohead[]{\pagemark}
\end{lstcode}
  When the command \Macro{chapter}, after it has started a new page, now
  switches to the page style \Pagestyle{plain}, then the page number is
  centered in the footer.
\end{Example}
%
\EndIndex{Pagestyle}{scrheadings}%
\EndIndex{Pagestyle}{scrplain}%


\begin{Declaration}
  \Macro{clearscrheadings}\\
  \Macro{clearscrplain}\\
  \Macro{clearscrheadfoot}
\end{Declaration}%
\BeginIndex{Cmd}{clearscrheadings}%
\BeginIndex{Cmd}{clearscrplain}%
\BeginIndex{Cmd}{clearscrheadfoot}%
If one wants to redefine both the page style \Pagestyle{scrheadings} and
the corresponding plain page style, frequently one must empty
some already occupied page elements. Since one rarely fills all items
with new content, in most cases several instructions with empty
parameters are necessary.  With the help of these three instructions
the quick and thorough deletion is possible.  While
\Macro{clearscrheadings} only deletes all fields of the page style
\Pagestyle{scrheadings}, and \Macro{clearscrplain} deletes all fields of
the corresponding plain page style, \Macro{clearscrheadfoot}
sets all fields of both page styles to empty.
\begin{Example}
  If one wants to reset the page style to the default {\KOMAScript}
  settings, independent of the actual configuration, only these three
  commands are sufficient:
\begin{lstcode}
  \clearscrheadfoot
  \ohead{\headmark}
  \ofoot[\pagemark]{\pagemark}
\end{lstcode}
  Without the commands \Macro{clearscrheadfoot},
  \Macro{clearscrheadings} and \Macro{clearscrplain}, six commands with
  additional nine empty arguments would be required:
\begin{lstcode}
  \ihead[]{}
  \chead[]{}
  \ohead[]{\headmark}
  \ifoot[]{}
  \cfoot[]{}
  \ofoot[\pagemark]{\pagemark}
\end{lstcode}
  Of course, for a specific configuration, some of them could be
  dropped.%
\end{Example}%
%
\EndIndex{Cmd}{clearscrheadings}%
\EndIndex{Cmd}{clearscrplain}%
\EndIndex{Cmd}{clearscrheadfoot}%
%
\EndIndex{Cmd}{lehead}\EndIndex{Cmd}{cehead}\EndIndex{Cmd}{rehead}%
\EndIndex{Cmd}{ihead}\EndIndex{Cmd}{chead}\EndIndex{Cmd}{ohead}%
\EndIndex{Cmd}{lohead}\EndIndex{Cmd}{cohead}\EndIndex{Cmd}{rohead}%
\EndIndex{Cmd}{lefoot}\EndIndex{Cmd}{cefoot}\EndIndex{Cmd}{refoot}%
\EndIndex{Cmd}{ifoot}\EndIndex{Cmd}{cfoot}\EndIndex{Cmd}{rfoot}%
\EndIndex{Cmd}{lofoot}\EndIndex{Cmd}{cofoot}\EndIndex{Cmd}{rofoot}%

In the previous examples two commands were used which have not been
introduced yet. The description of these commands follows.

\begin{Declaration}
  \Macro{leftmark}\\
  \Macro{rightmark}
\end{Declaration}%
\BeginIndex{Cmd}{leftmark}%
\BeginIndex{Cmd}{rightmark}%
These two instructions make it possible to access the running headings, which
are normally meant for the left or for the right page. These two instruction
are not made available by \Package{scrpage2}, but directly by the {\LaTeX}
kernel. When in this section running headings of the left page or the right
page are mentioned, this refers to the contents of \Macro{leftmark} or
\Macro{rightmark}, respectively.
%
\EndIndex{Cmd}{leftmark}%
\EndIndex{Cmd}{rightmark}%


\begin{Declaration}
  \Macro{headmark}
\end{Declaration}%
\BeginIndex{Cmd}{headmark}%
This command gives access to the content of running headings.  In
contrast to \Macro{leftmark} and \Macro{rightmark}, one need not
regard the proper assignment to left or right page.%
%
\EndIndex{Cmd}{headmark}


\begin{Declaration}
  \Macro{pagemark}
\end{Declaration}%
\BeginIndex{Cmd}{pagemark}%
This command returns the formatted page number. The formatting can be
controlled by \Macro{pnumfont}, introduced in
\autoref{sec:scrpage.basics.format}, \autopageref{desc:scrpage.cmd.pnumfont},
which \Macro{pagemark} heeds automatically.%
%
\EndIndex{Cmd}{pagemark}


\begin{Declaration}
  \Pagestyle{useheadings}
\end{Declaration}%
\BeginIndex{Pagestyle}{useheadings}
The package \Package{scrpage2} is meant primarily for use of the supplied
styles or for defining one's own styles. However, it may be necessary to shift
back also to a style provided by the document class.  It might appear that
this should be done with
\Macro{pagestyle}\PParameter{headings}\IndexCmd{pagestyle}, but this has the
disadvantage that commands \Macro{automark} and \Macro{manualmark}, to be
discussed shortly, do not function as expected.  For this reason one should
shift back to the original styles using
\Macro{pagestyle}\PParameter{useheadings}\IndexCmd{pagestyle}, which chooses
the correct page styles automatically for both manual and automatic running
headings.%
%
\EndIndex{Pagestyle}{useheadings}


\subsection{Manual and Running Headings}
\label{sec:scrpage.basics.mark}
% \automark \manualmark
%
\BeginIndex{}{headings>running}%
\BeginIndex{}{headings>automatic}%
\BeginIndex{}{headings>manual}%
Usually there is a \emph{my}-version of the \Pagestyle{headings}
page style.  If such a page style is active, then the running headings
are no longer updated no longer automatically and become manual
headings.  With \Package{scrpage2} a different path is taken. Whether
the headings are running or manual is determined by the instructions
\Macro{automark} and \Macro{manualmark}, respectively.  The default
can be set already while loading of the package, with the options
\Option{automark} and \Option{manualmark} (see
\autoref{sec:scrpage.basics.options},
\autopageref{desc:scrpage.option.automark}).


\begin{Declaration}
  \Macro{manualmark}
\end{Declaration}%
\BeginIndex{Cmd}{manualmark}%
As the name suggests, \Macro{manualmark} switches off the updating of
the running headings and makes them manual. It is left to the user to
update and provide contents for the headings.  For that purpose the
instructions \Macro{markboth}\IndexCmd{markboth} and
\Macro{markright}\IndexCmd{markright} are available.%
%
\EndIndex{Cmd}{manualmark}


\begin{Declaration}
  \Macro{automark}\OParameter{right page}\Parameter{left page}
\end{Declaration}%
\BeginIndex{Cmd}{automark}%
The macro \Macro{automark} activates the automatic updating, that is, running
headings.  For the two parameters the designations of the document sectioning
level whose title is to appear in appropriate place are to be used.  Valid
values for the parameters are:
\PValue{part}\ChangedAt{v2.2}{\Package{scrpage2}}, \PValue{chapter},
\PValue{section}, \PValue{subsection}, \PValue{subsubsection},
\PValue{paragraph}, and \PValue{subparagraph}.  For most of the classes use of
\PValue{part} will not produce the expected result. So far only {\KOMAScript}
classes from version~2.9s up are known to support this value. The optional
argument \PName{right page} is understandably meant only for double-sided
documents. In the single-sided case one should normally not use it.  With the
help of the option
\Option{autooneside}\IndexOption{autooneside}\important{\Option{autooneside}}
one can also set that the optional argument in single-sided mode is ignored
automatically (see \autoref{sec:scrpage.basics.options},
\autopageref{desc:scrpage.option.autooneside}).
%
\begin{Example}
  Assuming that the document uses a \emph{book} class, whose topmost
  section level is \emph{chapter}, then after a preceding
  \Macro{manualmark}
\begin{lstcode}
  \automark[section]{chapter}
\end{lstcode}
  restores the original behaviour.  If one prefers lower section levels
  in running headings, the following can be used:
\begin{lstcode}
  \automark[subsection]{section}
\end{lstcode}
%  How useful the last declaration is, everybody has to decide
%  for themselves.
\end{Example}

\begin{Explain}
  For the upper section level, the data of the headings is set by the command
  \Macro{markboth}\IndexCmd{markboth} (see \autoref{sec:maincls.pagestyle},
  \autopageref{desc:maincls.cmd.markboth}), while that for the lower section
  level by \Macro{markright}\IndexCmd{markright} or
  \Macro{markleft}\IndexCmd{markleft}.  These commands are called indirectly
  by the sectioning commands.  The macro \Macro{markleft} is provided by the
  package \Package{scrpage2} and is defined similarly to \Macro{markright}
  (see \autoref{sec:maincls.pagestyle},
  \autopageref{desc:maincls.cmd.markright}) in the {\LaTeX} kernel.  Although
  \Macro{markleft} is not defined as an internal command, the direct use is
  not recommended.
\end{Explain}
\EndIndex{Cmd}{automark}%
%
\EndIndex{}{headings>manual}%
\EndIndex{}{headings>automatic}%
\EndIndex{}{headings>running}%


\subsection{Formatting of Header and Footer}
\label{sec:scrpage.basics.format}
% \headfont \pnumfont
% \setheadwidth \setfootwidth
% \set(head|foot)(top|sep|bot)line
The previous section concerned itself mainly with the contents of the
header and footer. This is of course not sufficient to satisfy
formative ambitions. Therefore we devote this section exclusively to
this topic.

\begin{Declaration}
  \Macro{headfont}\\
  \Macro{footfont}\\
  \Macro{pnumfont}
\end{Declaration}%
\BeginIndex{Cmd}{headfont}%
\BeginIndex{Cmd}{footfont}%
\BeginIndex{Cmd}{pnumfont}%
The command \Macro{headfont} contains the commands which determine the font of
header and footer lines.  Command \Macro{footfont} contains the difference of
the footer to that. The difference for the style of the page number is defined
by the command \Macro{pnumfont}.
\begin{Example}
  If, for example, one wants the header to be typeset in bold sans serif, the
  footer in non-bold sans serif, and the page number in a slanted serif style,
  then one can use the following definitions:
\begin{lstcode}
  \renewcommand{\headfont}{\normalfont\sffamily\bfseries}
  \renewcommand*{\footfont}{\normalfont\sffamily}
  \renewcommand{\pnumfont}{\normalfont\rmfamily\slshape}
\end{lstcode}
\end{Example}
\EndIndex{Cmd}{headfont}%
\EndIndex{Cmd}{footfont}%
\EndIndex{Cmd}{pnumfont}%

\BeginIndex{FontElement}{pagehead}%
\BeginIndex{FontElement}{pagefoot}%
\BeginIndex{FontElement}{pagenumber}%
From version 2.8p of the {\KOMAScript} classes a new unified user interface
scheme is implemented for font attributes. If \Package{scrpage2} is used
together with one of these classes, then it is recommended to set up font
attributes in the manner described in \autoref{sec:maincls.textmarkup} from
\autopageref{sec:maincls.textmarkup} onward.
\begin{Example}
  Instead of \Macro{renewcommand} the command \Macro{setkomafont}
  should be used to configure the font attributes. The previous
  definitions can then be written as:
\begin{lstcode}
  \setkomafont{pagehead}\normalfont\sffamily\bfseries}
  \setkomafont{pagefoot}{\normalfont\sffamily}
  \setkomafont{pagenumber}{\normalfont\rmfamily\slshape}
\end{lstcode}
\end{Example}
\EndIndex{FontElement}{pagenumber}%
\EndIndex{FontElement}{pagefoot}%
\EndIndex{FontElement}{pagehead}%


\begin{Declaration}
\Macro{setheadwidth}\OParameter{shift}\Parameter{width}\\
\Macro{setfootwidth}\OParameter{shift}\Parameter{width}
\end{Declaration}%
\BeginIndex{Cmd}{setheadwidth}%
\BeginIndex{Cmd}{setfootwidth}%
Normally the widths of header and footer lines correspond to the width of the
text body.  The commands
\Macro{setheadwidth}\Index{header>width}\Index{head>width} and
\Macro{setfootwidth}\Index{footer>width}\Index{foot>width} enable the user to
adapt in a simple manner the widths to his needs.  The mandatory argument
\PName{width} takes the value of the desired width of the page header or
footer, while \PName{shift} is a length parameter by which amount the
appropriate item is shifted toward the outside page edge.

For the most common situations the mandatory argument \PName{width}
accepts the following symbolic values:
\begin{labeling}[\,--]{\PValue{textwithmarginpar}}
\item[\PValue{paper}] the width of the paper
\item[\PValue{page}] the width of the page
\item[\PValue{text}] the width of the text body
\item[\PValue{textwithmarginpar}] the width of the text body including margin
\item[\PValue{head}] the current header width
\item[\PValue{foot}] the current footer width
\end{labeling}
The difference between \PValue{paper} and \PValue{page} is that
\PValue{page} means the width of the paper less the binding correction
if the package \Package{typearea}\IndexPackage{typearea} is used (see
\autoref{cha:typearea}). Without \Package{typearea} both values are
identical.

\begin{Example}
  Assume that one wants a layout like that of \emph{The
    {\LaTeX}\,Companion}, where the header projects into the
  margin. This can be obtained with:
\begin{lstcode}
  \setheadwidth[0pt]{textwithmarginpar}
\end{lstcode}
%
  which appears like this on an odd page:
%
  \begin{XmpTopPage}
    \XmpHeading{10,25}{85}
    \thinlines\XmpRule{10,23}{85}
    \XmpSetText[\XmpTopText]{10,21}
    \XmpMarginNote{83,11.8}
  \end{XmpTopPage}
%
  If the footer line should have the same width and alignment, then two
  ways to set this up are possible. The first way simply repeats the
  settings for the case of the footer line:
\begin{lstcode}
  \setfootwidth[0pt]{textwithmarginpar}
\end{lstcode}
%
  In the second way the symbolic value \PValue{head} is used, since the
  header already has the desired settings.
\begin{lstcode}
  \setfootwidth[0pt]{head}
\end{lstcode}
\end{Example}

If no \PName{shift} is indicated, i.\,e., without the optional argument,
then the header or footer appears arranged symmetrically on the page.
In other words, a value for the \PName{shift} is determined
automatically to correspond to the current page shape.
%
\begin{Example}
  Continuing with the previous example, we remove the optional
  argument:
\begin{lstcode}
  \setheadwidth{textwithmarginpar}
\end{lstcode}
%
  which appears like this on an odd page:
%
  \begin{XmpTopPage}
    \XmpHeading{5,25}{85}
    \thinlines\XmpRule{5,23}{85}
    \XmpSetText[\XmpTopText]{10,21}
    \XmpMarginNote{83,11.8}
  \end{XmpTopPage}
\end{Example}

As can be seen, the header is now shifted inward, while the header
width has not changed. The shift is calculated in a way that the
configuration of the typearea become visible also here.%
%
\EndIndex{Cmd}{setheadwidth}\EndIndex{Cmd}{setfootwidth}

\begin{Declaration}
  \Macro{setheadtopline}\OParameter{length}\Parameter{thickness}%
                        \OParameter{commands}\\
  \Macro{setheadsepline}\OParameter{length}\Parameter{thickness}%
                        \OParameter{commands}\\
  \Macro{setfootsepline}\OParameter{length}\Parameter{thickness}%
                        \OParameter{commands}\\
  \Macro{setfootbotline}\OParameter{length}\Parameter{thickness}%
                        \OParameter{commands}
\end{Declaration}%
\BeginIndex{Cmd}{setheadtopline}\BeginIndex{Cmd}{setheadsepline}%
\BeginIndex{Cmd}{setfootseptline}\BeginIndex{Cmd}{setfootbotline}%
Corresponding to the size configuration parameters of header and
footer there are commands to modify the rules above and below the
header and footer. But first of all the rules should be activated. See options  
\Option{headtopline}, \Option{headsepline},
\Option{footsepline}, and \Option{footbotline} in
\autoref{sec:scrpage.basics.options},
\autopageref{desc:scrpage.option.headsepline} for this.

\begin{labeling}[\,--]{\Macro{setfootsepline}}
\item[\Macro{setheadtopline}] configures the line above the header
\item[\Macro{setheadsepline}] configures the line below the header
\item[\Macro{setfootsepline}] configures the line above the footer
\item[\Macro{setfootbotline}] configures the line below the footer
\end{labeling}

The mandatory argument \PName{thickness} determines how strongly the
line is drawn. The optional argument \PName{length} accepts the same
symbolic values as \PName{width} for \Macro{setheadwidth}, as well as
also a normal length expression.  As long as the optional argument
\PName{length} is not assigned a value, the appropriate line length
adapts automatically the width of the header or the footer.

Use \PValue{auto} in the length argument to restore this automation
for the length of a line.

\BeginIndex{FontElement}{headtopline}%
\BeginIndex{FontElement}{headsepline}%
\BeginIndex{FontElement}{footsepline}%
\BeginIndex{FontElement}{footbotline}%
\BeginIndex{FontElement}{footbottomline}%
The\ChangedAt{v2.2}{\Package{scrpage2}} optional argument \PName{commands} may
be used to specify additional commands to be executed before the respective
line is drawn.  For example, such commands could be used for changing the
color\Index{header>color}\Index{footer>color}%
\Index{head>color}\Index{foot>color}%
\Index{color>in header}\Index{color>in footer} of the line.  When using a
{\KOMAScript} class you could also use
\Macro{setkomafont}\IndexCmd{setkomafont} to specify commands for one of the
elements \FontElement{headtopline}\important[i]{\FontElement{headtopline}\\
  \FontElement{headsepline}\\
  \FontElement{footsepline}\\
  \FontElement{footbottomline}}, \FontElement{headsepline},
\FontElement{footsepline}, \FontElement{footbottomline}, or
\FontElement{footbotline}.  These can then be extended via
\Macro{addtokomafont}\IndexCmd{addtokomafont}.  See
\autoref{sec:maincls.textmarkup}, \autopageref{desc:maincls.cmd.setkomafont}
for details on the \Macro{setkomafont} and \Macro{addtokomafont} commands.
\EndIndex{FontElement}{footbottomline}%
\EndIndex{FontElement}{footbotline}%
\EndIndex{FontElement}{footsepline}%
\EndIndex{FontElement}{headsepline}%
\EndIndex{FontElement}{headtopline}%


\begin{Declaration}
  \XMacro{setheadtopline}\OParameter{\upshape\PValue{auto}}%
                         \Parameter{\upshape\PValue{current}}\\
  \XMacro{setheadtopline}\OParameter{\upshape\PValue{auto}}%
                         \Parameter{}\\
  \XMacro{setheadtopline}\OParameter{\upshape\PValue{auto}}%
                         \Parameter{}\OParameter{}
\end{Declaration}%
The arguments shown here for the command \Macro{setheadtopline} are of
course valid for the other three configuration commands too.

If the mandatory parameter has the value \PValue{current} or has been
left empty, then the line thickness is not changed.  This may be used
to modify the length of the line without changing its thickness.

If the optional argument \PName{commands} is omitted, then all command
settings that might have been specified before will remain active,
while an empty \PName{commands} argument will revoke any previously
valid commands.

\begin{Example}
  If the header, for example, is to be contrasted by a strong line of
  2\,pt above and a normal line of 0.4\,pt between header and body,
  one can achieve this with:
\begin{lstcode}
  \setheadtopline{2pt}
  \setheadsepline{.4pt}
\end{lstcode}
  Additionally\textnote{Attention!} the options \Option{headtopline} and
  \Option{headsepline} have to be used preferably globally in the optional
  argument of \Macro{documentclass}. In this case the result may be the
  following.
%
\begin{XmpTopPage}
        \XmpHeading{10,25}{70}
        \thinlines\XmpRule{10,23}{70}
        \thicklines\XmpRule{10,28}{70}
        \XmpSetText[\XmpTopText]{10,21}
        \XmpMarginNote{83,11.8}
\end{XmpTopPage}

   To specify that this line is to be drawn also, e.\,g., in red color, you 
   would change the commands like this:
\begin{lstcode}
  \setheadtopline{2pt}[\color{red}]
  \setheadsepline{.4pt}[\color{red}]
\end{lstcode}
  In this example, as well as in the following one, line color is
  activated by applying the syntax of the
  \Package{color}\IndexPackage{color} package, so this package must of
  course be loaded. Since \Package{scrpage2} comes without built-in
  color handling, any package providing color support may be used.

  {\KOMAScript} classes also support the following way of color specification:
\begin{lstcode}
  \setheadtopline{2pt}
  \setheadsepline{.4pt}
  \setkomafont{headtopline}[\color{red}]
  \setkomafont{headsepline}[\color{red}]
\end{lstcode}

  The automatic adjustment to the header and footer width is illustrated
  in the following example:
\begin{lstcode}
  \setfootbotline{2pt}
  \setfootsepline[text]{.4pt}
  \setfootwidth[0pt]{textwithmarginpar}
\end{lstcode}

% \phantomsection for hyperref-\pageref-links jum-2001/11/24
  \phantomsection\label{page:scrpage.autoLineLength}
  \begin{XmpBotPage}
    \XmpHeading{10,18}{85}
    \thinlines\XmpRule{17,21}{70}
    \thicklines\XmpRule{10,16}{85}
    \XmpSetText[\XmpBotText]{10,33}
    \XmpMarginNote{83,24}
  \end{XmpBotPage}
\end{Example}
%
Now not everyone will like the alignment of the line above the footer;
instead, one would expect the line to be left-aligned. This can only
be achieved with a global package option, which will be described
together with other package options in the next
\autoref{sec:scrpage.basics.options}.%
%
\EndIndex{Cmd}{setheadtopline}\EndIndex{Cmd}{setheadsepline}
\EndIndex{Cmd}{setfootseptline}\EndIndex{Cmd}{setfootbotline}


\subsection{Package Options}
\label{sec:scrpage.basics.options}
% head(in|ex)clude foot(in|ex)clude --> typearea
% headtopline headsepline footbotline footsepline (plain...)
% komastyle standardstyle
% markuppercase markusecase
% automark manualmark

In opposite to the \KOMAScript{} classes, where the most options may be
changed using \Macro{KOMAoptions} or \Macro{KOMAoption} also after loading the
class, package \Package{scrpage2} does not provide this feature\iffree{
  currently}{}. All options to \Package{scrpage2} have to be global options,
i.\,e. be part of the optional argument of \Macro{documentclass}, or
package option, i.\,e. be part of the optional argument of \Macro{usepackage}.

\begin{Declaration}
\Option{headinclude}\\
\Option{headexclude}\\
\Option{footinclude}\\
\Option{footexclude}
\end{Declaration}%
\BeginIndex{Option}{headinclude}\BeginIndex{Option}{footinclude}%
\BeginIndex{Option}{headexclude}\BeginIndex{Option}{footexclude}%
Since\textnote{Attention!} \KOMAScript~3\ChangedAt{v2.3}{\Package{scrpage2}}
this options should not be passed to \Package{scrpage2} any longer using
\Macro{PassOptionsToPackage} or the optional argument of
\Macro{usepackage}. Only for compatibility reason \Package{scrpage2} still
declares them and pass them as \Option{headinclude},
\OptionValue{headinclude}{false}, \Option{footinclude} und
\OptionValue{footinclude}{false} to package \Package{typearea} (see
\autoref{sec:typearea.typearea},
\autopageref{desc:typearea.option.headinclude}) weitergereicht.
\EndIndex{Option}{headinclude}\EndIndex{Option}{footinclude}%
\EndIndex{Option}{headexclude}\EndIndex{Option}{footexclude}


\begin{Declaration}
  \Option{headtopline}\\
  \Option{plainheadtopline}\\
  \Option{headsepline}\\
  \Option{plainheadsepline}\\
  \Option{footsepline}\\
  \Option{plainfootsepline}\\
  \Option{footbotline}\\
  \Option{plainfootbotline}
\end{Declaration}%
\BeginIndex{Option}{headtopline}\BeginIndex{Option}{plainheadtopline}%
\BeginIndex{Option}{headsepline}\BeginIndex{Option}{plainheadsepline}%
\BeginIndex{Option}{footsepline}\BeginIndex{Option}{plainfootsepline}%
\BeginIndex{Option}{footbotline}\BeginIndex{Option}{plainfootbotline}%
Basic adjustment of the lines under and over header and footer can be
made with these options.  These adjustments are then considered the
default for all page styles defined with \Package{scrpage2}.  If one
of these options is used, then a line thickness 0.4\,pt is set.
Since there is a corresponding plain page style to the
page style \Pagestyle{scrheadings}, the corresponding line in the plain
style can also be configured with the \Option{plain\dots} options.
These \Option{plain} options do however work only if the corresponding
options without \Option{plain} are activated.  Thus,
\Option{plainheadtopline} shows no effect without the
\Option{headtopline} option set.

With these options, it is to be noted that the appropriate page part,
header or footer, is considered as a part of the text area for the
calculation of the type area in case a line has been activated.  This
means that, if the separation line between header and text is
activated with \Option{headsepline}, then the package
\Package{typearea} calculates the type area in such a way that the
page header is part of the text block automatically.

The\textnote{Attention!} conditions for the options of the preceding paragraph
apply also to this automation. That means that the package \Package{typearea}
must be loaded after \Package{scrpage2}, or that on use of a {\KOMAScript}
class, the options \Option{headinclude} and \Option{footinclude} must be set
explicitly with \Macro{documentclass} in order to transfer header or footer
line in the text area.%
%
\EndIndex{Option}{headtopline}\EndIndex{Option}{plainheadtopline}
\EndIndex{Option}{headsepline}\EndIndex{Option}{plainheadsepline}
\EndIndex{Option}{footsepline}\EndIndex{Option}{plainfootsepline}
\EndIndex{Option}{footbotline}\EndIndex{Option}{plainfootbotline}

\begin{Declaration}
\Option{ilines}\\
\Option{clines}\\
\Option{olines}
\end{Declaration}%
\BeginIndex{Option}{ilines}%
\BeginIndex{Option}{clines}%
\BeginIndex{Option}{olines}%
\Index{rule>alignment}\Index{line>alignment}%
With the definition of the line lengths the case can arise where the
lengths are set correctly, but the justification is not as desired
because the line will be centered in the header or footer area.  With
the package options presented here, this specification can be modified
for all page styles defined with \Package{scrpage2}.  The option
\Option{ilines} sets the justification in such a way that the lines
align to the inside edge.  The option \Option{clines} behaves like the
default justification, and \Option{olines} aligns at the outside edge.

\begin{Example}
  The next example illustrates the influence of the
  option \Option{ilines}. Please compare to the example for
  \Macro{setfootsepline} on \autopageref{page:scrpage.autoLineLength}.
\begin{lstcode}
  \usepackage[ilines]{scrpage2}
  \setfootbotline{2pt}  
  \setfootsepline[text]{.4pt}
  \setfootwidth[0pt]{textwithmarginpar}
\end{lstcode}
  The mere use of the option \Option{ilines} leads to the different
  result shown below:
\begin{XmpBotPage}
        \XmpHeading{10,18}{85}
        \thinlines\XmpRule{10,21}{70}
        \thicklines\XmpRule{10,16}{85}
        \XmpSetText[\XmpBotText]{10,33}
        \XmpMarginNote{83,24}
\end{XmpBotPage}
  In contrast to the default configuration, the separation line between
  text and footer is now left-aligned, not centered.%
\end{Example}%
\EndIndex{Option}{ilines}%
\EndIndex{Option}{clines}%
\EndIndex{Option}{olines}%


\begin{Declaration}
\Option{automark}\\
\Option{manualmark}
\end{Declaration}%
\BeginIndex{Option}{automark}%
\BeginIndex{Option}{manualmark}%
\BeginIndex{}{headings>automatic}%
\BeginIndex{}{headings>manual}%
These options set at the beginning of the document whether to use running
headings or manual ones.  The option \Option{automark} switches the automatic
updating on, \Option{manualmark} deactivates it.  Without the use of one of
the two options, the setting which was valid when the package was loaded is
preserved.
%
\begin{Example}
  You load the package \Package{scrpage2} directly after the document class
  \Class{scrreprt} without any package options:
\begin{lstcode}
  \documentclass{scrreprt}
  \usepackage{scrpage2}
\end{lstcode}
  Since the default page style of \Class{scrreprt} is \Pagestyle{plain},
  this page style is also now still active.  Futhermore, \Pagestyle{plain}
  means manual headings.  If one now activates the page style
  \Pagestyle{scrheadings} with
\begin{lstcode}
  \pagestyle{scrheadings}
\end{lstcode}
  then the manual headings are nevertheless still active.

  If you instead use the document class \Class{scrbook}, then after
\begin{lstcode}
  \documentclass{scrbook}
  \usepackage{scrpage2}
\end{lstcode}
  the page style \Pagestyle{headings} is active and the running headings are
  updated automatically.  Switching to the page style
  \Pagestyle{scrheadings} keeps this setting active.  The marking commands
  of \Class{scrbook} continue to be used.

  However, the use of
\begin{lstcode}
  \usepackage[automark]{scrpage2}
\end{lstcode}
  activates running headings independently of the used document class.
  The option does not of course affect the used page style \Pagestyle{plain}
  of the class \Class{scrreprt}. The headings are not visible until the
  page style is changed to
  \Pagestyle{scrheadings}\IndexPagestyle{scrheadings}, \Pagestyle{useheadings}
  or another user-defined page style with headings.%
\end{Example}%
\EndIndex{Option}{automark}\EndIndex{Option}{manualmark}%

\begin{Declaration}
  \Option{autooneside}
\end{Declaration}%
\BeginIndex{Option}{autooneside}%
This option ensures that the optional parameter of
\Macro{automark}\IndexCmd{automark} will be ignored automatically in
one-sided mode. See also the explanation of the command
\Macro{automark} in \autoref{sec:scrpage.basics.mark},
\autopageref{desc:scrpage.cmd.automark}.%
%
\EndIndex{Option}{autooneside}%
%
\EndIndex{}{headings>manual}%
\EndIndex{}{headings>automatic}%


\begin{Declaration}
  \Option{komastyle}\\
  \Option{standardstyle}
\end{Declaration}%
\BeginIndex{Option}{komastyle}%
\BeginIndex{Option}{standardstyle}%
These options determine the look of the predefined page styles
\Pagestyle{scrheadings} and \Pagestyle{scrplain}. The option
\Option{komastyle} configures a look like that of the {\KOMAScript} classes.
This is the default for {\KOMAScript} classes and can in this way also be set
for other classes.

The option \Option{standardstyle} configures a page style as it is
expected by the standard classes. Furthermore, the option
\Option{markuppercase} will be activated automatically, but only if
option \Option{markusedcase} is not given.%
\EndIndex{Option}{komastyle}%
\EndIndex{Option}{standardstyle}


\begin{Declaration}
\Option{markuppercase}\\
\Option{markusedcase}
\end{Declaration}%
\BeginIndex{Option}{markuppercase}%
\BeginIndex{Option}{markusedcase}%
In order to achieve the functionality of \Macro{automark}, the package
\Package{scrpage2} modifies internal commands which are used by the
document structuring commands to set the running headings.  Since some
classes, in contrast to the {\KOMAScript} classes, write the headings
in uppercase letters, \Package{scrpage2} has to know how the used
document class sets the headings.

Option \Option{markuppercase} shows \Package{scrpage2} that the document class
uses uppercase letters.  If the document class does not set the headings in
uppercase letters, then the option \Option{markusedcase} should be given.
These\textnote{Attention!} options are not suitable to force a representation;
thus, unexpected effects may occur if the given option does not match the
actual behaviour of the document class.%
\EndIndex{Option}{markuppercase}\EndIndex{Option}{markusedcase}


\begin{Declaration}
  \Option{nouppercase}
\end{Declaration}%
\BeginIndex{Option}{nouppercase}%
In the previous paragraph dealing with \Option{markuppercase} and
\Option{markusedcase}, it has been already stated that some document classes
set the running headings\Index{heading} in uppercase letters using the
commands
\Macro{MakeUppercase}\IndexCmd{MakeUppercase}\important{\Macro{MakeUppercase}}
or \Macro{uppercase}\IndexCmd{uppercase}\important{\Macro{uppercase}}.
Setting the option \Option{nouppercase} allows disabling both these commands
in the headers and footers.  However, this is valid only for page styles
defined by \Package{scrpage2}, including \Pagestyle{scrheadings} and its
corresponding plain page style.

The applied method is very brutal and can cause that desired changes
of normal letters to uppercase letters \Index{uppercase letters} do
not occur.  Since these cases do not occur frequently, the option
\Option{nouppercase} usually affords a useful solution.
\begin{Example}
  Your document uses the standard class \Class{book}\IndexClass{book},
  but you do not want the uppercase headings but mixed case
  headings. Then the preamble of your document could start with:
\begin{lstcode}
  \documentclass{book}
  \usepackage[nouppercase]{scrpage2}
  \pagestyle{scrheadings}
\end{lstcode}
  The selection of the page style \Pagestyle{scrheadings} is necessary,
  since otherwise the page style \Pagestyle{headings} is active, which
  does not respect the settings made by option \Option{nouppercase}.
\end{Example}

In some cases not only classes but also packages set the running
headings in uppercase letters.
Also in these cases the option \Option{nouppercase} should be able
to switch back to the normal mixed case headings.%
%
\EndIndex{Option}{nouppercase}


\section{Defining Own Page Styles}\label{sec:scrpage.UI}
%
% 
\subsection{The Interface for Beginners}\label{sec:scrpage.UI.user}
% \deftripstyle
\BeginIndex{Cmd}{deftripstyle}\Index{page>style}

Now one would not like to remain bound to only the provided page
styles, but may wish to define one's own page styles.  Sometimes there
will be a special need, since a specific \emph{Corporate Identity} may
require the declaration of its own page styles.  The easiest way to
deal with this is:
\begin{Declaration}
\Macro{deftripstyle}\Parameter{name}%
\OParameter{LO}\OParameter{LI}%
\Parameter{HI}\Parameter{HC}\Parameter{HO}%
\Parameter{FI}\Parameter{FC}\Parameter{FO}
\end{Declaration}%
The individual parameters have the following meanings:
\begin{labeling}[\,--]{\PName{Name}}
\item[\PName{name}] the name of the page style, in order to activate it
        using the command \Macro{pagestyle}\Parameter{name}
\item[\PName{LO}] the thickness of the outside lines,
        i.\,e., the line above the header
        and the line below the footer (optional)
\item[\PName{LI}] the thickness of the separation lines,
        i.\,e., the line below the header
        and the line above the foot (optional)
\item[\PName{HI}] contents of the inside box in the page header for two-sided
        layout or left for one-sided layout
\item[\PName{HC}] contents of the centered box in the page header
\item[\PName{HO}] contents of the outside box in the page header for two-sided
        layout or right for one-sided layout
\item[\PName{FI}] contents of the inside box in the page footer for two-sided
        layout or left for one-sided layout
\item[\PName{FC}] contents of the centered box in the page footer
\item[\PName{FO}] contents of the outside box in the page footer for two-sided
        layout or right for one-sided layout
\end{labeling}

The command \Macro{deftripstyle} definitely represents the simplest
possibility of defining page styles.  Unfortunately, there are also
restrictions connected with this, since in a page range using a page
style defined via deftripstyle, no modification of the lines above and
below header and footer can take place.

\begin{Example}
  Assume a two-sided layout, where the running headings are placed on
  the inside.  Furthermore, the document title, here ``Report'', shall
  be placed outside in the header, the page number shall be centered
  in the footer.
\begin{lstcode}
  \deftripstyle{TheReport}%
                {\headmark}{}{Report}%
                {}{\pagemark}{}
\end{lstcode}

  If moreover the lines above the header and below the footer shall be
  drawn with a thickness of 2\,pt, and the text body be separated from
  header and footer with 0.4\,pt lines, then the definition has to be
  extended:
\begin{lstcode}
  \deftripstyle{TheReport}[2pt][.4pt]%
                {\headmark}{}{Report}%
                {}{\pagemark}{}
\end{lstcode}
  See \autoref{fig:scrpage2.tomuchlines} for the result.
%
\begin{figure}
  \typeout{^^J--- Ignore underfull and overfull \string\hbox:}
  \setcapindent{0pt}%
%  \begin{center}
  \begin{captionbeside}
    [{%
      Example of a user defined, line dominated page style%
    }]{%
      example of a user defined, line dominated page style
      with a static and a running heading at the page header and a page number
      centered at the page footer%
      \label{fig:scrpage2.tomuchlines}%
    }
    [l]
    \iffree{\setlength{\unitlength}{1.15mm}}{\setlength{\unitlength}{1mm}}%
    \begin{picture}(85,51)\scriptsize
      \thinlines
      \put(0,0){\line(0,1){51}}
      \put(45,0){\line(0,1){51}}
      \put(0,51){\line(1,0){40}}
      \put(45,51){\line(1,0){40}}
      % 
      \thicklines
      \put(40,0){\line(0,1){51}}
      \put(85,0){\line(0,1){51}}
      \put(0,0,){\line(1,0){40}}
      \put(45,0){\line(1,0){40}}
      % 
      \XmpHeading[Report\hfill 2. The Eye]{6,47}{30}
      \XmpHeading[2.1 Retina\hfill Report]{49,47}{30}
      \XmpHeading[\hfill 14\hfill]{6,6.5}{30}
      \XmpHeading[\hfill 15\hfill]{49,6.5}{30}
      \put(6,44){\makebox(0,0)[tl]{\parbox{30\unitlength}{\tiny%
            \textbf{2.1 Retina}\\
            \XmpText[49]}}}
      \put(49,44){\makebox(0,0)[tl]{\parbox{30\unitlength}{\tiny%
            \XmpText[51]}}}
      % 
      \thinlines
      \XmpRule{6,45.5}{30}\XmpRule{49,45.5}{30}
      \XmpRule{6,8}{30}\XmpRule{49,8}{30}
      \linethickness{1pt}
      \XmpRule{6,49}{30}\XmpRule{49,49}{30}
      \XmpRule{6,5}{30}\XmpRule{49,5}{30}
    \end{picture}
%  \end{center}
  \end{captionbeside}
  \typeout{^^J--- Don't ignore underfull and overfull \string\hbox:^^J}
\end{figure}
\end{Example}
\EndIndex{Cmd}{deftripstyle}


\subsection{The Interface for Experts}\label{sec:scrpage.UI.expert}
% \defpagestyle \newpagestyle \providepagestyle \renewpagestyle
\Index{page>style}
Simple page styles, as they can be defined with \Macro{deftripstyle},
are fairly rare according to experience.  Either a professor requires
that the thesis looks like his or her own\,---\,and who seriously wants
to argue against such a wish?\,---\,or a company would like that half the
financial accounting emerges in the page footer.  No problem, the
solution is:
%
\begin{Declaration}
\Macro{defpagestyle}\Parameter{name}\Parameter{header definition}\Parameter{footer definition}\\
\Macro{newpagestyle}\Parameter{name}\Parameter{header definition}\Parameter{footer definition}\\
\Macro{renewpagestyle}\Parameter{name}\Parameter{header definition}\Parameter{footer definition}\\
\Macro{providepagestyle}\Parameter{name}\Parameter{header definition}\Parameter{footer definition}
\end{Declaration}%
\BeginIndex{Cmd}{defpagestyle}\BeginIndex{Cmd}{newpagestyle}%
\BeginIndex{Cmd}{renewpagestyle}\BeginIndex{Cmd}{providepagestyle}%
These four commands give full access to the capabilities of
\Package{scrpage2} to define page styles.  Their structure is
indentical, they differ only in the manner of working.
\begin{labeling}[\ --]{\Macro{providepagestyle}}
\item[\Macro{defpagestyle}] defines a new page style.
If a page style with this name already exists it will be overwritten.
\item[\Macro{newpagestyle}] defines a new page style.
If a page style with this name already exists a error message will be given.
\item[\Macro{renewpagestyle}] redefines a page style.
If a page style with this name does not exist a error message will be given.
\item[\Macro{providepagestyle}] defines a new page style only if there is no page style with that name already present.
\end{labeling}

Using \Macro{defpagestyle} as an example, the syntax of the four
commands is explained below.
\begin{labeling}[~--]{\PName{head definition}}
\item[\PName{name}] the name of the page style for
  \Macro{pagestyle}\Parameter{name}
\item[\PName{header definition}] the declaration of the header, consisting
  of five element; elements in round parenthesis are optional:\hfill\\
  \hspace*{1em}\AParameter{ALL,ALT}%
  \Parameter{EP}\Parameter{OP}\Parameter{OS}\AParameter{BLL,BLT}
\item[\PName{footer definition}]  the declaration of the footer, consisting
  of five element; elements in round parenthesis are optional:\hfill\\  
  \hspace*{1em}\AParameter{ALL,ALT}%
  \Parameter{EP}\Parameter{OP}\Parameter{OS}\AParameter{BLL,BLT}
\end{labeling}

As can be seen, header and footer declaration have identical
structure.  The individual parameters have the following meanings:
\begin{labeling}[\ --]{\PName{OLD}}
\item[\PName{ALL}] above line length: (header = outside, footer = separation
  line)
\item[\PName{ALT}] above line thickness
\item[\PName{EP}]  definition for \emph{even} pages
\item[\PName{OP}]  definition for \emph{odd} pages
\item[\PName{OS}]  definition for \emph{one-sided} layout
\item[\PName{BLL}] below line length: (header = separation line, footer =
  outside)
\item[\PName{BLT}] below line thickness
\end{labeling}

If the optional line-parameters are omitted, then the line behaviour remains
configurable by the commands introduced in
\autoref{sec:scrpage.basics.format},
\autopageref{desc:scrpage.cmd.setheadtopline}.

The three elements \PName{EP}, \PName{OP} and \PName{OS} are boxes with the
width of page header or footer, as appropriate.  The corresponding definitions
are set left-justified in the boxes. To set something left- \emph{and}
right-justified into the boxes, the space between two text elements can be
stretched using \Macro{hfill}:
%
\begin{lstcode}[belowskip=\dp\strutbox]
  {\headmark\hfill\pagemark}
\end{lstcode}

If one would like a third text-element centered in the box, then an
extended definition must be used. The commands \Macro{rlap} and
\Macro{llap} simply write the given arguments, but for {\LaTeX} they
take up no horizontal space. Only in this way is the middle text
really centered.
%
\begin{lstcode}
  {\rlap{\headmark}\hfill centered text\hfill\llap{\pagemark}}
\end{lstcode}

\iffalse% Umbruchkorrekturtext
This and the use of the expert interface in connection with other
commands provided by \Package{scpage2} follows now in the final
example.
\fi

\begin{Example}
  This examples uses the document class \Class{scrbook}, which means
  that the default page layout is two-sided.  The package
  \Package{scrpage2} is loaded with options \Option{automark} and
  \Option{headsepline}.  The first switches on the automatic update of
  running headings, the second determines that a separation line
  between header and text body is drawn in the \Pagestyle{scrheadings}
  page style.

\begin{lstcode}
  \documentclass{scrbook}
  \usepackage[automark,headsepline]{scrpage2}
\end{lstcode}

  The expert interface is used to define two page styles.  The page
  style \PValue{withoutLines} does not define any line parameters.  The
  second page style \PValue{withLines} defines a line thicknes of 1\,pt
  for the line above the header and 0\,pt for the separation line
  between header and text.

\begin{lstcode}
  \defpagestyle{withoutLines}{%
    {Example\hfill\headmark}{\headmark\hfill without lines}
    {\rlap{Example}\hfill\headmark\hfill%
     \llap{without lines}}
  }{%
    {\pagemark\hfill}
    {\hfill\pagemark}
    {\hfill\pagemark\hfill}
  }
\end{lstcode}

\begin{lstcode}
  \defpagestyle{withLines}{%
    (\textwidth,1pt)
    {with lines\hfill\headmark}{\headmark\hfill with lines}
    {\rlap{\KOMAScript}\hfill \headmark\hfill%
     \llap{with lines}}
    (0pt,0pt)
  }{%
    (\textwidth,.4pt)
    {\pagemark\hfill}
    {\hfill\pagemark}
    {\hfill\pagemark\hfill}
    (\textwidth,1pt)
  }
\end{lstcode}

  Right at the beginning of the document the page style
  \Pagestyle{scrheadings} is activated.  The command \Macro{chapter} starts
  a new chapter and automatically sets the page rstyle for this page to
  \Pagestyle{plain}. Even though not a prime example, the command
  \Macro{chead} shows how running headings can be created even on a
  plain page.  However, in principle running headings on
  chapter start-pages are to be avoided, since otherwise the special
  character of the \Pagestyle{plain} page style is lost. It is more
  important to indicate that a new chapter starts here than that a
  section of this page has a special title.

\begin{lstcode}
  \begin{document}
  \pagestyle{scrheadings}
  \chapter{Thermodynamics}
  \chead[\leftmark]{}
  \section{Main Laws}
  Every system has an extensive state quantity called
  Energy. In a closed system the energy is constant.
\end{lstcode}

  \begin{XmpTopPage}
    \XmpHeading[\hfill\textsl{1. Thermodynamics}\hfill]{10,27}{70}
    \put(10,17){\normalsize\textbf{\sffamily 1.Thermodynamics}}
    \put(10,12){\textbf{\sffamily 1.1 Main Laws}}
    \XmpSetText[%
    Every System has an extensive state quantity]{10,9}
  \end{XmpTopPage}

  After starting a new page the page style \Pagestyle{scrheadings} is
  active and thus the separation line below the header is visible.
\begin{lstcode}
  There is a state quatity of a system, called entropy, whose temporal
  change consists of entropy flow and entropy generation.
\end{lstcode}
  \begin{XmpTopPage}
    \XmpHeading[\textsl{1. Thermodynamics}\hfill]{20,27}{70}
    \thinlines\XmpRule{20,25}{70}
    \XmpSetText[%
    There is a condition unit of a system, called entropy,
    whose temporal change consists of entropy flow
    and entropy generation.]{20,20}
  \end{XmpTopPage}

  After switching to the next page, the automatic update of the running
  headings is disabled using \Macro{manualmark}, and the page style
  \PValue{withoutLines} becomes active.  Since no line parameters are
  given in the definition of this page style, the default configuration
  is used, which draws a separation line between header and text body
  because \Package{scrpage2} was called with \Option{headsepline}.
\begin{lstcode}
  \manualmark
  \pagestyle{withoutLines}
  \section{Exergy and Anergy}\markright{Energy Conversion}
  During the transition of a system to an equilibrium state
  with its environment, the maximum work gainable is called
  exergy.
\end{lstcode}
  \begin{XmpTopPage}
    \XmpHeading[\slshape Energy Conversion\hfill without lines]{10,27}{70}
    \thinlines\XmpRule{10,25}{70}
    \XmpSetText[\setlength{\parfillskip}{0pt plus 1fil}%
    \textbf{\sffamily 1.2 Exergy and Anergy}\\
    During the transition of a system to an equilibrium state
    with its environment, the maximum work gainable is called
    exergy.]{10,21}
  \end{XmpTopPage}

  At the next page of the document, the page style \PValue{withLines} is
  activated.  The line settings of its definition are taken in account
  and the lines are drawn accordingly.
\begin{lstcode}
  \pagestyle{mitLinien}
  \renewcommand{\headfont}{\itshape\bfseries}
  The portion of an energy not convertible in exergy
  is named anergy \Var{B}.
  \[ B = U + T (S_1 - S_u) - p (V_1 - V_u)\] 
  \end{document}
\end{lstcode}
  \begin{XmpTopPage}
    \XmpHeading[\itshape\bfseries with lines\hfill 1. Thermodynamics]{20,27}{70}
    \thicklines\XmpRule{20,29}{70}
    \XmpSetText[\setlength{\parfillskip}{0pt plus 1fil}%
    The portion of an energy not convertible in exergy
    is named anergy $B$. 
    \[ B = U + T (S_1 - S_u) - p (V_1 - V_u)\] ]{20,20}
  \end{XmpTopPage}
\end{Example}
\EndIndex{Cmd}{defpagestyle}\EndIndex{Cmd}{newpagestyle}
\EndIndex{Cmd}{renewpagestyle}\EndIndex{Cmd}{providepagestyle}


\subsection{Managing Page Styles}\label{sec:scrpage.UI.cfgFile}
% scrpage.cfg
\BeginIndex{File}{scrpage.cfg}
Before long the work with different page styles will establish a
common set of employed page styles, depending on taste and tasks.  In
order to make the management of page styles easier and avoid
time-consuming copy operations each time a new project is started,
\Package{scrpage2} reads the file \File{scrpage.cfg} after
initialisation.  This file can contain a set of user-defined page
styles which many projects can share.
\EndIndex{File}{scrpage.cfg}
\EndIndex{Package}{scrpage2}

\endinput


%%% Local Variables:
%%% mode: latex
%%% coding: us-ascii
%%% TeX-master: "../guide"
%%% End: 
