% ======================================================================
% common-21.tex
% Copyright (c) Markus Kohm, 2013-2015
%
% 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.
% ----------------------------------------------------------------------
% common-21.tex
% Copyright (c) Markus Kohm, 2013-2015
%
% 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.
% ======================================================================
%
% Text that is common for several chapters of the KOMA-Script guide
% Maintained by Markus Kohm
%
% ----------------------------------------------------------------------
%
% Absaetze, die mehreren Kapitels in der KOMA-Script-Anleitung gemeinsam sind
% Verwaltet von Markus Kohm
%
% ============================================================================

\KOMAProvidesFile{common-21.tex}
                 [$Date: 2013-10-22 11:17:09 +0200 (Di, 22 Okt 2013) $
                  KOMA-Script guide (common paragraph: 
                                     Manipulation of defined page styles)]
\translator{Markus Kohm\and Jana Schubert}

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

\makeatletter
\@ifundefined{ifCommonscrlayer}{\newif\ifCommonscrlayer}{}%
\@ifundefined{ifCommonscrlayerscrpage}{\newif\ifCommonscrlayerscrpage}{}%
\@ifundefined{ifCommonscrlayerscrpageexperts}{\newif\ifCommonscrlayerscrpageexperts}{}
\@ifundefined{ifIgnoreThis}{\newif\ifIgnoreThis}{}%
\makeatother

\section{Manipulation of Defined Page Styles}
\seclabel{pagestyle.content}

\IfCommon{scrlayer}{%
  Even though \Package{scrlayer} itself does not define a concrete page style
  with content\,---\,the already mentioned page styles \Pagestyle{@everystyle@}
  and \Pagestyle{empty} are initially defined without any level and so empty
  and without content\,---\,, it provides some options and commands for the
  manipulation of the contents.%
}

\IfCommon{scrlayer-scrpage}{%
  \hyperref[sec:scrlayer-scrpage.predefined.pagestyles]%
  {Section~\ref*{sec:scrlayer-scrpage.predefined.pagestyles}}
  states the predefined defaults for the page style \Pagestyle{scrheadings}
  and \Pagestyle{plain.scrheadings} and how they can be adapted.  But
  information about the generation of, i.\,e., the running heads, the
  manipulation of the widths of page head and footer, and how you can get
  horizontal lines printed above or below the page head or footer are still
  missing. Even though all these are features of package \Package{scrlayer},
  they will be described consecutively, because these basic features of
  \Package{scrlayer} are also a fundamental part of the features of
  \Package{scrlayer-scrpage}.%
}

\IfCommon{scrlayer-scrpage-expert}{%
  This section is an add-on to \autoref{sec:scrlayer.pagestyle.content}. It
  describes features that may be to complicated for beginners.%
}

\ifCommonscrlayerscrpageexperts\else % ------- nicht scrlayer-scrpage-experts -
\ifshortversion\IgnoreThistrue\IfCommon{scrlayer-scrpage}{\IgnoreThisfalse}\fi
\ifIgnoreThis %++++++++++++++++++++++++++++++++++++++ nicht scrlayer-scrpage +
\else %------------------------------------------------ nur scrlayer-scrpage -

\begin{Declaration}
  \Macro{automark}\OParameter{section level of the right mark}%
                  \Parameter{section level of the left mark}\\
  \Macro{automark*}\OParameter{section level of the right mark}%
                  \Parameter{section level of the left mark}\\
  \Macro{manualmark}\\
  \Option{automark}\\
  \KOption{autooneside}\PName{simple switch}\\
  \Option{manualmark}
\end{Declaration}
\BeginIndex{Cmd}{automark}%
\BeginIndex{Cmd}{manualmark}%
\BeginIndex{Option}{automark}%
\BeginIndex{Option}{manualmark}%
\BeginIndex{Option}{autooneside~=\PName{simple switch}}%
\IfCommon{scrlayer-scrpage}{%
  \begin{Explain}
    With the \LaTeX{} standard classes or the \KOMAScript{} classes the
    decision whether using automatic running heads\Index{running
      heads>automatic}, or static or manual running heads\Index{running
      heads>static}\Index{running heads>manual} would be done using either
    page style \Pagestyle{headings} or \Pagestyle{myheadings}. Automatic
    running heads are replications of a significant, characterizing text
    snippet of the page mostly inside the page head, sometimes in the page
    footer.

    The article classes\OnlyAt{\Class{article}\and \Class{scrartcl}}
    \Class{article} or \Class{scrartcl} with page style
    \Pagestyle{headings}\IndexPagestyle{headings} use the section heading,
    which is either the mandatory or the optional argument of \Macro{section},
    for the automatic running head of single side documents. Double side
    documents use this section heading as the \emph{left mark} and at once use
    the subsection heading as the \emph{right mark}. The left mark will be
    printed on left pages, which founds the name \emph{left mark}. The right
    mark will be printed on right\,---\,in single side mode this means
    every\,---\,page. The classes by default also remove the right mark
    whenever they put the section heading into the left mark.

    The report and book classes \OnlyAt{\Class{report}\and
      \Class{scrreprt}\and \Class{book}\and \Class{scrbook}} start one level
    higher. So they use the chapter heading to be the right mark in single
    side layout. In double side layout they use the chapter heading to be the
    left mark and the section heading to be the right mark.

    If you are using \Pagestyle{myheadings} instead of
    \Pagestyle{headings}\IndexPagestyle{myheadings}, the marks in the page
    header still exists and would be printed same like using
    \Pagestyle{headings}. But section commands will not automatically set the
    marks any longer. So you can fill them only using the commands
    \Macro{markright}, \Macro{markleft}, and \Macro{markboth}, which will be
    described later in this section.
  \end{Explain}\par
}
\IfNotCommon{scrlayer-scrpage}{In common classes the decision for a page
  style\,---\,generally \Pagestyle{headings} and
  \Pagestyle{myheading}\,---\,is also a decision to use either automatic or
  manual running heads.}
