17.6. Head and Foot Height
You may find basic information about the height of the page header and footer in
section 5.2
,
page 206
.
17.7. Manipulation of Defined Page Styles
Even though scrlayer itself does not define a concrete page style with content — the already
mentioned page styles @everystyle@ and 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.
draft=simple switch
This KOMA-Script option understands the values for simple switches, that are shown in
table 2.5
on
page 38
. 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 \documentclass), but you do not want the
dimension lines, you can deactivate them for the package only using draft=false as an
optional argument of \usepackage while loading the package.
\MakeMarkcase{string }
The automatic running head and only this uses \MakeMarkcase for its output. If the command
has not been defined, e. g., by the class, while loading scrlayer, it would be defined with
the default of outputting the argument string without changes. But the default can be
change either redefining \MakeMarkcase or using option markcase, that has been described
in
section 5.5
. Depending on the setting the argument could, e. g., be converted into upper or
lower cases.
\GenericMarkFormat{name of the section level }
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 \chapter also for the section level and
the subsection level, if the mark commands for those numbers have not been defined before
loading scrlayer. Thereby the package uses \@seccntmarkformat if such a command has been
defined, like the KOMA-Script classes do. Otherwise \@seccntformat will be used, which is
provided by the L
A
TEX kernel. The expected, mandatory argument of the command is the
name of a section level
, i. e., chapter or section 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.
357
Chapter 17.
A detailed example about cooperation of command \GenericMarkFormat and the com-
mands \sectionmarkformat and \subsectionmarkformat that are described at
page 223
is
shown in
section 18.1
,
page 361
.
\righttopmark
\rightbotmark
\rightfirstmark
\lefttopmark
\leftbotmark
\leftfirstmark
For page styles L
A
TEX
v3.16
uses a bipartite TEX mark. Running heads can use the left part of that
mark by \leftmark and the right part by \rightmark. Indeed, it seems that it was suggested
to use \leftmark for the running head of left, even pages and \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 \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. L
A
TEX command \leftmark uses
exactly this mark. So it shows the left part of the last mark of the page. This is the same like
\leftbotmark
. In opposite to this \rightbotmark shows the right part of that mark.
\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. L
A
TEX command \rightmark uses exaclty
this mark. So it shows the right part of the first mark of the page. This is the same like
\rightfirstmark
. In opposite to this \leftfirstmark shows the left part of that mark.
\topmark
is the content of \botmark before building the current page. L
A
TEX itself does
not use it. Nevertheless, scrlayer provides \lefttopmark to show the left part of it and
\righttopmark
to show the right part of it.
Note that the left part and the right part of the mark can be made all together only.
Even if you use \markright to change only the right part, the left part will be made again
(unchanged). Accordingly in double-side mode using page style headings the higher section
levels always make both parts. For example \chaptermark uses \markboth with an empty
right argument in this case. This is the reason why \rightmark or \rightfirstmark always
shows an empty value on pages with chapter beginnings, even if there was a \sectionmark or
\section
on the same page to make the right part of the mark.
Please note 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 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.
358
Chapter 17.
If you need more information about the mark mechanism of TEX, please have a look at
[
Knu90
, chapter 23]. You will find, that marks are an issue for real experts. So if the expla-
nation above was at least more confusing than illuminative: Please don’t worry.
\@mkleft{left mark }
\@mkright{right mark }
\@mkdouble{mark }
\@mkboth{left mark }{right mark }
Sometimes inside classes and packages the marks for running heads should be filled up only
if automatic running heads are active (see option automark and command \automark on
page 218
). In the L
A
TEX standard classes only \@mkboth has been used for this. This command
is either \@gobbletwo, that simply destroys both mandatory arguments, or \markboth, a
command that fills up the left and left mark and the right mark. Packages like babel also
change \mkboth, i. e., to add language switching to the running head.
But if a class or package author only wants to change either the left mark or the right
mark
without the other one, a proper command is missing. Package scrlayer itself needs such
commands for the implementation of all cases of automatic running heads. So if command
\@mkleft
to fill up only the left mark or \@mkright to fill up only the right mark or \@mkdouble
to fill up both marks with the same content is undefined while loading scrlayer, the package will
define them. Thereby the actual definition of \@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 \markleft, \markright, and
\markboth
.
For more information about manipulation of the contents of page styles see also
section 5.5
from
page 218
.
17.8. End User Interfaces
Package scrlayer provides an interface to define and manage (concurrent) end user interfaces.
Maybe future releases of KOMA-Script will provide parts of this by package scrbase and
remove those commands from scrlayer. But currently this part if scrlayer is very experimental,
so package scrlayer provides its own interface definition commands. Currently you should not
depend on correct working of auto-removing a concurrent end user interface. Instead you
should avoid using concurrent end user interfaces.
This section only describes the interface commands for defining end user interfaces. This
is not interesting for end users, but only for authors of end user interfaces. End users will
find information about the end user interfaces in the sections about the particular end user
interface, e.g.,
chapter 5
,
chapter 18
, and
chapter 19
.
359
Chapter 17.
\scrlayerInitInterface[interface name ]
Command \scrlayerInitInterface registers a new interface. The interface name must
be unique. If you try to initialise an already initialised interface an error will occur. This com-
mand is obligatory and mandatory for interfaces. It should be the first interface command and
therefore has been described first. If the optional argument is omitted, \@currname.\@currext
will be used instead. For classes and packages this will be the file name of the class or package
while loading the class or package. But you may use any sequence of characters with category
letter or other.
forceoverwrite=simple switch
autoremoveinterfaces=simple switch
\scrlayerAddToInterface[interface name ]{command }{code }
\scrlayerAddCsToInterface[interface name ]{command sequence }{code }
One of the special features of end user interfaces is that they should register all interface depen-
dent commands (also known as macros). You may do this using \scrlayerAddToInterface.
If your interface generates macros not only at load time but also at run time or if the interface
name should not be the class’s or package’s name, you have to use the optional argument to
add the command to a dedicated interface. An error will occur, if the interface has not been
initialised before.
The first mandatory argument is the command
1
that should be added to the interface. If
the command can be added to the interface, it will be added to the interface, will be set to
\relax
and code will be executed. You can use, e.g., \newcommand command inside of code
to define command .
But when can a command be defined? If a command is undefined or \relax it can be
defined. If a command has already been defined and registered for another interface and if
KOMA-Script option autoremoveinterface has been switched on, the other interface will be
removed automatically and the new command will be set to \relax and will be registered for
the given interface. If a command has already been defined but is not part of another interface
and
if KOMA-Script option forceoverwrite has been switched on, the command will be set
to \relax and will be registered for the given interface.
Command \scrlayerAddCsToInterface is similar to \scrlayerAddToInterface but does
not expect a command as first, mandatory argument, but a command sequence
2
.
\scrlayerOnAutoRemoveInterface[ interface name ]{ code }
Command \scrlayerOnAutoRemoveInterface registers code to be executed, if the inter-
face will be automatically removed (see autoremoveinterfaces prior in this section). This
1
The command consists of the backslash followed by a command sequence consisting of characters with category
code letter or one other character, or command consists of one active character (without backslash).
2
A command sequence may consist of any characters with category code letter or other.
360
Chapter 17.
may be used, e.g., to automatically destroy layers or page styles (see \DestroyLayer,
\DestroyAliasPageStyle
, and \DestroyRealLayerPageStyle).
361
Chapter 18.
Additional Features
v3.12
with package scrlayer-scrpage
Package scrlayer-scrpage provides features that have not been described in
chapter 5
of this
user guide’s
part I
. In general, the average user will not need those extensions and some of
them are only provided for compatibility with scrpage2.
18.1. Manipulation of Defined Page Styles
\GenericMarkFormat{name of the section level }
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 \chapter also for the section level and
the subsection level, if the mark commands for those numbers have not been defined before
loading scrlayer. Thereby the package uses \@seccntmarkformat if such a command has been
defined, like the KOMA-Script classes do. Otherwise \@seccntformat will be used, which is
provided by the L
A
TEX kernel. The expected, mandatory argument of the command is the
name of a section level
, i. e., chapter or section 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.
Example: Assume 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 stan-
dard L
A
TEX article class, package scrlayer defines the number mark commands
\sectionmarkformat
and \subsectionmarkformat using \GenericMarkFormat.
So you need to redefine only this single command:
\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}
The colour has been done using package xcolor. See the package manual for more
information about this. Additionally a not visible strut has been used. Every com-
plete L
A
TEX introduction should explain the related command \strut. A helper
362
Chapter 18.
macro \numberbox has been defined for the formatting of the number within a box.
In the redefinition of \GenericMarkFormat this has been prefixed by \protect to
protect it from expansion. This is necessary because otherwise the upper case let-
ter conversion of \MakeUppercase that will be used for the running head, would
result in an ask for colours “BLACK” and “WHITE” instead of “black” and “white”
and those colours are undefined. Alternatively you may define \numberbox using
\DeclareRobustCommand*
instead of \newcommand* and then omit \protect (see
[
Tea06
]).
If you’d do the same with a KOMA-Script class or with one of the L
A
TEX standard
classes book or report, you’d additionally have to redefine \sectionmarkformat
and
\subsectionmarkformat
respectively
\chaptermarkformat
and
\sectionmarkformat
too, because then these would not have been defined
using \GenericMarkFormat:
\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}
\righttopmark
\rightbotmark
\rightfirstmark
\lefttopmark
\leftbotmark
\leftfirstmark
For page styles L
A
TEX
v3.16
uses a bipartite TEX mark. Running heads can use the left part of that
mark by \leftmark and the right part by \rightmark. Indeed, it seems that it was suggested
to use \leftmark for the running head of left, even pages and \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 \botmark is the last
valid mark of the page that has been build last. If there has not been set any mark on the
363
Chapter 18.
page, it is the last mark of the already shipped out pages. L
A
TEX command \leftmark uses
exactly this mark. So it shows the left part of the last mark of the page. This is the same like
\leftbotmark
. In opposite to this \rightbotmark shows the right part of that mark.
\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. L
A
TEX command \rightmark uses exaclty
this mark. So it shows the right part of the first mark of the page. This is the same like
\rightfirstmark
. In opposite to this \leftfirstmark shows the left part of that mark.
\topmark
is the content of \botmark before building the current page. L
A
TEX itself does
not use it. Nevertheless, scrlayer provides \lefttopmark to show the left part of it and
\righttopmark
to show the right part of it.
Note that the left part and the right part of the mark can be made all together only.
Even if you use \markright to change only the right part, the left part will be made again
(unchanged). Accordingly in double-side mode using page style headings the higher section
levels always make both parts. For example \chaptermark uses \markboth with an empty
right argument in this case. This is the reason why \rightmark or \rightfirstmark always
shows an empty value on pages with chapter beginnings, even if there was a \sectionmark or
\section
on the same page to make the right part of the mark.
Please note 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 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
[
Knu90
, chapter 23]. You will find, that marks are an issue for real experts. So if the expla-
nation above was at least more confusing than illuminative: Please don’t worry.
\@mkleft{left mark }
\@mkright{right mark }
\@mkdouble{mark }
\@mkboth{left mark }{right mark }
Sometimes inside classes and packages the marks for running heads should be filled up only
if automatic running heads are active (see option automark and command \automark on
page 218
). In the L
A
TEX standard classes only \@mkboth has been used for this. This command
is either \@gobbletwo, that simply destroys both mandatory arguments, or \markboth, a
command that fills up the left and left mark and the right mark. Packages like babel also
change \mkboth, i. e., to add language switching to the running head.
But if a class or package author only wants to change either the left mark or the right
mark
without the other one, a proper command is missing. Package scrlayer itself needs such
commands for the implementation of all cases of automatic running heads. So if command
364
Chapter 18.
\@mkleft
to fill up only the left mark or \@mkright to fill up only the right mark or \@mkdouble
to fill up both marks with the same content is undefined while loading scrlayer, the package will
define them. Thereby the actual definition of \@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 \markleft, \markright, and
\markboth
.
18.2. Definition of new Pairs of Page Styles
In
section 5.4
the page styles scrheadings and plain.scrheadings have been described.
These can be seen as a pair of page styles, with scrheadings being the main page style with
a running head and plain.scrheadings being the corresponding plain page style without
running head but generally with pagination. Additionally to the configuration of these page
styles, scrlayer-scrpage provides also the feature of defining new such pairs of page styles.
Thereby the name of the main page style, e. g., scrheadings, can be seen as the name of the
pair of page styles.
Most users will not need more than the predefined pair 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.
\defpairofpagestyles[parent pair ]{name }{definition }
\newpairofpagestyles[parent pair ]{name }{definition }
\renewpairofpagestyles[parent pair ]{name }{definition }
\providepairofpagestyles[parent pair ]{name }{definition }
With these commands you may define pairs of page styles similar to scrheadings and
plain.scrheadings
. Thereby name is the name of the main page style that is similar to
scrheadings
. The name of the corresponding plain page style will be prefixed by plain.
automatically. So 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 plain.name is the name of the plain page style of
this pair.
If the optional argument 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 parent pair .
Reading
section 5.4
might have created the impression that the described commands are
related to scrheadings and plain.scrheadings only. However, if there exist more pairs of
365
Chapter 18.
page styles, these commands are related to the pair that has been activated last. In fact, this
is the case for \lehead, \cehead, \rehead, \lohead, \cohead, \rohead, \lefoot, \cefoot,
\refoot
, \lofoot, \cofoot, \rofoot, \ihead, \chead, \ohead, \ifoot, \cfoot, and \ofoot
of
section 5.4
.
All those commands and the below described commands \clearmainofpairofpagestyles,
\clearplainofpairofpagestyles
, and \clearpairofpagestyles are also designed to be
used inside the argument 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 \pagestyle.
Please note that the commands of
section 5.5
are for general purpose. Therefore, they are
related to every page style that has been defined using scrlayer-scrpage.
Whereas \defpairofpagestyles will define a pair no matter if the corresponding page
styles are already defined, \newpairofpagestyles and \providepairofpagestyles will de-
fine 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 \providepairofpagestyles will be ignored, but usage
of \newpairofpagestyles would result in an error message. To redefine already existing pairs
of page styles you may use \renewpairofpagestyles. With this an error would be thrown,
if at least one of the page styles of the pair does not already exist.
\clearmainofpairofpagestyles
\clearplainofpairofpagestyles
\clearpairofpagestyles
Command \clearmainofpairofpagestyles will configure the main page style of the lastly ac-
tivated pair of page styles to be empty. In contrast to this \clearplainofpairofpagestyles
will configure the plain page style of the lastly activated pair of page styles to be empty. Last
but not least \clearpairofpagestyle will configure both page styles of the lastly activated
pair of page styles to be empty.
But please note that none of these commands will remove the definitions of argument
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 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.
The commands \clearscrheadings, \clearscrplain, and \clearscrheadfoot are aliases
for these commands provided only for compatibility with scrpage2. Nevertheless, they are
deprecated and should not be used.
366
Chapter 18.
Dostları ilə paylaş: |