% ======================================================================
% scrlayer-scrpage-experts.tex
% Copyright (c) Markus Kohm, 2013-2017
%
% 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-2017
%
% 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: 2017-01-02 13:30:07 +0100 (Mon, 02 Jan 2017) $
                  KOMA-Script guide (chapter: scrlayer-scrpage-experts)]
\translator{Markus Kohm}

% Date version of the translated file: 2015-03-31

\chapter[{Additional Features of \Package{scrlayer-scrpage}}]
  {Additional Features\ChangedAt{v3.12}{\Package{scrlayer-scrpage}} with
    package \Package{scrlayer-scrpage}}
\labelbase{scrlayer-scrpage-experts}
%
\BeginIndexGroup
\BeginIndex{Package}{scrlayer-scrpage}%
Package \Package{scrlayer-scrpage} provides features that have not been
described in \autoref{cha:scrlayer-scrpage} of this \iffree{user
  guide}{book}'s \autoref{part:forAuthors}. In general, the average user will
not need those extensions and some of them are only provided for
compatibility with \Package{scrpage2}.

\LoadCommonFile{pagestylemanipulation}% \section{Manipulation of Defined Page Styles}

\section{Definition of new Pairs of Page Styles}
\seclabel{pagestyle.pairs}

In \autoref{sec:scrlayer-scrpage.predefined.pagestyles} the page styles
\PageStyle{scrheadings} and \PageStyle{plain.scrheadings} have been
described. These can be seen as a pair of page styles, with
\PageStyle{scrheadings} being the main page style with a running head and
\PageStyle{plain.scrheadings} being the corresponding \PageStyle{plain} page
style without running head but generally with pagination. Additionally to 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}, can be seen as 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 as 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 the future, I perhaps could use it in
the future. However, 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}
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}.

Reading \autoref{sec:scrlayer-scrpage.predefined.pagestyles} might have
created the impression that the described commands are related to
\PageStyle{scrheadings} and \PageStyle{plain.scrheadings} only. However, if
there exist more pairs of page styles, these commands are related to the pair
that has been activated last. In fact, this is the case for \DescRef{scrlayer-scrpage.cmd.lehead},
\DescRef{scrlayer-scrpage.cmd.cehead}, \DescRef{scrlayer-scrpage.cmd.rehead}, \DescRef{scrlayer-scrpage.cmd.lohead}, \DescRef{scrlayer-scrpage.cmd.cohead},
\DescRef{scrlayer-scrpage.cmd.rohead}, \DescRef{scrlayer-scrpage.cmd.lefoot}, \DescRef{scrlayer-scrpage.cmd.cefoot}, \DescRef{scrlayer-scrpage.cmd.refoot},
\DescRef{scrlayer-scrpage.cmd.lofoot}, \DescRef{scrlayer-scrpage.cmd.cofoot}, \DescRef{scrlayer-scrpage.cmd.rofoot}, \DescRef{scrlayer-scrpage.cmd.ihead}, \DescRef{scrlayer-scrpage.cmd.chead},
\DescRef{scrlayer-scrpage.cmd.ohead}, \DescRef{scrlayer-scrpage.cmd.ifoot}, \DescRef{scrlayer-scrpage.cmd.cfoot}, and \DescRef{scrlayer-scrpage.cmd.ofoot} of
\autoref{sec:scrlayer-scrpage.predefined.pagestyles}.

All those commands and the below described commands
\DescRef{\LabelBase.cmd.clearmainofpairofpagestyles}, \DescRef{\LabelBase.cmd.clearplainofpairofpagestyles}, and
\DescRef{\LabelBase.cmd.clearpairofpagestyles} are also designed 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 is executed each time the pair will be
activated. A pair of page styles is activated, if one of the page styles of
the pair will be activated, which is mostly done by using
\DescRef{maincls.cmd.pagestyle}\IndexCmd{pagestyle}.

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

Whereas \Macro{defpairofpagestyles} will define a pair no matter if the
corresponding page styles are already defined, \Macro{newpairofpagestyles} and
\Macro{providepairofpagestyles} will 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.%
\EndIndexGroup


\begin{Declaration}
  \Macro{clearmainofpairofpagestyles}%
  \Macro{clearplainofpairofpagestyles}%
  \Macro{clearpairofpagestyles}
\end{Declaration}
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 provided only for
compatibility with \Package{scrpage2}. Nevertheless, they are deprecated and
should not be used.%
%
\EndIndexGroup


