% ======================================================================
% scrlayer-scrpage-experts.tex
% Copyright (c) Markus Kohm, 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.
% ----------------------------------------------------------------------
% scrlayer-scrpage-experts.tex
% Copyright (c) Markus Kohm, 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.
% ======================================================================
%
% Expert chapter about scrlayer-scrpage of the KOMA-Script guide
%
% ----------------------------------------------------------------------
%
% Expertenkapitel ueber scrlayer-scrpage in der KOMA-Script-Anleitung
%
% ============================================================================

\KOMAProvidesFile{scrlayer-scrpage-experts.tex}%
                 [$Date: 2013-12-13 12:11:01 +0100 (Fr, 13. Dez 2013) $
                  KOMA-Script guide (chapter: scrlayer-scrpage-experts)]
\translator{Markus Kohm}

% Date version of the translated file: 2013-10-28

\chapter[{Additional Features of \Package{scrlayer-scrpage}}]
  {Additional Features\ChangedAt{v3.12}{\Package{scrlayer-scrpage}} with
    package \Package{scrlayer-scrpage}}
\labelbase{scrlayer-scrpage-experts}
%
\BeginIndex{Package}{scrlayer-scrpage}%
Package \Package{scrlayer-scrpage} provides features that have not been
described in \autoref{cha:scrlayer-scrpage} of \autoref{part:forAuthors} of this
\iffree{user guide}{book}. But the most average user will not need those
extensions and some of them are only implemented for compatibility with
\Package{scrpage2}. So most users do not need to know them. Therefore all those
things are described here in \autoref{part:forExperts} only.

\section{Definition of new Pairs of Page Styles}
\label{sec:scrlayer-scrpage.pagestyle.pairs}

In \autoref{sec:scrlayer-scrpage.predefined.pagestyles} the page styles
\Pagestyle{scrheadings} and \Pagestyle{plain.scrheadings} have been
described. Those build quasi a pair of page styles, with
\Pagestyle{scrheadings} as the main page style with running head and
\Pagestyle{plain.scrheadings} as the corresponding \Pagestyle{plain} page
style without running head but generally with pagination. Beside the
configuration of these page styles, \Package{scrlayer-scrpage} provides also
the feature of defining new such pairs of page styles. Thereby the name of the
main page style, e.\,g., \Pagestyle{scrheadings}, is quasi the name of the
pair of page styles.

Most users will not need more than the predefined pair
\Pagestyle{scrheadings}. So the commands of this section may be understood as
an addition for special cases. And because each such case is very special,
this section also lacks of handsome examples. Nevertheless, if the support
will show me a real nice example in future, I perhaps could use it in
future. Nevertheless, I'm almost sure that all such cases could also be
solved using the predefined pair only.

\begin{Declaration}
  \Macro{defpairofpagestyles}%
  \OParameter{parent pair}\Parameter{name}\Parameter{definition}\\
  \Macro{newpairofpagestyles}%
  \OParameter{parent pair}\Parameter{name}\Parameter{definition}\\
  \Macro{renewpairofpagestyles}%
  \OParameter{parent pair}\Parameter{name}\Parameter{definition}\\
  \Macro{providepairofpagestyles}%
  \OParameter{parent pair}\Parameter{name}\Parameter{definition}
\end{Declaration}
\BeginIndex{Cmd}{defpairofpagestyles}%
\BeginIndex{Cmd}{newpairofpagestyles}%
\BeginIndex{Cmd}{renewpairofpagestyle}%
\BeginIndex{Cmd}{providepairofpagestyles}%
With these commands you may define pairs of page styles similar to
\Pagestyle{scrheadings} and \Pagestyle{plain.scrheadings}. Thereby
\PName{name} is the name of the main page style that is similar to
\Pagestyle{scrheadings}. The name of the corresponding \Pagestyle{plain} page
style will be prefixed by \PValue{plain.} automatically. So \PName{name} is
not only the name of the pair of page styles, but also the name of the main
page style of that pair, while \PValue{plain.}\PName{name} is the name of the
\Pagestyle{plain} page style of this pair.

If the optional argument \PName{parent pair} is given, the settings of the
pair of page styles with that name are the initial settings of the new pair of
page styles. So the new pair inherits the configuration of the \PName{parent
  pair}.