This difference between those two page styles has been abolished by
\Package{scrpage2} and also by \Package{scrlayer}. Instead of distinguishing
between automatic and manual running head by the selection of a page style,
two new commands, \Macro{automark} and \Macro{manualmark}, are provided. 

The command \Macro{manualmark} switches to manual marks and deactivates the
automatic filling of the marks. In contrast to this \Macro{automark} and
\Macro{automark*} can be used to define, which section levels should be used
for the automatic mark filling. The optional argument is the \PName{section
  level of the right mark}, the mandatory argument the \PName{section level of
  the left mark}. The arguments always should be the name of a section level
like \PValue{part}, \PValue{chapter}, \PValue{section}, \PValue{subsection},
\PValue{subsubsection}, \PValue{paragraph}, or \PValue{subparagraph}.

Generally the higher level should be used for the left mark and the lower
level for the right mark. This is only a convention and not a need, but it
makes sense.

The difference in \Macro{automark} and \Macro{automark*} is, that
\Macro{automark} deletes all prior usages of \Macro{automark} or
\Macro{automark*}, while \Macro{automark*} changes only the behaviour of the
section levels of its arguments. So you can even build more complex cases.

\ifCommonscrlayerscrpage% +++++++++++++++++++++++++++ nur scrlayer-scrpage +
\begin{Example}
  Assume you want the chapter heading to be the running head of even pages
  and the section heading to be the running head of odd pages like this is
  usual for books. But on odd pages you also want the chapter headings as a
  running head as long as the first section appears. To do so, you first have
  to load \Package{scrlayer-scrpage} and select page style
  \Pagestyle{scrheadings}. So you're document starts with:
\begin{lstcode}
  \documentclass{scrbook}
  \usepackage{scrlayer-scrpage}
  \pagestyle{scrheadings}
\end{lstcode}
  Next you will setup the chapter heading to be not only the left but also the
  right mark:
\begin{lstcode}
  \automark[chapter]{chapter}
\end{lstcode}
  Then the section heading should also become a right mark:
\begin{lstcode}
   \automark*[section]{}
\end{lstcode}
  Here the star version is used, because the prior \Macro{automark} command
  should be still valid. Additionally the mandatory argument for the
  \PName{section level of the left mark} is empty, because this mark should be
  unchanged.

  Now you just need some document contents to see a result:
\begin{lstcode}
  \usepackage{lipsum}
  \begin{document}
  \chapter{Chapter Heading}
  \lipsum[1-20]
  \section{Section Heading}
  \lipsum[21-40]
  \end{document}
\end{lstcode}
  We once again use package \Package{lipsum}\IndexPackage{lipsum} to generate
  some dummy text with command \Macro{lipsum}\IndexCmd{lipsum}. The package is
  really useful.

  If you'd test the example, you'd see, that the chapter start page does not
  have a running head as usual. This is, because it automatically uses the
  \Pagestyle{plain} page style \Pagestyle{plain.scrheadings}. Pages~2--4 have
  the chapter headings in the running head. After the section heading on
  page~4 the running head of page~5 changes into this section heading. From
  this page to the end the running head alternates between chapter and section
  heading from page to page.
\end{Example}
\fi % ******************************************** Ende nur scrlayer-scrpage *

Instead of the commands you may also use the options \Option{manualmark} and
\Option{automark} to switch between manual and automatic running
heads. Thereby \Option{automark} always uses the default
\begin{lstcode}[belowskip=\dp\strutbox]
  \automark[section]{chapter}
\end{lstcode}
for classes with \Macro{chapter} and
\begin{lstcode}[belowskip=\dp\strutbox]
  \automark[subsection]{section}
\end{lstcode}
for classes without \Macro{chapter}.

But normally in single side mode you do not want that the lower level
influences the right mark, you want the higher level, that
will fill only the left mark in double side layout, to be the running head of
all pages. The default option \Option{autooneside} corresponds to this
behaviour. The option understands the values for simple switches, that can be
found in  \autoref{tab:truefalseswitch} on
\autopageref{tab:truefalseswitch}. If you'd deactivate the option, in single
side layout the optional and the obligatory arguments of \Macro{automark} and
\Macro{automark*} will influence the running head again.%
\ifCommonscrlayerscrpage% +++++++++++++++++++++++++++++ nur scrlayer-scrpage +
\begin{Example}
  Assume you have a single sided report but want similar running heads as in
  the book example before. The chapter headings should be used as a running
  head as long as the first section appears. From the first section on, the
  section heading should be used. So we modify the previous example a little
  bit:
\begin{lstcode}
  \documentclass{scrreprt}
  \usepackage[autooneside=false]{scrlayer-scrpage}
  \pagestyle{scrheadings}
  \automark[section]{chapter}
  \usepackage{lipsum}
  \begin{document}
  \chapter{Chapter Heading}
  \lipsum[1-20]
  \section{Section Heading}
  \lipsum[21-40]
  \end{document}
\end{lstcode}
  You can see, that we do not need a \Macro{automark*} command in this
  case. Please try the example also with \Option{autooneside} set to
  \PValue{true} or remove the option and its value. You should find a
  difference at the running head in the pages' head from page~4 on.
\end{Example}
\fi% ********************************************* Ende nur scrlayer-scrpage *

Please note\textnote{Attention!}, only loading the package does not have
any effect on the fact whether automatic or manual running heads are used or
what kind of section headings do fill up the marks. Only using an explicit
option \Option{automark} or \Option{manualmark} or one of the commands
\Macro{automark} or \Macro{manualmark} can reach a well defined state.%
\EndIndex{Option}{autooneside~=\PName{simple switch}}%
\EndIndex{Option}{manualmark}%
\EndIndex{Option}{automark}%
\EndIndex{Cmd}{manualmark}%
\EndIndex{Cmd}{automark}%
\fi % ******************************************** End only scrlayer-scrpage *

\ifshortversion\IgnoreThistrue\IfCommon{scrlayer}{\IgnoreThisfalse}\fi
\ifIgnoreThis %++++++++++++++++++++++++++++++++++++++++++++++++ not scrlayer +
\else %------------------------------------------------------- only scrlayer -

\begin{Declaration}
  \KOption{draft}\PName{simple switch}
\end{Declaration}
\BeginIndex{Option}{draft~=\PName{simple switch}}%
This \KOMAScript{} option understands the values for simple switches, that are
shown in \autoref{tab:truefalseswitch} on \autopageref{tab:truefalseswitch}. If
the option is active, all elements of the page styles will also show dimension
lines. This might be useful while draft editing. If the option has been set as
a global option (see the optional argument of \Macro{documentclass}), but you
do not want the dimension lines, you can deactivate them for the package only
using \OptionValue{draft}{false} as an optional argument of \Macro{usepackage}
while loading the package.%
\EndIndex{Option}{draft~=\PName{Ein-Aus-Wert}}%

\begin{Declaration}
  \Macro{MakeMarkcase}\Parameter{string}
\end{Declaration}
\BeginIndex{Cmd}{MakeMarkcase}%
The automatic running head and only this uses \Macro{MakeMarkcase} for its
output. If the command has not been defined, e.\,g., by the class, while
loading \Package{scrlayer}, it would be defined with the default of outputting
the argument \PName{string} without changes. But the default can be change
either redefining \Macro{MakeMarkcase} or using option \Option{markcase}, that
\ifshortversion has been described in
\autoref{sec:scrlayer-scrpage.pagestyle.content}%
\else will be described next%
\fi%
. Depending on the setting the argument could, e.\,g., be converted into upper
or lower cases.
%
\EndIndex{Cmd}{MakeMarkcase}%
\fi %***************************************************** End only scrlayer *

\ifshortversion\IgnoreThistrue\IfCommon{scrlayer-scrpage}{\IgnoreThisfalse}\fi
\ifIgnoreThis %++++++++++++++++++++++++++++++++++++++++ not scrlayer-scrpage +
\else %----------------------------------------------- only scrlayer-scrpage -
\begin{Declaration}
  \KOption{markcase}\PName{Wert}
\end{Declaration}
\BeginIndex{Option}{markcase~=\PName{Wert}}%
As already mentioned with \Package{scrlayer} you may switch between manual and
automatic running heads. Using automatic running heads the corresponding marks
will be filled by the section heading commands. Some culture areas do convert
the running heads into upper case letters in opposite to the German
typographic habit. The \LaTeX{} standard classes do so by default. Package
\Package{scrlayer} optionally provides this too. Therefor you'd use option
\OptionValue{markcase}{upper} which results in a redefinition of
\Macro{MakeMarkcase}\IndexCmd[indexmain]{MakeMarkcase}, a command, that is
used by \Package{scrlayer} for automatic running heads.

Unfortunately \LaTeX's command for upper case letter typesetting,
\Macro{MakeUppercase}\IndexCmd{MakeUppercase} results in an very inadequate
typesetting, because it neither uses letter spacing nor does it space
balancing. One reason for this behaviour might be, that a glyph analyzing
would be needed, to incorporate the letter shapes and their combination while
space balancing. Because of this \KOMAScript{} author suggests to abstain from
upper case letter typesetting for running heads. This could be achieved using
\OptionValue{markcase}{used}. Nevertheless, some classes would add
\Macro{MarkUppercase} or even \TeX{} command \Macro{uppercase} into the
running heads. For such cases option \OptionValue{markcase}{noupper} can be
used. This will also deactivate \Macro{MakeUppercase} and \Macro{uppercase}
inside the running heads.

You can find all valid values for \Option{markcase} in
\autoref{tab:scrlayer-scrpage.markcase}\IfNotCommon{scrlayer-scrpage}{,
  \autopageref{tab:scrlayer-scrpage.markcase}}.%
