Chapter 17: Defining Layers and Page Styles Using scrlayer
398
\DestroyPageStyleAlias{page style name }
This command makes the page style with given page style name L
A
TEX-undefined, if it is
an alias for another page style. Afterwards, the page style may be defined newly with, e.g.,
\DeclareNewAliasPageStyle
or \ProvideAliasPageStyle.
The command is intended to be used inside of
\scrlayerOnAutoRemoveInterface
to re-
move page styles that have been declared by an interface and use removable macros of that
interface.
\GetRealPageStyle{page style name }
The command will result in the (recursive) real page name of the page style, if the page style
with given name page style name is an alias of another page style. In all other cases, even
if there’s no alias and no page style named page style name , the result would be simply
page style name
. The command is fully expandable and may be used, e.g., in the second
argument of \edef.
\DeclarePageStyleByLayers[option list ]{page style name }{layer list }
\DeclareNewPageStyleByLayers[option list ]{page style name }{layer list }
\ProvidePageStyleByLayers[option list ]{page style name }{layer list }
\RedeclarePageStyleByLayers[option list ]{page style name }{layer list }
These commands declare a page style with page style name . The page style will consist of
the layers given in layer list , a comma separated list of layer names. Note, the page style
name
and the layer names at the layer list must be fully expandable and should expand
to letters. Several other characters are tolerated, but, nevertheless, not recommended.
The option list is a comma separated list of key =value options. These options may
be used to set additional features. Currently they are used to set the code that should be
expanded or executed at several hooks. See the introduction to this section for more general
information about hooks. See
table 17.2
for detailed information on specific hooks.
Table 17.2.: The hook options for page styles (in order of execution)
onselect=code
Execute code whenever the page style is selected using, e.g.,
\pagestyle
. Note,
\thispagestyle
does not select the page style immediately, but asynchronously
inside L
A
TEX’s output routine.
. . .
Chapter 17: Defining Layers and Page Styles Using scrlayer
399
Table 17.2.: The hook options for page styles (Continuation)
oninit=code
Execute code whenever the output of page style’s layers is initialised. Note, this
is done twice for every page: once for background layers and once for foreground
layers.
ononeside= code
Execute code whenever the output of page style’s layers in single-side mode is ini-
tialised. Note, this is done twice for every page: once for background layers and once
for foreground layers.
ontwoside=code
Execute code whenever the output of page style’s layers in two-side mode is ini-
tialised. Note, this is done twice for every page: once for background layers and
once for foreground layers.
onoddpage=code
Execute code whenever the output of page style’s layers on an odd page is initialised.
Note, this is done twice for every page: once for background layers and once for
foreground layers. Note also that in single-side mode all pages are odd pages, not
only pages with odd page numbers.
onevenpage=code
Execute code whenever the output of page style’s layers on an even page is initialised.
Note, this is done twice for every page: once for background layers and once for
foreground layers. Note also that there are not even pages in single-side mode, but
all pages are odd pages, not only pages with odd page numbers.
onfloatpage=code
Execute code whenever the output of page style’s layers on a float page are ini-
tialised. Note, this is be done twice for every page: once for background layers and
once for foreground layers. Note also that float pages are only those pages with
p-placed floating objects.
onnonfloatpage=code
Execute code whenever the output of page style’s layers on a non-float page is
initialised. Note, this is done twice for every page: once for background layers and
once for foreground layers. Note also that non-float pages are all pages that are
not float-pages. Those pages may have t-placed, h-placed, b-placed, or no floating
objects.
. . .
Chapter 17: Defining Layers and Page Styles Using scrlayer
400
Table 17.2.: The hook options for page styles (Continuation)
onbackground=code
Execute code whenever the output of page style’s layers in the background of a page
is initialised. Note, this is done once for every page.
onforeground=code
Execute code whenever the output page style’s layers in the foreground of a page is
initialised. Note, this is done once for every page.
The difference of \DeclarePageStyleByLayers and \DeclareNewPageStyleByLayers is
that \DeclareNewPageStyleByLayers will result in an error, if a page style with name page
style name
already exists. Note, declaring a page style, which is an alias of another page
style (see \DeclareAliasPageStyle prior in this section), will not re-declare the page style
itself, but it’s real page style (see
\GetRealPageStyle
prior in this section).
The difference of \DeclarePageStyleByLayers and \ProvidePageStyleByLayers is that
\ProvidePageStyleByLayers
will simply do nothing, if there’s already a page style with name
page style name
. In difference to \DeclareNewPageStyleByLayers it will not raise an error.
The difference of \DeclarePageStyleByLayers and \RedeclarePageStyleByLayers is,
that \RedeclarePageStyleByLayers may be used only if the real page style of page style
name
already exists. Otherwise an error occurs.
Please have also a look at the notes to following pseudo page style @everystyle@.
\pagestyle
{@everystyle@}
\pagestyle
{empty}
There are two default layer page styles that are somehow special.
The first one is
@everystyle@
. This page style should not be used like any other page style, but the
layers of this page style will be used by all the other layer page styles. So adding
a layer to this page style is similar to adding this layer to all other layer page styles
even the empty one. There’s one difference: Layer referencing commands of the page
style interface like
\ForEachLayerOfPageStyle
,
\AddLayersToPageStyleBeforeLayer
, or
\AddLayersToPageStyleAfterLayer
process only the layers of the page style that has been
referenced but not the layers implicated by @everystyle@.
The other somehow special page style is empty. Normally page style empty is defined by the
L
A
TEX kernel, to be a page style without page head or page foot. Package scrlayer re-defines it
to be a layer page style without any layer. Nevertheless, you may use it like every other layer
page style too. The main advantage above the L
A
TEX kernel’s empty page style is that it also
executes the layers of special layer page style @everysel@.
Chapter 17: Defining Layers and Page Styles Using scrlayer
401
onpsselect=code
onpsinit=code
onpsoneside=code
onpstwoside=code
onpsoddpage=code
onpsevenpage=code
onpsfloatpage=code
onpsnonfloatpage=code
onpsbackground=code
onpsforeground=code
There’s also a KOMA-Script option for each of those hooks. The names of the KOMA-Script
options are similar to the names of the page style options, but with “ps” inserted behind “on”.
The value of the KOMA-Script options are the initial defaults of the corresponding hooks.
These defaults will be extended at every declaration of page style hook options via option
list
. You may remove the default, using
\ModifyLayerPageStyleOptions
described later
in this section.
deactivatepagestylelayers=simple switch
\ForEachLayerOfPageStyle{page style name }{code }
\ForEachLayerOfPageStyle*{page style name }{code }
As long as KOMA-Script option deactivatepagestylelayers has not been activated com-
mand \ForEachLayerOfPageStyle can be used to process code for every member layer of
page style name
’s layers list. Inside of code the place holder #1 may be used to reference
the name of the current layer.
Example: If you want to print the names of all layers of page style scrheadings, you may
us:
\ let\commaatlist\ empty
\ForEachLayerOfPageStyle{scrheadings}{%
\commaatlist#1\gdef\commaatlist{, }}
Usage of \gdef instead of \def is necessary in the example above, because
\ForEachLayerOfPageStyle
executes the code inside of a group to minimise side effects.
Here \gdef redefines \commaatlist globally, so it would be still valid at the execution of
code
for the next layer.
Alternatively,
v3.18
you can use \def but the star variant \ ForEachLayerOfPageStyle*.
This type does not use an additional group for executing code .
On the
other hand the user has to take care on side effects of code , i. e., deactiva-
tion of all layers using deactivatepagestylelayers=true in code would persist after
\ForEachLayerOfPageStyle*
.
Chapter 17: Defining Layers and Page Styles Using scrlayer
402
Several other commands of scrlayer also use \ForEachLayerOfPageStyle internally. So these
also do not process any layer if KOMA-Script option deactivatepagestylelayers would be
activated. So you may use this options, e.g., to hide all layers of all layer page styles.
\AddLayersToPageStyle{page style name }{layer list }
\AddLayersAtBeginOfPageStyle{page style name }{layer list }
\AddLayersAtEndOfPageStyle{page style name }{layer list }
\RemoveLayersFromPageStyle{page style name }{layer list }
You can use these commands to add layers to a layer page style or to remove layers from a
layer page style. The page style will be referenced by page style name . The layers are given
by a comma separated layer list .
The commands \AddLayersToPageStyle and \AddLayersAtEndOfPageStyle add all layers
of the comma separated list of layers layer list at the end of the layer list of layer page style
page style name
. Logically the added layers would be above or in front of the old layers
of the page style. Nevertheless, new background layers would be behind the text layer and
therefore behind all foreground layers.
Command \AddLayersAtBeginOfPageStyle adds the new layers at the begin of the layer
list of the page style. Note, the layers will be added in the order of the layer list . The
first layer at layer list will be added first, the second layer will be added second and so on.
So with \AddLayersAtBeginOfPageStyle the last layer at layer list will become the new
first layer of the layer list of layer page style page style name .
Command \RemoveLayersFromPageStyle may be used to remove layers from the layer list
of layer page style page style name instead of adding them. Note, layers, which are part
of layer list , but not part of the page style’s layer list, will be ignored. But adding or
removing layers from a page style, which is not a layer page style or an alias of a layer page
style, would be a mistake and result in an error message.
\AddLayersToPageStyleBeforeLayer{page style name }{layer list }{reference layer name }
\AddLayersToPageStyleAfterLayer{page style name }{layer list }{reference layer name }
These commands are similar to the commands described before, but they do not add the layers
at the begin or end of the layer list of a layer page style, but just before or after a reference
layer at the layer list of a layer page style. Note, in this case the order of the layer list
will be same in the layer list of page style name after adding. If the reference layer named
reference layer name
is not part of the layer list of the layer page style, nothing happens.
Chapter 17: Defining Layers and Page Styles Using scrlayer
403
\UnifyLayersAtPageStyle{page style name }
With the commands described before in this section you may not only add different layers to
a page style, but even add the same layer several times to a page style. In most cases it does
not make sense to have one layer several times at the layer list of a layer page style. So you
may use \UnifyLayersAtPageStyle to remove all dupes of layers from the layer list of a layer
page style.
Note, the order of layers may change! So if you want a special order, you should remove all
layers and add the layers in the order you want instead of using \UnifyLayersAtPageStyle.
\ModifyLayerPageStyleOptions{page style name }{option list }
\AddToLayerPageStyleOptions{page style name }{option list }
Command \ModifyLayerPageStyleOptions may be used to modify the page style options of
a layer page style. Only options at the comma separated option list will be set to the new
values given in option list if the new value is not empty. Options, which are not at option
list
, will stay unchanged. If you want to set an option to do nothing you may use value
\relax
. Note, setting an option to a new value using \ModifyLayerPageStyleOptions will
remove the previous value including the global default value.
\AddToLayerPageStyleOptions
differs from \ModifyLayerPageStyleOptions in that
point. It will not overwrite the previous values, but adds — or more precisely: concatenates —
the new values to the previous values of the options at option list .
\IfLayerPageStyleExists{page style name }{then code }{else code }
\IfRealLayerPageStyleExists{page style name }{then code }{else code }
Command \IfLayerPageStyleExists tests, whether or not the real page style of page style
name
is a layer page style. If the test is true, then code will be executed. If page style
name
is neither a layer page style, nor an alias of a layer page style, nor an alias of an alias of
. . . a layer page style, else code will be executed. Internally this command is often used to
throw an error message if you use one of the layer page style commands with an page style
name
that does not correspond with a layer page style.
Command \IfRealLayerPageStyleExists is similar, but then code will only be executed,
if page style name itself is the name of a layer page style. So else code will even be
executed, if page style name is an alias name of a layer page style or the alias name of an
alias name of . . . a layer page style.
Chapter 17: Defining Layers and Page Styles Using scrlayer
404
\IfLayerAtPageStyle{page style name }{layer name }{then code }{else code }
\IfSomeLayerAtPageStyle{page style name }{layer list }{then code }{else code }
\IfLayersAtPageStyle{page style name }{layer list }{then code }{else code }
Command \IfLayerAtPageStyle may be used to test, whether or not a layer named layer
name
is a member of the layer list of a given page style. If the test is true, the then code
will be executed. If the layer is not a member of the layer list of page style name , the else
code
will be executed.
Commands \IfSomeLayerAtPageStyle and \IfLayersAtPageStyle do not only test one
layer but several layers at a given, comma separated layer list . \IfSomeLayerAtPageStyle
will execute the then code if at least one of the layers at layer list is a member of the
layer list of page style name . In difference \IfLayersAtPageStyle executes the then code
only if all of the layers at layer list are members of the layer list of page style name .
\DestroyRealLayerPageStyle{page style name }
Command \DestroyRealLayerPageStyle makes the page style named page style name un-
defined, if and only if it is a layer page style. Nothing will be happen if it is an alias name of
a layer page style, if it is another page style, or if it is not a page style.
If page style name is the name of the current page style the current page style will become
a kind of empty page style. If the special page style — this may be set using
\thispagestyle
—
is page style name , this will be simply reset. So the previous
\thispagestyle
will become
invalid.
Note, the layers of the page style will not be destroyed automatically. If you want to destroy
the layers too, you may use
\ForEachLayerOfPageStyle{...}{\DestroyLayer{#1}}
before
destroying the layer page style.
The command is intended to be used inside the auto-remove code of an interface See
sec-
tion 17.8
below for more information about auto-remove code.
17.6. Head and Foot Height
Page head and footer are the main elements not only of a page style. Layer can also be
restricted to these using corresponding options (see
table 17.1
,
page 387
). Therefore the
heights of these elements are very important and have to be well defined.
All of what is described in
section 5.2
is generally applicable. So if you have alread read
and understood
section 5.2
you can switch to
section 17.7
,
page 405
.
Chapter 17: Defining Layers and Page Styles Using scrlayer
405
\footheight
\headheight
The package scrlayer introduces \footheight as a new length similar to \headheight of the
L
A
TEX kernel. Additionally scrlayer-scrpage interprets \footskip to be the distance from the
last possible base line of the text area to the first normal base line of the footer. Package
typearea interprets footheight in the same way. So typearea’s foot height options may also be
used to setup the values for packages scrlayer and scrlayer-scrpage. See option
footheight
and
footlines
in
section 2.6
,
page 43
) and option
footinclude
at
page 40
of the same section.
If you do not use package typearea, you should setup the head and foot height using the
lengths directly where necessary. At least for the head package geometry provides similar
settings. If you setup a head or foot height that is too small for the effective content,
scrlayer-scrpage will try to adjust the corresponding lengths properly. Furthermore, it will
warn you and give you additional information about the changes and proper settings you may
use yourself. The automatic changes will become valid immediately after the need for them
has been detected. They will never be removed automatically, however, even if content with
a lower height requirement should be detected at a later point in time.
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.
\automark[section level of the right mark ]{section level of the left mark }
\automark*[section level of the right mark ]{section level of the left mark }
\manualmark
automark
autooneside=simple switch
manualmark
In common classes the decision for a page style — generally headings and myheading — is also
a decision to use either automatic or manual running heads. This difference between those
two page styles has been abolished by scrpage2 and also by scrlayer. Instead of distinguish-
ing between automatic and manual running head by the selection of a page style, two new
commands, \automark and \manualmark, are provided.
The command \manualmark switches to manual marks and deactivates the automatic filling
of the marks. In contrast to this \automark and \automark* can be used to define, which
section levels should be used for the automatic mark filling. The optional argument is the
section level of the right mark
, the mandatory argument the section level of the
Chapter 17: Defining Layers and Page Styles Using scrlayer
406
left mark
. The arguments always should be the name of a section level like part, chapter,
section
, subsection, subsubsection, paragraph, or 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.
Please note that not every class provides running heads for every section level. For example
the standard classes never setup the running head of
\part
. The KOMA-Script classes provide
running heads for every section level.
The difference in \automark and \automark* is, that \automark deletes all prior usages of
\automark
or \automark*, while \automark* changes only the behaviour of the section levels
of its arguments. So you can even build more complex cases.
Instead of the commands you may also use the options manualmark and automark to switch
between manual and automatic running heads. Thereby automark always uses the default
\automark[section]{chapter}
for classes with
\chapter
and
\automark[subsection]{section}
for classes without
\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 autooneside corresponds to this behaviour.
The option understands the values for simple switches, that can be found in
table 2.5
on
page 39
. If you’d deactivate the option, in single side layout the optional and the obligatory
arguments of \automark and \automark* will influence the running head again.
Please note, 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 automark or manualmark or one of the commands \automark or
\manualmark
can reach a well defined state.
draft=simple switch
This KOMA-Script option understands the values for simple switches, that are shown in
table 2.5
on
page 39
. If the option is active, all elements of the page styles will also show
dimension lines. This might be useful while draft editing.
\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 will be described
next. Depending on the setting the argument could, e. g., be converted into upper or lower
cases.
|