While reading \autoref{sec:scrlayer-scrpage.predefined.pagestyles} you might
have the impression that the commands of this section were related to
\Pagestyle{scrheadings} and \Pagestyle{plain.scrheadings} only. Nevertheless,
this is only as long true, as this is the only existing pair of page
styles. As soon as there exist more pairs of page styles, they are related to
the pair that has been activated last. In fact, this is the case for \Macro{lehead}, \Macro{cehead}, \Macro{rehead}, \Macro{lohead},
\Macro{cohead}, \Macro{rohead}, \Macro{lefoot}, \Macro{cefoot},
\Macro{refoot}, \Macro{lofoot}, \Macro{cofoot}, \Macro{rofoot}, \Macro{ihead},
\Macro{chead}, \Macro{ohead}, \Macro{ifoot}, \Macro{cfoot}, and \Macro{ofoot}
from \autoref{sec:scrlayer-scrpage.predefined.pagestyles}.

All those commands and the below described commands \Macro{clearmainofpairofpagestyles}, \Macro{clearplainofpairofpagestyles}, and
\Macro{clearpairofpagestyles} are also mentioned to be used inside the
argument \PName{definition}. In that case, they are a kind of default
configuration of the pair of page styles that will be executed each time the
pair will be activated. A pair of page styles will be activated, if one of the
page styles of the pair will be activated. This will be done mostly using
\Macro{pagestyle}\IndexCmd{pagestyle}.

Please note that the commands of
\autoref{sec:scrlayer-scrpage.pagestyle.content} are for general purpose,
anyway. So they are related to every page style that has been defined using
\Package{scrlayer-scrpage}.

Whereas \Macro{defpairofpagestyles} will define a pair independent whether or
not the corresponding page styles are already defined, will
\Macro{newpairofpagestyles} and \Macro{providepairofpagestyles} define the pair
only, if the page styles are currently undefined. If at least one of the page
styles is already defined, the new definition of
\Macro{providepairofpagestyles} will be ignored, but usage of
\Macro{newpairofpagestyles} would result in an error message. To redefine
already existing pairs of page styles you may use
\Macro{renewpairofpagestyles}. With this an error would be thrown, if at least
one of the page styles of the pair does not already exist.%
\EndIndex{Cmd}{providepairofpagestyles}%
\EndIndex{Cmd}{renewpairofpagestyles}%
\EndIndex{Cmd}{newpairofpagestyles}%
\EndIndex{Cmd}{defpairofpagestyles}%

\begin{Declaration}
  \Macro{clearmainofpairofpagestyles}\\
  \Macro{clearplainofpairofpagestyles}\\
  \Macro{clearpairofpagestyles}
\end{Declaration}
\BeginIndex{Cmd}{clearmainofpairofpagestyles}%
\BeginIndex{Cmd}{clearplainofpairofpagestyles}%
\BeginIndex{Cmd}{clearpairofpagestyles}%
Command \Macro{clearmainofpairofpagestyles} will configure the main page style
of the lastly activated pair of page styles to be empty. In contrast to this
\Macro{clearplainofpairofpagestyles} will configure the \Pagestyle{plain} page
style of the lastly activated pair of page styles to be empty. Last but not
least \Macro{clearpairofpagestyle} will configure both page styles of the
lastly activated pair of page styles to be empty.

But please note\textnote{Attention!} that none of these commands will remove
the definitions of argument \PName{definition} that has been used when
defining the pair of page styles (see above). So if you activate the pair of
page styles again, those definitions will be used again!

These commands may be used inside of \PName{definition} themselves. But you
may use them outside the definition of a pair of page styles too. In this case
they are related to the lastly activated pair of page styles.

\BeginIndex{Cmd}{clearscrheadings}%
\BeginIndex{Cmd}{clearscrplain}%
\BeginIndex{Cmd}{clearscrheadfoot}%
The commands \Macro{clearscrheadings}, \Macro{clearscrplain}, and
\Macro{clearscrheadfoot} are aliases for these commands that have been
implemented for compatibility with \Package{scrpage2} only. Nevertheless, they
are deprecated and should not be used any longer.%
\EndIndex{Cmd}{clearscrheadfoot}%
\EndIndex{Cmd}{clearscrplain}%
\EndIndex{Cmd}{clearscrheadings}%
%
\EndIndex{Cmd}{clearpairofpagestyles}%
\EndIndex{Cmd}{clearplainofpairofpagestyles}%
\EndIndex{Cmd}{clearmainofpairofpagestyles}%