\section{Definition of Simple Page Styles with Three Parts in Head and Foot }
\seclabel{pagestyle.triple}

Beside predefined page styles and 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. However, it has been extended
beyond the functionality of \Package{scrpage2} to provide a more consistent
set of commands. Nevertheless, for new documents it is recommended to instead
use the advanced features described in the previous section.

\begin{Declaration}
  \Macro{deftriplepagestyle}\Parameter{name of the page style}%
                            \OParameter{thickness of the outer line}%
                            \OParameter{thickness of the inner line}%
                            \Parameter{inner head element}%
                            \Parameter{centre head element}%
                            \Parameter{outer head element}%
                            \Parameter{inner foot element}%
                            \Parameter{centre foot element}%
                            \Parameter{outer foot element}%
  \Macro{newtriplepagestyle}\Parameter{name of the page style}%
                            \OParameter{thickness of the outer linen}%
                            \OParameter{thickness of the inner linen}%
                            \Parameter{inner head element}%
                            \Parameter{centre head element}%
                            \Parameter{outer head element}%
                            \Parameter{inner foot element}%
                            \Parameter{centre foot element}%
                            \Parameter{outer foot element}%
  \Macro{renewtriplepagestyle}\Parameter{name of the page style}%
                              \OParameter{thickness of the outer line}%
                              \OParameter{thickness of the inner line}%
                              \Parameter{inner head element}%
                              \Parameter{centre head element}%
                              \Parameter{outer head element}%
                              \Parameter{inner foot element}%
                              \Parameter{centre foot element}%
                              \Parameter{outer foot element}%
  \Macro{providetriplepagestyle}\Parameter{name of the page style}%
                                \OParameter{thickness of the outer line}%
                                \OParameter{thickness of the inner line}%
                                \Parameter{inner head element}%
                                \Parameter{centre head element}%
                                \Parameter{outer head element}%
                                \Parameter{inner foot element}%
                                \Parameter{centre foot element}%
                                \Parameter{outer foot element}
\end{Declaration}
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 stated via 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 note 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!}, 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 as explained for
\KOMAScript{} option \DescRef{scrlayer-scrpage.option.headwidth} (see
\autoref{sec:scrlayer-scrpage.pagestyle.content},
\DescPageRef{scrlayer-scrpage.option.headwidth}) for the optional
arguments.

\hyperref[fig:scrlayer-scrpage.triplepagestyle]%
{Figure~\ref*{fig:scrlayer-scrpage.triplepagestyle}} shows a sketch for the
interpretation of the arguments on a 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}

Using the described commands it is not possible to draw only a single line,
e.\,g., only below the page head but not above the page footer.  If you need
to do so, please consult the previous or following section.

The length of a single element\textnote{Attention!} is not limited by the
existence of a neighbour element. So in unfortunate 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 usage. 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} simply does nothing, but
\Macro{newtriplepagestyle} throws an error. Command
\Macro{renewtriplepagestyle} is something like the opposite of
\Macro{newtriplepagestyle}. It throws 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} corresponds 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.%
\EndIndexGroup


\section{Definition of Complex Page Styles}
\seclabel{pagestyle.experts}

Beside predefined page styles, the definition of new pairs of page styles and
the deprecated definition of page styles with tripartite head and foot, the
package \Package{scrlayer-scrpage} additionally provides 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.
As all most all imaginable use cases of page styles can handled using the
features described previous section, less advanced users may skip this
section.

\begin{Declaration}
  \Macro{defpagestyle}%
  \Parameter{name}\Parameter{head specification}\Parameter{foot specification}%
  \Macro{newpagestyle}%
  \Parameter{name}\Parameter{head specification}\Parameter{foot specification}%
  \Macro{providepagestyle}%
  \Parameter{name}\Parameter{head specification}\Parameter{foot specification}%
  \Macro{renewpagestyle}%
  \Parameter{name}\Parameter{head specification}\Parameter{foot specification}%
\end{Declaration}
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 specification} and \PName{foot specification} have
identical structure:
\begin{quote}\raggedright
  \texttt{%
    (\PName{length of the line above},\PName{thickness of the line above})\%\\
    \Parameter{specification for the left page in two-side layout}\%\\
    \Parameter{specification for the right page in two-side layout}\%\\
    \Parameter{specification for all pages in one-side laypout}\%\\
    (\PName{length of the line below},\PName{thickness of the line below})%
  }