\ifCommonscrlayerscrpage
\begin{table}
  \centering
  \caption[Possible values for option \Option{markcase}]{Possible values for
    option \Option{markcase} to select upper/lower case letter typesetting in
    automatic running heads}%
  \label{tab:scrlayer-scrpage.markcase}%
  \begin{desctabular}
    \pventry{lower}{\IndexOption{markcase~=\PValue{lower}}%
      redefines \Macro{MakeMarkcase} to convert the automatic running heads
      into lower case letters using \Macro{MakeLowercase}
      (lower case typesetting).%
    }%
    \pventry{upper}{\IndexOption{markcase~=\PValue{upper}}%
      redefines \Macro{MakeMarkcase} to convert the automatic running heads
      into upper case letters using \Macro{MakeUppercase}
      (upper case typesetting).%
    }%
    \pventry{used}{\IndexOption{markcase~=\PValue{used}}%
      redefines \Macro{MakeMarkcase} to use automatic running heads without
      any case changes.%
    }%
    \entry{\PValue{ignoreuppercase}, \PValue{nouppercase},
      \PValue{ignoreupper},
      \PValue{noupper}}{\IndexOption{markcase~=\PValue{noupper}}%
      redefines not only \Macro{MakeMarkcase} but also locally to the running
      heads \Macro{MakeUppercase} and \Macro{uppercase} to leave the automatic
      running heads unchanged.%
    }%
  \end{desctabular}
\end{table}
\fi
\EndIndex{Option}{markcase~=\PName{Wert}}%

\begin{Declaration}
  \Macro{leftmark}\\
  \Macro{rightmark}\\
  \Macro{headmark}\\
  \Macro{pagemark}
\end{Declaration}
\BeginIndex{Cmd}{leftmark}%
\BeginIndex{Cmd}{rightmark}%
\BeginIndex{Cmd}{headmark}%
\BeginIndex{Cmd}{pagemark}%
If you want to differ from the predefined page styles, usually you need to
decide, where to place the marks' contents. With \Macro{leftmark} you can state
the contents of the left mark.

Similar you can use \Macro{rightmark} to state the contents of the right
mark. For more information about some intricacies of this see the further
description of \Macro{rightmark} in \autoref{sec:maincls-experts.addInfos},
\autopageref{desc:maincls-experts.cmd.rightmark}.

Somehow easier would be usage of \Macro{headmark}. This extension of
\Package{scrlayer} aliases either \Macro{leftmark} or \Macro{rightmark}
depending on whether the current page is even or odd.

Strictly thought command \Macro{pagemark} is not involved by \TeX's mark
mechanism. It is only used to output a formatted page number.
\BeginIndex{FontElement}{pagenumber}%
The font of element
\FontElement{pagenumber}\important{\FontElement{pagenumber}} will be used for
the output. This can be changed using command \Macro{setkomafont} or
\Macro{addtokomafont} (see also \autoref{sec:maincls.textmarkup},
\autopageref{desc:maincls.cmd.setkomafont}).%
\EndIndex{FontElement}{pagenumber}%
\ifCommonscrlayerscrpage% +++++++++++++++++++++++++++++ nur scrlayer-scrpage +
\begin{Example}
  Assume\label{example.scrlayer-scrpage.headmark} you want to use a left
  aligned running head and right aligned page
  number in the head of the pages of a document in single side layout. The
  following minimal but working examples would do so:
\begin{lstcode}
  \documentclass{scrreprt}
  \usepackage{blindtext}
  \usepackage[automark]{scrlayer-scrpage}
  \pagestyle{scrheadings}
  \ihead{\headmark}
  \ohead[\pagemark]{\pagemark}
  \chead{}
  \cfoot[]{}
  \begin{document}
  \blinddocument
  \end{document}
\end{lstcode}
  Here package \Package{blindtext}\IndexPackage{blindtext} with its command
  \Macro{blinddocument}\IndexCmd{blinddocument} has been used to easily
  generate content for an example document.

  Commands \Macro{ihead} and \Macro{ohead} have been used to place the wanted
  marks. Although the page mark will be place not only to pages in page style
  \Pagestyle{scrheadings} but using the optional argument also to pages in
  page style \Pagestyle{plain.scrheadings}.

  Because of both page styles already have marks in the middle of the page
  head and page foot, those elements will be cleared using \Macro{chead} and
  \Macro{cfoot} with empty arguments. Alternatively you'd use
  \Macro{clearpairofpagestyles} \emph{before} \Macro{ihead}. You will find a
  description of this command in
  \autoref{sec:scrlayer-scrpage-experts.pagestyle.pairs}.
\end{Example}

Please note\textnote{Attention!}, that the empty optional argument of
\Macro{cfoot} in the example above is not the same like omitting the optional
argument. Please try it out and have a look at the difference in the footer of
the first page.%
\else % --------------------------------------------- nicht scrlayer-scrpage -
  \par %
  If you are interested in an example about usage of commands \Macro{headmark}
  and \Macro{pagemark}, have a look into
  \autoref{sec:scrlayer-scrpage.pagestyle.content},
  \autopageref{example.scrlayer-scrpage.headmark}. The package
  \Package{scrlayer-scrpage} internally uses a lot of such features of
  \Package{scrlayer}.%