\section{Definition of Simple Page Styles with Three Parts in Head and Foot }
\label{sec:scrlayer-scrpage.pagestyle.triple}

Beside predefined page styles and beside the definition of new pairs of page
styles, package \Package{scrlayer-scrpage} also provides the Definition of
page styles with three parts in head and foot. But this user interface exists
for compatibility with \Package{scrpage2} only. Nevertheless, it has been
extended to have a more consistent set of commands in difference to
\Package{scrpage2}. However, for new documents it is recommended to use the
advanced features that have been described in the previous section, instead
of the commands of this section.

\begin{Declaration}
  \Macro{deftriplepagestyle}%
  \Parameter{name of the page style}\\
  \hphantom{\XMacro{deftriplepagestyle}}%
  \OParameter{thickness of the outer line}%
  \OParameter{thickness of the inner line}\\
  \hphantom{\XMacro{deftriplepagestyle}}%
  \Parameter{inner head element}%
  \Parameter{centre head element}%
  \Parameter{outer head element}\\
  \hphantom{\XMacro{deftriplepagestyle}}%
  \Parameter{inner foot element}%
  \Parameter{centre foot element}%
  \Parameter{outer foot element}\\
  \Macro{newtriplepagestyle}%
  \Parameter{name of the page style}\\
  \hphantom{\XMacro{newtriplepagestyle}}%
  \OParameter{thickness of the outer linen}%
  \OParameter{thickness of the inner linen}\\
  \hphantom{\XMacro{newtriplepagestyle}}%
  \Parameter{inner head element}%
  \Parameter{centre head element}%
  \Parameter{outer head element}\\
  \hphantom{\XMacro{newtriplepagestyle}}%
  \Parameter{inner foot element}%
  \Parameter{centre foot element}%
  \Parameter{outer foot element}\\
  \Macro{renewtriplepagestyle}%
  \Parameter{name of the page style}\\
  \hphantom{\XMacro{renewtriplepagestyle}}%
  \OParameter{thickness of the outer line}%
  \OParameter{thickness of the inner line}\\
  \hphantom{\XMacro{renewtriplepagestyle}}%
  \Parameter{inner head element}%
  \Parameter{centre head element}%
  \Parameter{outer head element}\\
  \hphantom{\XMacro{renewtriplepagestyle}}%
  \Parameter{inner foot element}%
  \Parameter{centre foot element}%
  \Parameter{outer foot element}\\
  \Macro{providetriplepagestyle}%
  \Parameter{name of the page style}\\
  \hphantom{\XMacro{providetriplepagestyle}}%
  \OParameter{thickness of the outer line}%
  \OParameter{thickness of the inner line}\\
  \hphantom{\XMacro{providetriplepagestyle}}%
  \Parameter{inner head element}%
  \Parameter{centre head element}%
  \Parameter{outer head element}\\
  \hphantom{\XMacro{providetriplepagestyle}}%
  \Parameter{inner foot element}%
  \Parameter{centre foot element}%
  \Parameter{outer foot element}
\end{Declaration}
\BeginIndex{Cmd}{deftriplepagestyle}%
\BeginIndex{Cmd}{newtriplepagestyle}%
\BeginIndex{Cmd}{renewtriplepagestyle}%
\BeginIndex{Cmd}{providetriplepagestyle}%
With these commands you can define a single page style, whose head and foot are
parted into three elements: an inner element, a centre element, and an outer
element. The contents of the elements are given three mandatory arguments for
the head and three mandatory arguments for the foot.

Each of the two inner elements will be printed right aligned on left pages and
left aligned on right pages. The centre elements will be printed centred in
the head respectively foot of left and right pages. Each of the two outer
elements will be printed left aligned on left pages and right aligned on right
pages.

Please remember once again:\textnote{Attention!} There are only right pages in
single side layout!

The two optional arguments can be used to activate horizontal lines in the
head and foot of the page style. To do so, you put the wanted thickness of the
line as an optional argument. The first optional argument is the
\PName{thickness of the outer line} in both, the page head and footer. In the
page head it will be printed above the head contents. In the page footer it
will be printed below the foot contents. The second optional argument is the
\PName{thickness of the inner line}. This will be printed below the page head
and additionally above the page footer. If you have only one optional
argument, this is the \PName{thickness of the inner line}. In this case no
outer line will be printed. And if you omit both optional arguments, both
lines will be omitted.