\end{quote}
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
\DescRef{scrlayer-scrpage.option.headtopline},
\DescRef{scrlayer-scrpage.option.headsepline},
\DescRef{scrlayer-scrpage.option.footsepline} or
\DescRef{scrlayer-scrpage.option.footbotline} (see
\autoref{sec:scrlayer-scrpage.pagestyle.content},
\DescPageRef{scrlayer-scrpage.option.headtopline}).

All three arguments in the curly brackets are mandatory. They hold arbitrary
content specifications depending on the page and the layout settings. But for
page styles with running heads usage of
\DescRef{scrlayer-scrpage.cmd.headmark},
\DescRef{scrlayer-scrpage.cmd.leftmark}, or
\DescRef{scrlayer-scrpage.cmd.rightmark} is recommended inside the
specification. Section numbers or section headings must not be used in the
specifications. Due to the asynchronous page building of \LaTeX, using them
could result in wrong numbers or texts in the page header or footer.

Command \Macro{defpagestyle} defines the page style no matter if 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 contrast to this,
\Macro{providepagestyle} simple does nothing in such a case. In contrast to
\Macro{newpagestyle} command \Macro{renewpagestyle} throws an 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 are based on the command
\DescRef{scrlayer.cmd.DeclarePageStyleByLayers}\IndexCmd{DeclarePageStyleByLayers} of package
\Package{scrlayer}. \hyperref[tab:scrlayer-scrpage-experts.layersperstyle]{Table~\ref*{tab:scrlayer-scrpage-experts.layersperstyle}}
shows the layers that are defined for a page style \PName{name}. More
information about layers and layer page styles can be found starting on
\autopageref{cha:scrlayer} in \autoref{cha:scrlayer} of
\autoref{part:forExperts}.%

\begin{table}
%  \KOMAoptions{captions=topbeside}
%  \setcapindent{0pt}
%  \begin{captionbeside}
  \caption
    [{The layers \Package{scrlayer-scrpage} defines to a page style}]
    {The layers \Package{scrlayer-scrpage} defines to a page style
      \PName{name}%
      \label{tab:scrlayer-scrpage-experts.layersperstyle}}
%    [l]
    \begin{tabular}{ll}
      \toprule
      Name of the layer & Meaning of the layer \\
      \midrule
      \PName{Name}\PValue{.head.above.line} 
        & horizontal line above the page head\\
      \PName{Name}\PValue{.head.odd} 
        & page head of odd pages in two-side layout\\
      \PName{Name}\PValue{.head.even}
        & page head of even pages in two-side layout\\
      \PName{Name}\PValue{.head.oneside} 
        & page head in single-side layout\\
      \PName{Name}\PValue{.head.below.line} 
        & horizontal line below the page head\\
      \PName{Name}\PValue{.foot.above.line} 
        & horizontal line above the page foot\\
      \PName{Name}\PValue{.foot.odd} 
        & page foot of odd pages in two-side layout\\
      \PName{Name}\PValue{.foot.even} 
         & page foot of even pages in two-side layout\\
     \PName{Name}\PValue{.foot.oneside} 
        & page foot in single-side layout\\
      \PName{Name}\PValue{.foot.below.line}
        & horizontal line below the page foot\\
      \bottomrule
    \end{tabular}
%  \end{captionbeside}
\end{table}

\begin{Example}
  Assume you want to colour the whole background of page style
  \PageStyle{scrheadings}' head. 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.

  In this example the coloured background is printed using a \Macro{rule}
  command. The size arguments of this \Macro{rule} are given by
  \DescRef{scrlayer.cmd.layerwidth} and \DescRef{scrlayer.cmd.layerheight}
  which contain the current width and height of the layer itself. The optional
  argument of \Macro{rule} is used to move the rule down by the height of a
  descender.
\end{Example}
%
Instead of using new layers to colour the background in the example above,
\Macro{colorbox} and \DescRef{scrlayer-scrpage.cmd.chead} could have been
used. It is recommended to build such a solution as an exercise. Another
approach could be to add the background layers one by one and just before the
contents layers. You may do this as an exercise too.%
\EndIndexGroup


\begin{Declaration}
  \KOption{hmode}\PValue{simple switch}
\end{Declaration}
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} gain compatibility to
\Package{scrpage2} in this
aspect. But this would have side effects, i.\,e., white
spaces at the start of the output or the vertical alignment of the output.

The options allows for the standard values for simple switches that are given
at \autoref{tab:truefalseswitch} on \autopageref{tab:truefalseswitch}. The
option is deactivated by default.%
\EndIndexGroup
%
\EndIndexGroup

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