\fi% ******************************************* Ende nicht scrlayer-scrpage *
\ifnum\currentversionlt{3.16}\else\par
  If all the mark features described above are not sufficient, experienced
  users can find more of them on \IfCommon{scrlayer-scrpage}{%
    \autopageref{desc:scrlayer-scrpage-experts.cmd.righttopmark}}%
  \IfNotCommon{scrlayer-scrpage}{%
    \autopageref{desc:scrlayer.cmd.righttopmark}}. For example, you can find
  there \Macro{leftfirstmark} and \Macro{rightbotmark}, which seem to be
  useful for lexicon like documents.%
\fi
\EndIndex{Cmd}{pagemark}%
\EndIndex{Cmd}{headmark}%
\EndIndex{Cmd}{rightmark}%
\EndIndex{Cmd}{leftmark}%

\begin{Declaration}
  \Macro{partmarkformat}\\
  \Macro{chaptermarkformat}\\
  \Macro{sectionmarkformat}\\
  \Macro{subsectionmarkformat}\\
  \Macro{subsubsectionmarkformat}\\
  \Macro{paragraphmarkformat}\\
  \Macro{subparagraphmarkformat}
\end{Declaration}
\BeginIndex{Cmd}{partmarkformat}%
\BeginIndex{Cmd}{chaptermarkformat}%
\BeginIndex{Cmd}{sectionmarkformat}%
\BeginIndex{Cmd}{subsectionmarkformat}%
\BeginIndex{Cmd}{subsubsectionmarkformat}%
\BeginIndex{Cmd}{paragraphmarkformat}%
\BeginIndex{Cmd}{subparagraphmarkformat}%
Usually the \KOMAScript{} classes and package \Package{scrlayer} use these
commands internally to bring the section numbers into wanted form and
additionally they support the \Macro{autodot} mechanism of the \KOMAScript{}
classes. If wanted these commands may be redefined to get another form of
section numbers.%
\ifCommonscrlayerscrpage% ++++++++++++++++++++++++++++ nur scrlayer-scrpage +
\begin{Example}
  Assume you do not want section numbers but section heading text only in the
  running head. So:
\begin{lstcode}
  \renewcommand*{\sectionmarkformat}{}
\end{lstcode}
  would be a simple solution for this.
\end{Example}
\else % -------------------------------------------- nicht scrlayer-scrpage -
  \ See the example in
  \autoref{sec:scrlayer-scrpage.pagestyle.content},
  \autopageref{example:scrlayer-scrpage.sectionmarkformat} for more
  information.%
\fi % ***************************************** Ende nicht scrlayer-scrpage *
%
\EndIndex{Cmd}{subparagraphmarkformat}%
\EndIndex{Cmd}{paragraphmarkformat}%
\EndIndex{Cmd}{subsubsectionmarkformat}%
\EndIndex{Cmd}{subsectionmarkformat}%
\EndIndex{Cmd}{sectionmarkformat}%
\EndIndex{Cmd}{chaptermarkformat}%
\EndIndex{Cmd}{partmarkformat}%

\begin{Declaration}
  \Macro{partmark}\Parameter{Text}\\
  \Macro{chaptermark}\Parameter{Text}\\
  \Macro{sectionmark}\Parameter{Text}\\
  \Macro{subsectionmark}\Parameter{Text}\\
  \Macro{subsubsectionmark}\Parameter{Text}\\
  \Macro{paragraphmark}\Parameter{Text}\\
  \Macro{subparagraphmark}\Parameter{Text}
\end{Declaration}
\BeginIndex{Cmd}{partmark}%
\BeginIndex{Cmd}{chaptermark}%
\BeginIndex{Cmd}{sectionmark}%
\BeginIndex{Cmd}{subsectionmark}%
\BeginIndex{Cmd}{subsubsectionmark}%
\BeginIndex{Cmd}{paragraphmark}%
\BeginIndex{Cmd}{subparagraphmark}%
Most classes use these commands to setup marks corresponding to the
section commands. Thereby the only argument is the text without the number of
the section heading, that should be used for the running head. For the number
simply the number of the current section level will be used, if the current
level uses numbers.

If users redefine these commands, they should\textnote{Attention!} take care
to also use the counter \Counter{secnumdepth} for the test whether or not the
section level should output a number, even in the case the user
does not change counter \Counter{secnumdepth} himself, because packages and
classes may do so locally and rely on correct handling of
\Counter{secnumdepth}.

However, package \Package{scrlayer} redefines these commands whenever you use
\Macro{automark} or \Macro{manualmark} or the corresponding options, to
activate or deactivate the wanted running heads.%
%
\EndIndex{Cmd}{subparagraphmark}%
\EndIndex{Cmd}{paragraphmark}%
\EndIndex{Cmd}{subsubsectionmark}%
\EndIndex{Cmd}{subsectionmark}%
\EndIndex{Cmd}{sectionmark}%
\EndIndex{Cmd}{chaptermark}%
\EndIndex{Cmd}{partmark}%

\begin{Declaration}
  \Macro{markleft}\Parameter{left mark}\\
  \Macro{markright}\Parameter{right mark}\\
  \Macro{markboth}\Parameter{left mark}\Parameter{right mark}