Please note\textnote{Attention!} that an empty optional argument is not the
same like omitting the optional argument! Empty optional arguments are not
allowed in this case. But you may use simple dimension expressions for the
optional arguments, like they have been explained for \KOMAScript{} option
\Option{headwidth} (see \autoref{sec:scrlayer-scrpage.pagestyle.content},
\autopageref{desc:scrlayer-scrpage.option.headwidth}).

The meaning of the arguments is also shown in
\autoref{fig:scrlayer-scrpage.triplepagestyle} for an schematic double
page. Thereby ``\texttt{outer}'', ``\texttt{inner}'', and ``\texttt{centre}''
are example contents. The corresponding arrows illustrate the expansion of
those contents. The \iffree{coloured }{}texts inside the pages are only the
names of the arguments of these commands. The related arrows \iffree{in
  the same colour }{} point to the corresponding elements of the page.

\begin{figure}
  \centering
  \begin{picture}(\textwidth,80mm)
    \put(0,50mm){%
      %\
      \begin{picture}(\textwidth,30mm)(0,-10mm)
        \thinlines
        \small
        % linke Seite
        \put(0,20mm){\line(1,0){.49\textwidth}}%
        \put(0,0){\line(0,1){20mm}}%
        \multiput(0,0)(0,-1mm){10}{\line(0,-1){.5mm}}%
        \put(.49\textwidth,5mm){\line(0,1){15mm}}%
        \put(.05\textwidth,15mm){\thicklines\line(1,0){.415\textwidth}}%
        \put(.05\textwidth,10mm){\makebox(0em,5mm)[l]{\slshape outer\strut$\longrightarrow$}}%
        \put(.465\textwidth,10mm){\makebox(0em,5mm)[r]{\slshape $\longleftarrow$inner\strut}}%
        \put(.2575\textwidth,10mm){\makebox(0em,5mm)[c]{\slshape $\longleftarrow$centre\strut$\longrightarrow$}}%
        \put(.05\textwidth,10mm){\thicklines\line(1,0){.415\textwidth}}%
        % rechte Seite
        \put(0.51\textwidth,20mm){\line(1,0){.49\textwidth}}%
        \put(0.51\textwidth,5mm){\line(0,1){15mm}}%
        \multiput(\textwidth,0)(0,-1mm){10}{\line(0,-1){.5mm}}%
        \put(\textwidth,0mm){\line(0,1){20mm}}%
        \put(.535\textwidth,15mm){\thicklines\line(1,0){.415\textwidth}}%
        \put(.535\textwidth,10mm){\makebox(0em,5mm)[l]{\slshape inner\strut$\longrightarrow$}}%
        \put(.95\textwidth,10mm){\makebox(0em,5mm)[r]{\slshape $\longleftarrow$outer\strut}}%
        \put(.7425\textwidth,10mm){\makebox(0em,5mm)[c]{\slshape $\longleftarrow$centre\strut$\longrightarrow$}}%
        \put(.535\textwidth,10mm){\thicklines\line(1,0){.415\textwidth}}%
        % commands for both pages
        \iffree{\color{red}}{}%
        \put(.5\textwidth,0){\makebox(0,\baselineskip)[c]{\PName{inner head element}}}%
        \put(.5\textwidth,-5mm){\makebox(0,\baselineskip)[c]{\PName{centre
              head element}}}%
        \put(.5\textwidth,-10mm){\makebox(0,\baselineskip)[c]{\PName{outer
              head element}}}%
        \put(\dimexpr.5\textwidth-2em,.5\baselineskip){%
          \put(-1.5em,.5\baselineskip){\vector(0,1){7mm}}%
          \put(-3.5em,-1\baselineskip){\line(-1,0){\dimexpr .25\textwidth-6.5em\relax}}%
          \put(-\dimexpr
          .25\textwidth-3em\relax,-1\baselineskip){\vector(0,1){\dimexpr
              7mm+1.5\baselineskip\relax}}
          \put(-3.25em,-2.25\baselineskip){\line(-1,0){\dimexpr .45\textwidth-8em\relax}}%
          \put(-\dimexpr
          .45\textwidth-4.75em\relax,-2.25\baselineskip){\vector(0,1){\dimexpr
              7mm+2.75\baselineskip\relax}}
        }%
        \put(\dimexpr.5\textwidth+2em,.5\baselineskip){%
          \put(1.5em,.5\baselineskip){\vector(0,1){7mm}}%
          \put(3.5em,-1\baselineskip){\line(1,0){\dimexpr .25\textwidth-6.5em\relax}}
          \put(\dimexpr
          .25\textwidth-3em\relax,-1\baselineskip){\vector(0,1){\dimexpr
              7mm+1.5\baselineskip\relax}}
          \put(3.25em,-2.25\baselineskip){\line(1,0){\dimexpr .45\textwidth-8em\relax}}
          \put(\dimexpr
          .45\textwidth-4.75em\relax,-2.25\baselineskip){\vector(0,1){\dimexpr
              7mm+2.75\baselineskip\relax}}
        }%
      \end{picture}
      %
    }%
    \put(0,0){%
      \begin{picture}(\textwidth,30mm)
        \thinlines
        \small
        % linke Seite
        \put(0,0){\line(1,0){.49\textwidth}}%
        \put(0,0){\line(0,1){20mm}}%
        \multiput(0,20mm)(0,1mm){10}{\line(0,1){.5mm}}%
        \put(.49\textwidth,0){\line(0,1){15mm}}%
        \put(.05\textwidth,15mm){\thicklines\line(1,0){.415\textwidth}}%
        \put(.05\textwidth,10mm){\makebox(0em,5mm)[l]{\slshape outer\strut$\longrightarrow$}}%
        \put(.465\textwidth,10mm){\makebox(0em,5mm)[r]{\slshape $\longleftarrow$inner\strut}}%
        \put(.2575\textwidth,10mm){\makebox(0em,5mm)[c]{\slshape $\longleftarrow$centre\strut$\longrightarrow$}}%
        \put(.05\textwidth,10mm){\thicklines\line(1,0){.415\textwidth}}%
        % rechte Seite
        \put(.51\textwidth,0){\line(1,0){.49\textwidth}}%
        \put(.51\textwidth,0){\line(0,1){15mm}}%
        \put(\textwidth,0){\line(0,1){20mm}}%
        \multiput(\textwidth,20mm)(0,1mm){10}{\line(0,1){.5mm}}%
        \put(.535\textwidth,15mm){\thicklines\line(1,0){.415\textwidth}}%
        \put(.535\textwidth,10mm){\makebox(0em,5mm)[l]{\slshape inner\strut$\longrightarrow$}}%
        \put(.95\textwidth,10mm){\makebox(0em,5mm)[r]{\slshape $\longleftarrow$outer\strut}}%
        \put(.7425\textwidth,10mm){\makebox(0em,5mm)[c]{\slshape $\longleftarrow$centre\strut$\longrightarrow$}}%
        \put(.535\textwidth,10mm){\thicklines\line(1,0){.415\textwidth}}%
        % commands for both pages
        \iffree{\color{red}}{}%
        \put(.5\textwidth,20mm){\makebox(0,\baselineskip)[c]{\PName{inner foot
              element}}}%
        \put(.5\textwidth,25mm){\makebox(0,\baselineskip)[c]{\PName{centre
              foot element}}}%
        \put(.5\textwidth,30mm){\makebox(0,\baselineskip)[c]{\PName{outer foot
              element}}}%
        \put(\dimexpr.5\textwidth-2em,.5\baselineskip){%
          \put(-1.5em,\dimexpr 20mm-.5\baselineskip\relax){\vector(0,-1){6mm}}%
          \put(-3.5em,25mm){\line(-1,0){\dimexpr .25\textwidth-6.5em\relax}}%
          \put(-\dimexpr .25\textwidth-3em\relax,25mm){\vector(0,-1){\dimexpr
              .5\baselineskip + 11mm\relax}}%
          \put(-3em,30mm){\line(-1,0){\dimexpr .45\textwidth-7.5em\relax}}%
          \put(-\dimexpr .45\textwidth-4.5em\relax,30mm){\vector(0,-1){\dimexpr
              .5\baselineskip + 16mm\relax}}%
        }%
        \put(\dimexpr.5\textwidth+2em,.5\baselineskip){%
          \put(1.5em,\dimexpr 20mm-.5\baselineskip\relax){\vector(0,-1){6mm}}%
          \put(3.5em,25mm){\line(1,0){\dimexpr .25\textwidth-6.5em\relax}}%
          \put(\dimexpr .25\textwidth-3em\relax,25mm){\vector(0,-1){\dimexpr
              .5\baselineskip + 11mm\relax}}%
          \put(3em,30mm){\line(1,0){\dimexpr .45\textwidth-7.5em\relax}}%
          \put(\dimexpr .45\textwidth-4.5em\relax,30mm){\vector(0,-1){\dimexpr
              .5\baselineskip + 16mm\relax}}%
        }%
      \end{picture}
    }%
    \thinlines\small\iffree{\color{blue}}{}%
    \put(0.055\textwidth,45mm){\vector(0,1){25mm}}%
    \put(0.945\textwidth,45mm){\vector(0,1){25mm}}%
    \put(0.055\textwidth,45mm){\vector(0,-1){30mm}}%
    \put(0.945\textwidth,45mm){\vector(0,-1){30mm}}%
    \put(0.055\textwidth,45mm){\line(1,0){\dimexpr
        .445\textwidth-7.5em\relax}}%
    \put(0.945\textwidth,45mm){\line(-1,0){\dimexpr
        .445\textwidth-7.5em\relax}}%
    \put(0.5\textwidth,45mm){\makebox(0,0)[c]{\PName{thickness of the inner lines}}}%
    \iffree{\color{green}}{}%
    \put(0.025\textwidth,40mm){\line(0,1){35mm}}%
    \put(0.025\textwidth,75mm){\vector(1,0){3.75mm}}%
    \put(0.975\textwidth,40mm){\line(0,1){35mm}}%
    \put(0.975\textwidth,40mm){\line(0,1){35mm}}%
    \put(0.975\textwidth,75mm){\vector(-1,0){3.75mm}}%
    \put(0.025\textwidth,40mm){\line(0,-1){30mm}}%
    \put(0.025\textwidth,10mm){\vector(1,0){3.75mm}}%
    \put(0.975\textwidth,40mm){\line(0,-1){30mm}}%
    \put(0.975\textwidth,40mm){\line(0,-1){30mm}}%
    \put(0.975\textwidth,10mm){\vector(-1,0){3.75mm}}%
    \put(0.025\textwidth,40mm){\line(1,0){\dimexpr
        .475\textwidth-7.5em\relax}}%
    \put(0.975\textwidth,40mm){\line(-1,0){\dimexpr
        .475\textwidth-7.5em\relax}}%
    \put(0.5\textwidth,40mm){\makebox(0,0)[c]{\PName{thickness of the outer lines}}}%
  \end{picture}
  \caption[{Elements of a three parts page style}]{Schematic double page with
    the elements of a tripartite page style of commands
    \Macro{deftriplepagestyle}, \Macro{newtriplepagestyle},
    \Macro{providetriplepagestyle}, and \Macro{renewtriplepagestyle}}
  \label{fig:scrlayer-scrpage.triplepagestyle}
\end{figure}

With the commands that are described here, it is not possible to activate only
a single line, e.\,g., only below the page head but not above the page
footer. If you need so, you should either use the commands of the previous or
the following section.

The length of a single element\textnote{Attention!} is not limited by the
existence of a neighbour element. So in inappropriate circumstances it can
happen that one elements overwrites a neighbour element or even both of
them. The user himself is responsible to avoid such inappropriate cases. With
automatic running heads this could, e.\,g., be done using the optional
argument of the section commands. See the manual of the document class for
more information about those commands.

Command \Macro{deftriplepagestyle} defines a page style independent from
whether or not a page style with the same \PName{name of the page style}
already exists. In difference to this \Macro{newtriplepagestyle} and
\Macro{providetriplepagestyle} define the page style only, if the \PName{name
  of the page style} is not the name of an already defined page
style. Otherwise \Macro{providepagestyle} will simply do nothing, but
\Macro{newtriplepagestyle} would throw an error. Command
\Macro{renewtriplepagestyle} is something like the opposite of
\Macro{newtriplepagestyle}. It would throw an error, if there has not been
a page style with the \PName{name of the page style} before, and defines the
page style only, if there has been already a page style with the given name.

\BeginIndex{Cmd}{deftripstyle}%
The command \Macro{deftriplestyle} of \Package{scrpage2} conforms to
\Macro{deftriplepagestyle}. Because of unification reasons it has been renamed
and should not be used with it's old name any longer. Using the old name would
result in a warning message. Nevertheless, the result would be the expected
one.%
\EndIndex{Cmd}{deftripstyle}%
\EndIndex{Cmd}{providetriplepagestyle}%
\EndIndex{Cmd}{renewtriplepagestyle}%
\EndIndex{Cmd}{newtriplepagestyle}%
\EndIndex{Cmd}{deftriplepagestyle}%