\end{Declaration}
\BeginIndex{Cmd}{markleft}%
\BeginIndex{Cmd}{markright}%
\BeginIndex{Cmd}{markboth}%
Independent of whether currently manual or automatic running heads are active,
you may change the contents of the \PName{left mark} or the \PName{right mark}
at any time using these commands. You should note, that the resulting contents
of \Macro{leftmark}\IndexCmd{leftmark} is the \PName{left
  mark} of the last \Macro{markleft} or \Macro{markboth} command of the
current page. In opposite to this the resulting contents of
\Macro{rightmark}\IndexCmd{rightmark} is the \PName{right mark} of the first
\Macro{rightmark} or \Macro{markboth} command of the current page.

If you are using manual running heads, the marks will stay valid until one of
the corresponding commands will be used again. If you are using automatic
running heads the marks can loose their validity with the next section heading
depending on the configuration of the automatism.

You may also use these commands together with the star versions of the section
commands.%
\ifCommonscrlayerscrpage % +++++++++++++++++++++++++++++ nur scrlayer-scrpage +
\begin{Example}
  Assume you are using a preface with several pages just before the table of
  contents, that should not have an entry at the table of contents
  itself. Because of using a separation line at the page head, you want also a
  running head for this preface:
\begin{lstcode}
  \documentclass[headsepline]{book}
  \usepackage{scrlayer-scrpage}
  \pagestyle{scrheadings}
  \usepackage{blindtext}
  \begin{document}
  \chapter*{Preface}
  \markboth{Preface}{Preface}
  \blindtext[20]
  \tableofcontents
  \blinddocument
  \end{document}
\end{lstcode}
  First of all this seems to produce the wanted result. But have a closer
  look: In difference to the other running heads ``\texttt{Preface}'' is not in
  upper case letters. But you can fix this easily:
\begin{lstcode}
  \documentclass[headsepline]{book}
  \usepackage{scrlayer-scrpage}
  \pagestyle{scrheadings}
  \usepackage{blindtext}
  \begin{document}
  \chapter*{Preface}
  \markboth{\MakeMarkcase{Preface}}{\MakeMarkcase{Preface}}
  \blindtext[20]
  \tableofcontents
  \blinddocument
  \end{document}
\end{lstcode}
  Using command \Macro{MakeMarkcase} results in getting the same letter case
  as for automatic running heads.

  Now, let's move command \Macro{tableofcontents} in front of the
  preface. Let's remove the \Macro{markboth} command too. You'll realise, that
  the preface now has the running head ``\texttt{CONTENTS}''. This is because
  of a quirk of \Macro{chapter*} (see also \autoref{sec:maincls.structure} on
  \autopageref{desc:maincls.cmd.chapter*}). If in such cases the running head
  should be removed, \Macro{markboth} with two empty arguments would be
  useful:
\begin{lstcode}
  \documentclass[headsepline]{book}
  \usepackage{scrlayer-scrpage}
  \pagestyle{scrheadings}
  \usepackage{blindtext}
  \begin{document}
  \tableofcontents
  \chapter*{Preface}
  \markboth{}{}
  \blindtext[20]
  \blinddocument
  \end{document}
\end{lstcode}
\end{Example}
\else % -------------------------------------------- nicht scrlayer-scrpage -
  \ You can find a detailed example about usage of \Macro{markboth} with
  \Package{scrlayer-scrpage} in
  \autoref{sec:scrlayer-scrpage.pagestyle.content},
  \autopageref{example:scrlayer-scrpage.markboth}. Package
  \Package{scrlayer-scrpage} is a kind of extension of \Package{scrlayer}.%
\fi % ***************************************** Ende nicht scrlayer-scrpage *
%
\EndIndex{Cmd}{markboth}%
\EndIndex{Cmd}{markright}%
\EndIndex{Cmd}{markleft}%

\fi %********************************************* End only scrlayer-scrpage *
\fi %*********************************** Ende nicht scrlayer-scrpage-experts *


\ifshortversion\IgnoreThisfalse\IfCommon{scrlayer-scrpage}{\IgnoreThistrue}\fi
\ifIgnoreThis %+++++++++++++++++++++++++++++++++++++++ auch scrlayer-scrpage +
\else %---------------------------------------------- nicht scrlayer-scrpage -
\ifCommonscrlayerscrpage\else %---------------------- nicht scrlayer-scrpage -
\begin{Declaration}
  \Macro{GenericMarkFormat}\Parameter{name of the section level}
\end{Declaration}
\BeginIndex{Cmd}{GenericMarkFormat}%
At the running head this command will be used by default for the formatting of
all section numbers below the subsection and with classes without
\Macro{chapter} also for the section level and the subsection level, if the
mark commands for those numbers have not been defined before loading
\Package{scrlayer}. Thereby the package uses \Macro{@seccntmarkformat} if such
a command has been defined, like the \KOMAScript{} classes do. Otherwise
\Macro{@seccntformat} will be used, which is provided by the \LaTeX{}
kernel. The expected, mandatory argument of the command is the \PName{name of
  a section level}, i.\,e., \PValue{chapter} or \PValue{section}
\emph{without} the backslash prefix.

You can change the default formatting of the numbers, that use this command,
by redefining only this single command. Classes can change the default
formatting also by defining this command.%
\ifCommonscrlayerscrpageexperts % ++++++++++++ nur scrlayer-scrpage-experts +
\begin{Example}
  Assume\label{example:scrlayer-scrpage-experts.GenericMarkFormat}
  you want the section numbers of all levels at the running head of
  an article to be printed in white colour inside a black coloured box. Using
  standard \LaTeX{} \Class{article} class, package \Package{scrlayer} defines
  the number mark commands \Macro{sectionmarkformat} and
  \Macro{subsectionmarkformat} using \Macro{GenericMarkFormat}. So you need to
  redefine only this single command:
\begin{lstcode}
  \documentclass{article}
  \usepackage{blindtext}
  \usepackage[automark]{scrlayer-scrpage}
  \pagestyle{scrheadings}
  \usepackage{xcolor}
  \newcommand*{\numberbox}[1]{%
    \colorbox{black}{\strut~\textcolor{white}{#1}~}}
  \renewcommand*{\GenericMarkFormat}[1]{%
    \protect\numberbox{\csname the#1\endcsname}\enskip}
  \begin{document}
  \blinddocument
  \end{document}
\end{lstcode}
  The colour has been done using package
  \Package{xcolor}\IndexPackage{xcolor}. See the package manual for more
  information about this. Additionally a not visible strut has been
  used. Every complete \LaTeX{} introduction should explain the related
  command \Macro{strut}. A helper macro \Macro{numberbox} has been defined for
  the formatting of the number within a box. In the redefinition of
  \Macro{GenericMarkFormat} this has been prefixed by
  \Macro{protect} to protect it from expansion. This is necessary because
  otherwise the upper case letter conversion of \Macro{MakeUppercase} that
  will be used for the running head, would result in an ask for colours
  ``\texttt{BLACK}'' and ``\texttt{WHITE}'' instead of ``\texttt{black}'' and
  ``\texttt{white}'' and those colours are undefined. Alternatively you may
  define \Macro{numberbox} using \Macro{DeclareRobustCommand*} instead of
  \Macro{newcommand*} and then omit \Macro{protect} (see
  \cite{latex:clsguide}).

  If you'd do the same with a \KOMAScript{} class or with one of the \LaTeX{}
  standard classes \Class{book} or \Class{report}, you'd additionally have to
  redefine \Macro{sectionmarkformat} and \Macro{subsectionmarkformat}
  respectively \Macro{chaptermarkformat} and \Macro{sectionmarkformat} too,
  because then these would not have been defined using
  \Macro{GenericMarkFormat}:
\begin{lstcode}
  \documentclass{scrbook}
  \usepackage{blindtext}
  \usepackage[automark]{scrlayer-scrpage}
  \pagestyle{scrheadings}
  \usepackage{xcolor}
  \newcommand*{\numberbox}[1]{%
    \colorbox{black}{\strut~\textcolor{white}{#1}~}}
  \renewcommand*{\GenericMarkFormat}[1]{%
    \protect\numberbox{\csname the#1\endcsname}\enskip}
  \renewcommand*{\chaptermarkformat}{\GenericMarkFormat{chapter}}
  \renewcommand*{\sectionmarkformat}{\GenericMarkFormat{section}}
  \begin{document}
  \blinddocument
  \end{document}
\end{lstcode}
\end{Example}
\else % ------------------------------------- nicht scrlayer-scrpage-experts -
  \par %
  A detailed example about cooperation of command \Macro{GenericMarkFormat}
  and the commands \Macro{sectionmarkformat} and \Macro{subsectionmarkformat}
  that are described at \autopageref{desc:\csname
    label@base\endcsname.cmd.chaptermark} is shown in
  \autoref{sec:scrlayer-scrpage-experts.pagestyle.content},
  \autopageref{example:scrlayer-scrpage-experts.GenericMarkFormat}.%
\fi % ********************************** Ende nicht scrlayer-scrpage-experts *
%
\EndIndex{Cmd}{GenericMarkFormat}%

\ifnum\currentversionlt{3.16}\else
\begin{Declaration}
  \Macro{righttopmark}\\
  \Macro{rightbotmark}\\
  \Macro{rightfirstmark}\\
  \Macro{lefttopmark}\\
  \Macro{leftbotmark}\\
  \Macro{leftfirstmark}
\end{Declaration}
\BeginIndex{Cmd}{righttopmark}%
\BeginIndex{Cmd}{rightbotmark}%
\BeginIndex{Cmd}{rightfirstmark}%
\BeginIndex{Cmd}{lefttopmark}%
\BeginIndex{Cmd}{leftbotmark}%
\BeginIndex{Cmd}{leftfirstmark}%
For page styles \LaTeX\ChangedAt{v3.16}{\Package{scrlayer}} uses a bipartite
\TeX{} mark. Running heads can use the left part of that mark by
\Macro{leftmark}\important{\Macro{leftmark}}\IndexCmd{leftmark} and the right
part by
\Macro{rightmark}\important{\Macro{rightmark}}\IndexCmd{rightmark}. Indeed, it
seems that it was suggested to use \Macro{leftmark} for the running head of
left, even pages and \Macro{rightmark} for the running head of right, odd
pages of double-sided documents. Within single-sided layouts the standard
classes even do not set the left part of the mark.

\TeX{} itself knows three alternatives to make usage of a mark. The
\Macro{botmark} is the last valid mark of the page that has been build
last. If there has not been set any mark on the page, it is the last mark of the
already shipped out pages. \LaTeX{} command \Macro{leftmark} uses exactly this
mark. So it shows the left part of the last mark of the page. This is the same
like \Macro{leftbotmark}. In opposite to this \Macro{rightbotmark} shows the
right part of that mark.

\Macro{firstmark} is the first mark of the page that has been build last. This
means the first mark, that has been set on the page. If there has not been set
any mark on the page, this is the last mark of the already shipped out
pages. \LaTeX{} command \Macro{rightmark} uses exaclty this mark. So it shows
the right part of the first mark of the page. This is the same like
\Macro{rightfirstmark}. In opposite to this \Macro{leftfirstmark} shows the
left part of that mark.

\Macro{topmark} is the content of \Macro{botmark} before building the current
page. \LaTeX{} itself does not use it. Nevertheless, \Package{scrlayer}
provides \Macro{lefttopmark} to show the left part of it and
\Macro{righttopmark} to show the right part of it.

Note\textnote{Attention!} that the left part and the right part of the mark
can be made all together only. Even if you use
\Macro{markright}\IndexCmd{markright} to change only the right part, the left
part will be made again (unchanged). Accordingly in double-side mode using
page style
\Pagestyle{headings\important{\Pagestyle{headings}}\IndexPagestyle{headings}}
the higher section levels always make both parts. For example
\Macro{chaptermark} uses \Macro{markboth} with an empty right argument in this
case. This is the reason why \Macro{rightmark} or \Macro{rightfirstmark}
always shows an empty value on pages with chapter beginnings, even if there
was a \Macro{sectionmark} or \Macro{section} on the same page to make the
right part of the mark.

Please note\textnote{Attention!} that using any of these commands to show the
left or right part of the mark as part of the page content could have
unexpected results. They are recommended to be used in the head or foot of a
page style only. So with \Package{scrlayer} they should be part of the
contents of a layer. But it does not matter whether or not a layer is
restricted to the background or the foreground. Both kind of layers are
shipped out after building the current page.

If you need more information about the mark mechanism of \TeX, please have a
look at \cite[chapter~23]{knuth:texbook}. You will find, that marks are an
issue for real experts. So if the explanation above was at least more
confusing than illuminative: Please don't worry.
%
\EndIndex{Cmd}{leftfirstmark}%
\EndIndex{Cmd}{leftbotmark}%
\EndIndex{Cmd}{lefttopmark}%
\EndIndex{Cmd}{rightfirstmark}%
\EndIndex{Cmd}{righttopmark}%
\EndIndex{Cmd}{rightbotmark}%
\fi

\begin{Declaration}
  \Macro{@mkleft}\Parameter{left mark}\\
  \Macro{@mkright}\Parameter{right mark}\\
  \Macro{@mkdouble}\Parameter{mark}\\
  \Macro{@mkboth}\Parameter{left mark}\Parameter{right mark}
\end{Declaration}
\BeginIndex{Cmd}{@mkleft}%
\BeginIndex{Cmd}{@mkright}%
\BeginIndex{Cmd}{@mkdouble}%
\BeginIndex{Cmd}{@mkboth}%
Sometimes inside classes and packages the marks for running heads should be
filled up only if automatic running heads are active (see option
\Option{automark} and command \Macro{automark} on
\autopageref{desc:scrlayer-scrpage.cmd.automark}). In the \LaTeX{} standard
classes only \Macro{@mkboth} has been used for this. This command is either
\Macro{@gobbletwo}, that simply destroys both mandatory arguments, or
\Macro{markboth}, a command that fills up the left and \PValue{left mark} and
the \PValue{right mark}. Packages like \Package{babel} also change
\Macro{\@mkboth}, i.\,e., to add language switching to the running head.

But if a class or package author only wants to change either the \PName{left
  mark} or the \PName{right mark} without the other one, a proper command is
missing. Package \Package{scrlayer} itself needs such commands for the
implementation of all cases of automatic running heads. So if command
\Macro{@mkleft} to fill up only the left mark or \Macro{@mkright} to fill up
only the right mark or \Macro{@mkdouble} to fill up both marks with the same
content is undefined while loading \Package{scrlayer}, the package will define
them. Thereby the actual definition of \Macro{@mkboth} will be used as an
indicator whether or not automatic running heads should be used. The new
commands will full up the marks only in the case of automatic running heads.

Class and package authors can use these commands too, if they want to fill up
only one of the marks or both marks with the same content but only if
automatic running heads are activated. This condition is also the difference
to the commands \Macro{markleft}, \Macro{markright}, and \Macro{markboth}.%
\EndIndex{Cmd}{@mkboth}%
\EndIndex{Cmd}{@mkdouble}%
\EndIndex{Cmd}{@mkright}%
\EndIndex{Cmd}{@mkleft}%

\fi %***************************************************** End only scrlayer *
\fi %***************************************************** End only scrlayer *

\ifshortversion%
\IfCommon{scrlayer}{%
  For more information about manipulation of the contents of page styles see
  also \autoref{sec:scrlayer-scrpage.pagestyle.content} from
  \autopageref{sec:scrlayer-scrpage.pagestyle.content}.%
}%
\fi

%%% Local Variables:
%%% mode: latex
%%% mode: flyspell
%%% coding: iso-latin-1
%%% ispell-local-dictionary: "en_GB"
%%% TeX-master: "../guide.tex"
%%% TeX-PDF-mode: t
%%% End: 