\section{Definition of Complex Page Styles}
\label{sec:scrlayer-scrpage.pagestyle.experts}

Beside predefined page styles and the definition of new pairs of page styles,
and beside the definition of page styles with tripartite head and foot that
are not recommended any longer, package \Package{scrlayer-scrpage} provides
also a more basic features to define new page styles. All already described
page style definitions of \Package{scrlayer-scrpage} use internally these basic
features. Because of the complexity of this user interface it is recommended
for advanced users only. Less advanced users should be able to reach almost all
using one of the previously described features. So less advanced users do not
need to read this section.
 
\begin{Declaration}
  \Macro{defpagestyle}%
  \Parameter{name}\Parameter{head definition}\Parameter{foot definition}\\
  \Macro{newpagestyle}%
  \Parameter{name}\Parameter{head definition}\Parameter{foot definition}\\
  \Macro{providepagestyle}%
  \Parameter{name}\Parameter{head definition}\Parameter{foot definition}\\
  \Macro{renewpagestyle}%
  \Parameter{name}\Parameter{head definition}\Parameter{foot definition}%
\end{Declaration}
\BeginIndex{Cmd}{defpagestyle}%
\BeginIndex{Cmd}{newpagestyle}%
\BeginIndex{Cmd}{providepagestyle}%
\BeginIndex{Cmd}{renewpagestyle}%
These commands can be used to define a single page style with maximum
flexibility. Thereby \PName{name} is the name of the page style that should
be defined.

The arguments \PName{head definition} and \PName{foot definition} have
identical structure:
\begin{quote}\raggedright
  \texttt{%
    (\PName{length of the line above},\PName{thickness of the line above})\%\\
    \Parameter{definition for the left page in two-side layout}\%\\
    \Parameter{definition for the right page in two-side layout}\%\\
    \Parameter{definition for all pages in one-side laypout}\%\\
    (\PName{length of the line below},\PName{thickness of the line below})%
  }
\end{quote}
Thereby the arguments in the round brackets are options, this means, you may
omit them together with the brackets. In that case, the length and thickness
of the corresponding horizontal line would be given by the \KOMAScript{}
options \Option{headtopline}, \Option{headsepline}, \Option{footsepline} or
\Option{footbotline} (see \autoref{sec:scrlayer-scrpage.pagestyle.content},
\autopageref{desc:scrlayer-scrpage.option.headtopline}).

All three definition arguments are mandatory and will be used depending on the
page and the layout settings. The contents of the definitions are
arbitrary. But for page styles with running heads usage of \Macro{headmark},
\Macro{leftmark}, or \Macro{rightmark} is recommended inside the
definition. In no case section numbers or section headings should be used in
the definition. Ignoring this could result in wrong numbers or texts in the
page head or footer, because of the asynchronous page building of \LaTeX{}.

Command \Macro{defpagestyle} will define the page style independent from
whether or not a page style with the same \PName{name} already exists. Command
\Macro{newpagestyle} would throw an error, if such a page style already
exists. In difference to this, \Macro{providepagestyle} will simple do nothing
in such a case. In opposite to \Macro{newpagestyle} command
\Macro{renewpagestyle} would throw the error, if a page style with the
\PName{name} does not already exist, and therefore may be used to redefine an
existing page style.

All these commands base on command \Macro{DeclareLayerPageStyle} of package
\Package{scrlayer} internally. Thereby for a page style \PName{Name} the
layer \PName{Name}\PValue{.head.above.line} will be defined for the horizontal
line above the page head, the layer \PName{Name}\PValue{.head.odd} will be
defined for the page head of odd pages in two-side layout,
\PName{Name}\PValue{.head.even} will be defined for the page head of even pages
in two-side layout, \PName{Name}\PValue{.head.oneside} will be defined for the
page head of all pages in one-side layout, \PName{Name}\PValue{.head.below}
will be defined for the horizontal line below the page head,
\PName{Name}\PValue{.foot.above.line} will be defined for the horizontal line
above the page foot, \PName{Name}\PValue{.foot.odd} will be defined for the
page foot of odd pages in two-side layout, \PName{Name}\PValue{.foot.even} for
the page foot of even pages in two-side layout,
\PName{Name}\PValue{.foot.oneside} for the page foot of all pages in one-side
layout, and last but not least \PName{Name}\PValue{.foot.below} for the
horizontal line below the page foot. More information about layers and layer
page styles can be found from \autopageref{cha:scrlayer} in
\autoref{cha:scrlayer} also in \autoref{part:forExperts}.%
%
\begin{Example}
  Assume you want to background the whole head of page style
  \Pagestyle{scrheadings} with a colour. Because you read the introduction to
  this chapter, you know, that \Pagestyle{scrheadings} last but not least is a
  layer page style with, e.\,g., layers \PValue{scrheadings.head.even},
  \PValue{scrheadings.head.odd}, and \PValue{scrheadings.head.oneside}. So you
  define three more layers for the backgrounds and add them at the very
  beginning of the page style:
\begin{lstcode}
 \documentclass{scrartcl}
  \usepackage[automark]{scrlayer-scrpage}
  \usepackage{xcolor}
  \usepackage{blindtext}
  \DeclareLayer[clone=scrheadings.head.oneside,
    contents={%
      \color{yellow}\rule[-\dp\strutbox]{\layerwidth}{\layerheight}%
    }%
  ]{scrheadings.head.oneside.background}
  \DeclareLayer[clone=scrheadings.head.odd,
    contents={%
      \color{yellow}\rule[-\dp\strutbox]{\layerwidth}{\layerheight}%
    }%
  ]{scrheadings.head.odd.background}
  \DeclareLayer[clone=scrheadings.head.even,
    contents={%
      \color{yellow}\rule[-\dp\strutbox]{\layerwidth}{\layerheight}%
    }%
  ]{scrheadings.head.even.background}
  \AddLayersAtBeginOfPageStyle{scrheadings}{%
    scrheadings.head.oneside.background,%
    scrheadings.head.odd.background,%
    scrheadings.head.even.background%
  }
  \pagestyle{scrheadings}
  \begin{document}
  \blinddocument
  \end{document}
\end{lstcode}
  As you can see, the example uses three layers, so the position and size of
  that background layers may simply be copied from the corresponding head
  layer using option \Option{clone}. This is much easier than using only one
  background layer and dynamically calculate the position time by time.

  The coloured background have been printed using a \Macro{rule} command in
  this example. The size arguments of this \Macro{rule} are given by
  \Macro{layerwidth} and \Macro{layerheight} which contain the current width
  and height of the layer itself. The optional argument of \Macro{rule} has
  been used to move the rule down by the height of a descender.
\end{Example}
%
Instead of using new layers for the background colours like in the example
above, \Macro{colorbox} and \Macro{chead} could have been used. It is
recommended to build such a solution as an exercise. Another change could be
to add the background layers one by one and just before the contents
layers. You may do this as an exercise too.%
\EndIndex{Cmd}{renewpagestyle}%
\EndIndex{Cmd}{providepagestyle}%
\EndIndex{Cmd}{newpagestyle}%
\EndIndex{Cmd}{defpagestyle}%

\begin{Declaration}
  \KOption{hmode}\PValue{simple switch}
\end{Declaration}
\BeginIndex{Option}{hmode}%
Package \Package{scrpage2} outputs page heads and page foots in horizontal
mode always. In opposite to this \Package{scrlayer-scrpage} does not switch
into horizontal mode itself, but the output of horizontal material will do
so. Nevertheless, you can activate option \Option{hmode} to make
\Package{scrlayer-scrpage} more compatible with \Package{scrpage2} in this
aspect. But this would have implications to, i.\,e., white
spaces at the start of the output or the vertical alignment of the output.

The options knows the standard values for simple switches that are given at
\autoref{tab:truefalseswitch} on \autopageref{tab:truefalseswitch}. The option
is deactivated by default.%
\EndIndex{Option}{hmode}%
%
\EndIndex{Package}{scrlayer-scrpage}%

%%% Local Variables:
%%% mode: latex
%%% mode: flyspell
%%% coding: us-ascii
%%% ispell-local-dictionary: "en_GB"
%%% TeX-master: "../guide"
%%% End: 
