Debian Codegraph @

texmf-dist/source/latex/koma-script/doc/scrlayer-en.tex

raw
1 % ======================================================================
2 % scrlayer-en.tex
3 % Copyright (c) Markus Kohm, 2013-2023
4 %
5 % This file is part of the LaTeX2e KOMA-Script bundle.
6 %
7 % This work may be distributed and/or modified under the conditions of
8 % the LaTeX Project Public License, version 1.3c of the license.
9 % The latest version of this license is in
10 % http://www.latex-project.org/lppl.txt
11 % and version 1.3c or later is part of all distributions of LaTeX
12 % version 2005/12/01 or later and of this work.
13 %
14 % This work has the LPPL maintenance status "author-maintained".
15 %
16 % The Current Maintainer and author of this work is Markus Kohm.
17 %
18 % This work consists of all files listed in MANIFEST.md.
19 % ======================================================================
20 %
21 % Chapter about scrlayer of the KOMA-Script guide
22 % Maintained by Markus Kohm
23 %
24 % ============================================================================
25
26 \KOMAProvidesFile{scrlayer-en.tex}
27 [$Date: 2023-04-25 09:00:44 +0200 (Di, 25. Apr 2023) $
28 KOMA-Script guide (chapter:scrlayer)]
29
30 \translator{Markus Kohm\and Karl Hagen}
31
32 \chapter[{Defining Layers and Page Styles with \Package{scrlayer}}]
33 {Defining\ChangedAt{v3.12}{\Package{scrlayer}} Layers and Page Styles with
34 \Package{scrlayer}}
35 \labelbase{scrlayer}
36
37 \BeginIndexGroup
38 \BeginIndex{Package}{scrlayer}%
39 \BeginIndex{}{layer}%
40 Most users of graphics software are already familiar with the layer model for
41 a page. Such a model is rather alien to \LaTeX{} itself, but some packages,
42 like \Package{eso-pic} or \Package{textpos}, provide a kind of
43 background or foreground layer. \Package{scrlayer} is another package that
44 provides such background and foreground layers, but unlike the packages
45 mentioned above, these layers are part of the page style. As a result, you can
46 switch between different layers simply by switching the page style.
47
48 To do so, the package also supports a low-level interface for defining page
49 styles that are based on a stack or list of layers, for adding layers to such
50 a layer stack, either at the top or the bottom, or before or after a specific
51 layer, and for removing individual layers and duplicates from a stack. In a
52 nutshell, the page style interface of \Package{scrlayer} provides commands to
53 define page styles based on a stack of layers and to manage those stacks.
54
55 Nevertheless, using the layers directly is recommended for advanced users
56 only. Interfaces for beginners and average users are provided by additional
57 packages that in turn load \Package{scrlayer}. See
58 \autoref{cha:scrlayer-scrpage} in \autoref{part:forAuthors} of this
59 \iffree{manual}{book}.
60
61
62 \LoadCommonFile{options} % \section{Early or Late Selection of Options}
63
64 \section{Generic Information}
65 \seclabel{generic.information}
66
67 The package needs some generic information about the class being used. Class
68 authors can help \Package{scrlayer} by providing the appropriate information.
69 Otherwise the package will try to determine this information for itself. This
70 works, for example, for the standard and the \KOMAScript{} classes. It may
71 work with other classes, or it may fail in whole or in part.
72
73 This section describes some of the information that class authors can provide.
74 Normally, users should not have to worry about it.
75
76 \begin{Declaration}
77 \Macro{if@chapter}\ \PName{then code}\ \textMacro{else}\ %
78 \PName{else code}\ \textMacro{fi}%
79 \end{Declaration}
80 If \Macro{if@chapter} is defined and corresponds to
81 \Macro{iftrue}\IndexCmd{iftrue}, \Package{scrlayer} takes the chapter level
82 into account when, for example, processing the
83 \DescRef{\LabelBase.option.automark} option. If it is defined but is not
84 \Macro{iftrue}, \Package{scrlayer} handles only the
85 \DescRef{maincls.cmd.part}, \DescRef{maincls.cmd.section},
86 \DescRef{maincls.cmd.subsection}, \Macro{sub\dots subsection},
87 \DescRef{maincls.cmd.paragraph}, \DescRef{maincls.cmd.subparagraph},
88 \Macro{sub\dots subparagraph} sectioning units. If the macro is undefined,
89 \Package{scrlayer} searches for \DescRef{maincls.cmd.chapter}. If
90 \DescRef{maincls.cmd.chapter} is defined and does not correspond to
91 \Macro{relax}, \Package{scrlayer} defines \Macro{if@chapter} to
92 \Macro{iftrue}. Otherwise \Macro{if@chapter} becomes
93 \Macro{iffalse}\IndexCmd{iffalse}.%
94 \EndIndexGroup
95
96
97 \begin{Declaration}
98 \Macro{if@mainmatter}\ \PName{then code}\ %
99 \textMacro{else}\ \PName{else code}\ \textMacro{fi}%
100 \end{Declaration}
101 Classes like \Class{book} or \Class{scrbook} provide
102 \DescRef{maincls.cmd.frontmatter}\IndexCmd{frontmatter},
103 \DescRef{maincls.cmd.mainmatter}\IndexCmd{mainmatter}, and
104 \DescRef{maincls.cmd.backmatter}\IndexCmd{backmatter} to switch between the
105 front, main, and end parts of a book. Typically, these classes also use
106 \Macro{if@mainmatter} internally to decide whether the current text is part of
107 the main body of the document or not. Classes like \Class{report} and
108 \Class{article} have no \DescRef{maincls.cmd.frontmatter},
109 \DescRef{maincls.cmd.mainmatter}, or \DescRef{maincls.cmd.backmatter} and
110 therefore also lack \Macro{if@mainmatter}.
111
112 It is easier for \Package{scrlayer} to avoid constantly testing for the
113 existence of these commands to decide whether to work in the main matter or
114 not, and instead to use \Macro{if@mainmatter}\IndexCmd{iftrue} with classes
115 like \Class{report} and \Class{article}. So if \Macro{if@mainmatter} is not
116 defined, \Package{scrlayer} defines it as a synonym for \Macro{iftrue}.
117
118 Some classes, however, define \DescRef{maincls.cmd.frontmatter},
119 \DescRef{maincls.cmd.mainmatter}, or \DescRef{maincls.cmd.backmatter} but not
120 \Macro{if@mainmatter}. In this case, \Package{scrlayer} also defines
121 \Macro{if@mainmatter} to be \Macro{iftrue} and it extends definition of
122 \DescRef{maincls.cmd.frontmatter}, \DescRef{maincls.cmd.mainmatter}, and
123 \DescRef{maincls.cmd.backmatter} to set \Macro{if@mainmatter} properly.
124 However, if there are other, comparable commands for switching between
125 different document parts. \Package{scrlayer} will not recognize them, does not
126 test for them, and therefore cannot extend them appropriately. In this case,
127 \Package{scrlayer} needs help of the class author to set \Macro{if@mainmatter}
128 correctly.%
129 \EndIndexGroup
130
131
132 \begin{Declaration}
133 \Macro{DeclareSectionNumberDepth}\Parameter{level name}%
134 \Parameter{level depth}
135 \end{Declaration}
136 Generally each section level is assigned an integer number indicating its
137 depth in the document structure. \LaTeX{} needs this to manage the hierarchy
138 of the section levels. But normally these values are known only to the
139 particular class that defines the section commands. This class then uses the
140 appropriate numbers inside the corresponding commands.
141
142 The \Package{scrlayer} package also needs information about the section
143 hierarchy. With the help of \Macro{DeclareSectionNumberDepth}, you can map the
144 name of a heading level to a corresponding \PName{level depth}. For example,
145 for the standard \Class{book} class, the \PName{level name}s would be
146 \PValue{part}, \PValue{chapter}, \PValue{section}, \PValue{subsection},
147 \PValue{subsubsection}, \PValue{paragraph}, and \PValue{subparagraph}, and the
148 corresponding \PName{level depth}s would be -1, 0, 1, 2, 3, 4, and 5.
149
150 The \Package{scrlayer} package tries to determine the \PName{level depth}s on
151 its own while loading and again during \Macro{begin}\PParameter{document}. But
152 if this fails, for example because you use completely different sectioning
153 commands, you can define the relationship explicitly with
154 \Macro{DeclareSectionNumberDepth}.%
155 \EndIndexGroup
156
157
158 \section{Declaring Layers}
159 \seclabel{layers}
160
161 A layer is an abstract model of a page. Unlike a real, physical sheet of
162 paper, this page is completely transparent. Typically, multiple layers are
163 stacked atop one another and opaque material on one layer hides material on
164 the layers below. The stack of layers is then merged to form the physical
165 page. The \Package{scrlayer} package provides two such stacks for each page: a
166 background stack and a foreground stack. The background stack is printed
167 beneath the normal page content, while the foreground stack is printed above
168 it. The normal page content is therefore a kind of a dividing layer between
169 the two layer stacks.
170
171 A layer has several attributes that can be understood as answers to some basic
172 questions:
173 \iffree{\begin{description}}{%
174 \begingroup
175 \RedeclareSectionCommand[beforeskip=.5\baselineskip plus .25\baselineskip
176 minus .1\baselineskip]{paragraph}%
177 \renewcommand*\item[4][]{\paragraph*{#3{#4}#1}}%
178 }%
179 \item[Does the layer belong to the foreground or the background?]%
180 \leavevmode\textnote{foreground or background}\hskip 0pt
181 Background layers are output before the normal content of the page.
182 Therefore they appear behind or beneath the normal content of the page.
183 Foreground layers are then output after the normal content. Therefore they
184 appear on top of the normal content of the page. By default, a layer is both
185 a background layer \emph{and} a foreground layer and therefore is printed
186 twice. Usually it makes sense to limit the layer explicitly to either the
187 foreground or the background.
188 \item[What is the position of the layer?]%
189 \leavevmode\textnote{horizontal and vertical position}\hskip 0pt
190 To answer this question, there are attributes to define the layer's
191 horizontal and vertical position.
192 \item[How big is the layer?\textnote{horizontal and vertical size}]%
193 As with the position, there are also attributes to define the width and
194 height of a layer. Thus a layer can be smaller or larger than the paper
195 and it can be placed at different positions on the paper.
196 \item[How are the horizontal and vertical positions measured?]%
197 \leavevmode\textnote{alignment}\hskip 0pt
198 This question is answered by the alignment attribute. The horizontal
199 position can be measured from the left edge of the paper to the left edge of
200 the layer, to the centre of the layer, to the right edge of the layer.
201 Similarly, the vertical position can be measured from the top edge of the
202 paper to the top edge of the layer, the centre of the layer, or the bottom
203 edge of the layer.
204 \item[Is the layer intended for text or picture output?]%
205 \leavevmode\textnote{text or picture}\hskip 0pt
206 This question is closely related to the position. For example, users often
207 expect the origin for a picture to be at the lower left corner of the layer.
208 But this would not be suitable for text output. Therefore the origin of a
209 text layer is the height of a standard text line below the top left corner
210 of the layer. Picture layers, on the other hand, create a
211 \Environment{picture}\IndexEnv{picture} environment in which additional
212 positioning commands are available.
213 \item[Should the layer be printed on left or right pages?]%
214 \leavevmode\textnote{left or right page}\hskip 0pt
215 By default a layer will be printed on all pages. Note that \LaTeX{} treats
216 even pages as left-side pages and odd pages as right-side pages, but in
217 one-sided printing, only right-hand pages exist regardless of the page
218 number.
219 \item[Should the layer be printed in one-sided or two-sided mode?]%
220 \leavevmode\textnote{one-sided or two-sided}\hskip 0pt
221 By default a layer will be printed in both one-sided and two-sided
222 printing. Nonetheless, a layer that is restricted to even pages will never
223 be printed in one-sided printing and therefore is not a one-sided layer.
224 \item[Should the layer be printed on float pages or normal pages?]%
225 \leavevmode\textnote{float page or normal page}\hskip 0pt
226 \LaTeX{} produces float pages for objects from environments like tables or
227 figures if they are allowed to appear on a page without normal page contents
228 (see option \PValue{p} for \Environment{figure} or \Environment{table}). In
229 effect, the entire page is allowed to float within the document. Normal
230 pages in this sense are all pages that are not float pages. Normal pages can
231 also contain floats at the top, in the middle, or at the bottom of the page.
232 Very large floats can give the impression of being page floats, while in
233 reality they are floating environments placed at the top of a normal page.
234 \item[What are the contents of the layer?]%
235 \leavevmode\textnote{contents}\hskip 0pt
236 The corresponding attribute simply contains what should be printed whenever
237 the layer is output.
238 \iffree{\end{description}}{%
239 \endgroup\par\bigskip\noindent\ignorespaces
240 }%
241 These eight questions immediately give rise to a number of attributes. Later
242 \iffree{in this guide}, we will describe additional attributes. However, they
243 are only defined for convenience and can be expressed by a combination of
244 these primary attributes.
245
246
247 \begin{Declaration}
248 \Macro{DeclareLayer}\OParameter{option list}\Parameter{layer name}%
249 \Macro{DeclareNewLayer}\OParameter{option list}\Parameter{layer name}%
250 \Macro{ProvideLayer}\OParameter{option list}\Parameter{layer name}%
251 \Macro{RedeclareLayer}\OParameter{option list}\Parameter{layer name}%
252 \Macro{ModifyLayer}\OParameter{option list}\Parameter{layer name}
253 \end{Declaration}
254 These commands can be used to define layers. The \PName{layer name} must be
255 fully expandable and should expand to ASCII letters only. Some additional
256 characters are accepted, but their use is only recommended for advanced users.
257
258 The \Macro{DeclareLayer} command does not care whether or not a layer with the
259 given \PName{layer name} already exists. It will under all circumstances
260 define the layer with the attributes specified in the \PName{option list}. An
261 \PName{option} can be either a key or a key followed by an equal sign and
262 a value. Multiple options are separated by commas. To use a comma or a white
263 space within the value of an option, you must put the value inside curly
264 brackets. See \autoref{tab:scrlayer.layerkeys} for more information on keys,
265 values, and the corresponding attributes.
266
267 Unlike \Macro{DeclareLayer}, \Macro{DeclareNewLayer} reports an error if a
268 layer with the same \PName{layer name} already exists. This prevents the user
269 from accidentally using the same \PName{layer name} more than once. This
270 is especially useful when classes or packages also define layers internally.
271
272 In contrast, \Macro{ProvideLayer} only defines a layer if there is no layer
273 with the same name already. If the name is in use for another layer, the new
274 definition is ignored. Therefore this command has the meaning, \emph{define
275 the layer only if it does not already exist.}
276
277 If you want to redefine an existing layer, you can use \Macro{RedeclareLayer}
278 or \Macro{ModifyLayer}. With \Macro{RedeclareLayer}, the layer is first reset
279 to the default settings and then completely redefined via the specified
280 options list. In contrast, \Macro{ModifyLayer} does not reset the layer.
281 Only those attributes which are explicitly set in the \PName{option list} will
282 be changed. Applying either command to a previously undefined \PName{layer
283 name} results in an error.
284
285 \begin{desclist}
286 \desccaption{%
287 Options for defining page layers and the meaning of the
288 corresponding layer attribute\label{tab:scrlayer.layerkeys}%
289 }{%
290 Options for defining layers (\emph{continued})%
291 }%
292 \entry{%
293 \ChangedAt{v3.16}{\Package{scrlayer}}%
294 \OptionVName{addcontents}{Code}}{%
295 The specified \PName{code} will be appended to the current value of the
296 \Option{contents} attribute, so the new content will appear at the end of
297 the existing content. For more information about the handling of
298 \PName{code} see the \Option{contents} option.%
299 }%
300 \entry{%
301 \ChangedAt{v3.16}{\Package{scrlayer}}%
302 \OptionVName{addheight}{additional height}}{%
303 The current value of the \Option{height} attribute will be increased by
304 the value of this option. You can use the same kind of values as for
305 \Option{height}.%
306 }%
307 \entry{%
308 \ChangedAt{v3.16}{\Package{scrlayer}}%
309 \OptionVName{addhoffset}{additional horizontal offset}}{%
310 The current value of the \Option{hoffset} attribute will be increased by
311 the value of this option. You can use the same kind of values as for
312 \Option{hoffset}.%
313 }%
314 \entry{%
315 \ChangedAt{v3.16}{\Package{scrlayer}}%
316 \OptionVName{addvoffset}{additional vertical offset}}{%
317 The current value of the \Option{voffset} attribute will be increased by
318 the value of this option. You can use the same kind of values as for
319 \Option{voffset}.%
320 }%
321 \entry{%
322 \ChangedAt{v3.16}{\Package{scrlayer}}%
323 \OptionVName{addwidth}{additional width}}{%
324 The current value of the \Option{width} attribute will be increased by
325 the value of this option. You can use the same kind of values as for
326 \Option{width}.%
327 }%
328 \nentry{\KOption{align}{\PName{alignment characters}}}{%
329 The \PName{alignment characters} define the desired alignment of the
330 layer. Each \PName{alignment character} determines how the \PName{length}
331 of either the \Option{hoffset} or the \Option{voffset} option is
332 interpreted. Multiple \PName{alignment character}s can be used together
333 (without spaces or commas) and are evaluated in the order they occur.
334 Macros are not permitted in the value of the option. Valid
335 \PName{alignment character}s are:
336 \begin{description}
337 \item[\PValue{b} --] align the layer at its bottom edge; the value of
338 \Option{voffset} is the distance from the top edge of the paper to the
339 bottom of the layer.
340 \item[\PValue{c} --] align the layer at its centre; the values of
341 \Option{voffset} and \Option{hoffset} are interpreted as the distance
342 from the top left corner of the paper to the centre of the layer.
343 \item[\PValue{l} --] align the layer at its left edge; the value of
344 \Option{hoffset} is interpreted as the distance from the left edge of
345 the paper to the left edge of the layer.
346 \item[\PValue{r} --] align the layer at its right edge; the value of
347 \Option{hoffset} is interpreted as the distance from the left edge of
348 the paper to the right edge of the layer.
349 \item[\PValue{t} --] align the layer at its top edge; the value of
350 \Option{voffset} is interpreted as the distance from the top edge of the
351 paper to the top edge of the layer.
352 \end{description}%
353 }%
354 \entry{\KOption{area}{%
355 \Parameter{hoffset}\Parameter{voffset}%
356 \Parameter{width}\Parameter{height}}}{%
357 This composite option sets the primary attributes
358 \OptionValue{hoffset}{horizontal offset}, \OptionValue{voffset}{vertical
359 offset}, \OptionValue{width}{width}, \OptionValue{height}{height}.%
360 }%
361 \entry{\ChangedAt{v3.18}{\Package{scrlayer}}%
362 \Option{backandforeground}}{%
363 This option removes the restriction of a layer to the foreground or the
364 background. In general, this option makes little sense, but it is provided
365 for the sake of a complete user interface. This option does not expect or
366 allow a value.%
367 }%
368 \entry{\Option{background}}{%
369 This option displays the layer in the background only. The default is to
370 display layers in both the background and the foreground. This option does
371 not expect or allow a value.%
372 }%
373 \entry{\Option{bottommargin}}{%
374 This composite option sets the primary attributes \Option{hoffset},
375 \Option{voffset}, \Option{width}, \Option{height}, and \Option{align} so
376 that the layer spans the paper horizontally from the left edge to the
377 right and vertically from immediately beneath the footer to the bottom
378 edge of the paper.%
379 }%
380 \entry{\KOption{clone}{\PName{layer name}}}{%
381 This composite option sets all primary attributes of the layer to the same
382 values as the primary attributes of the layer with the given \PName{layer
383 name}. See the notes on the \PName{layer name} at the beginning of the
384 explanation for \Macro{DeclareLayer}. The layer to be cloned must also
385 already exist.%
386 }%
387 \entry{\KOption{contents}{\PName{code}}}{%
388 The specified \PName{code} will be expanded whenever the layer is printed.
389 This \PName{code} defines what you see for the layer. No tests are made to
390 see if the code is valid. Errors in the \PName{code} can therefore lead to
391 multiple error messages on each page that prints the layer.%
392 }%
393 \entry{\Option{evenpage}}{%
394 This option causes the layer to appear on even pages only, unlike the
395 default, where a layer will appear on both even and odd pages. Since even
396 pages only appear in two-sided printing, this option implies
397 \Option{twoside}. This option does not expect or allow a value.%
398 }%
399 \entry{\ChangedAt{v3.18}{\Package{scrlayer}}%
400 \Option{everypage}}{%
401 This option is a combination of \Option{oddorevenpage} and
402 \Option{floatornonfloatpage}. This option does not expect or allow a
403 value.%
404 }%
405 \entry{\Option{everyside}}{%
406 This option removes any restriction of the layer to one-sided or two-sided
407 printing. This is the default setting. This option does not expect or
408 allow a value.%
409 }%
410 \entry{\ChangedAt{v3.18}{\Package{scrlayer}}%
411 \Option{floatornonfloatpage}}{%
412 This option removes any restriction of the layer to float or non-float
413 pages and restores the default setting. This option does not expect or
414 allow a value.%
415 }%
416 \entry{\Option{floatpage}}{%
417 This option restricts the layer to appearing on float pages only. The
418 default setting is for layers to appear on both float and non-float pages.
419 This option does not expect or allow a value.%
420 }%
421 \entry{\Option{foot}}{%
422 This composite option sets \Option{hoffset}, \Option{voffset},
423 \Option{width}, \Option{height}, and \Option{align} so that the layer
424 spans the page footer over the width of the text area. This option does
425 not expect or allow a value.%
426 }%
427 \entry{\Option{footskip}}{%
428 This composite option sets \Option{hoffset}, \Option{voffset},
429 \Option{width}, \Option{height}, and \Option{align} so that the layer
430 spans the vertical distance between the text area and the page footer over
431 the width of the text area. Note, however, that although the height of
432 this area depends on \Length{footskip}, it is not the same. This option
433 does not expect or allow a value.%
434 }%
435 \entry{\Option{foreground}}{%
436 This option displays the layer in the foreground only. The default is to
437 display layers in both the background and the foreground. The option does
438 not expect or allow a value.%
439 }%
440 \entry{\Option{head}}{%
441 This composite option sets \Option{hoffset}, \Option{voffset},
442 \Option{width}, \Option{height}, and \Option{align} so that the layer
443 spans the vertical area of the page header for the width of the text area.
444 The height corresponds to the length \Length{headheight}. This option does
445 not expect or allow a value.%
446 }%
447 \entry{\Option{headsep}}{%
448 This composite option sets \Option{hoffset}, \Option{voffset},
449 \Option{width}, \Option{height}, and \Option{align} so that the layer
450 spans the vertical distance between the page header and the text area for
451 the width of the text area. The height corresponds to the length
452 \Length{headsep}. This option does not expect or allow a value.%
453 }%
454 \entry{\KOption{height}{\PName{length}}}{%
455 Sets the height of the layer. Note that the \PName{length} can be a
456 \LaTeX{} length declared with \Macro{newlength}, a \TeX{} length declared
457 with \Macro{newdimen} or \Macro{newskip}, a length value like 10\,pt, or a
458 dimensional expression using +, -, /, *, (, and ). For more information
459 about valid dimensional expressions see \cite[section~3.5]{manual:eTeX}.%
460 }%
461 \entry{\KOption{hoffset}{\PName{length}}}{%
462 Sets the distance of the layer from the left edge of the paper. How the
463 distance is measured depends on the \Option{align} option. See the
464 \Option{height} option for more information about valid expressions for
465 \PName{length}.%
466 }%
467 \entry{\Option{innermargin}}{%
468 This composite option sets \Option{hoffset}, \Option{voffset},
469 \Option{width}, \Option{height}, and \Option{align} so that the layer
470 spans the inner margin, from the edge of the page to the edge of the text
471 area and from the top to the bottom of the page. In one-sided printing,
472 the inner margin corresponds to the left margin. This option does not
473 expect or allow a value.%
474 }%
475 \entry{\Option{leftmargin}}{%
476 This composite option sets \Option{hoffset}, \Option{voffset},
477 \Option{width}, \Option{height}, and \Option{align} so that the layer
478 spans the left margin, from the left edge of the paper to the left edge of
479 the text area and from the top of the paper to the bottom. This option
480 does not expect or allow a value.%
481 }%
482 \entry{\ChangedAt{v3.19}{\Package{scrlayer}}%
483 \OptionVName{mode}{mode}}{%
484 This primary option defines the \PName{mode} in which the layer's content
485 is output. The default is \OptionValue{mode}{text}. The baseline of the
486 first text line is placed the height of one standard text line below the
487 top edge of the layer, so the text is usually neatly aligned with the top
488 of the layer. In \PValue{picture} \PName{mode}, on the other hand, the
489 layer spans a \Environment{picture} environment with the origin at the
490 bottom left corner of the layer. The \PValue{raw} \PName{mode} is also
491 also defined. By default it corresponds to \PValue{text} \PName{mode}.
492 Changing\textnote{Attention!} the \PName{mode} of a layer usually results
493 the contents shifting. Furthermore, the \PValue{picture} \PName{mode}
494 provides additional commands that result in errors with another
495 \PName{mode}. Therefore it usually makes no sense to change the
496 \PName{mode} of a layer after its initial declaration!%
497 }%
498 \entry{\Option{nonfloatpage}}{%
499 This option restricts the layer to pages that are not float pages. The
500 default is for the layer to appear on both float and non-float pages. This
501 option does not expect or allow a value.%
502 }%
503 \entry{\ChangedAt{v3.18}{\Package{scrlayer}}%
504 \Option{oddorevenpage}}{%
505 This option removes any restriction of the layer to odd or even pages,
506 restoring the default behaviour that the layer should appear on both odd
507 and even pages. The option does not expect or allow a value.%
508 }%
509 \entry{\Option{oddpage}}{%
510 This option restricts the layer to odd pages only. The default is for
511 layers to appear on both odd pages and on even pages. Note that in
512 one-sided printing, all pages are odd, regardless of the page number. This
513 option does not expect or allow a value.%
514 }%
515 \entry{\Option{oneside}}{%
516 This option restricts the layer to one-sided printing only. The default is
517 for layers to appear in both one-sided and two-sided printing. This option
518 does not expect or allow a value.%
519 }%
520 \entry{\Option{outermargin}}{%
521 The composite option sets \Option{hoffset}, \Option{voffset},
522 \Option{width}, \Option{height}, and \Option{align} so that the layer
523 spans the outer margin of the page, from the top to the bottom of the
524 paper. The outer margin corresponds to the right margin in one-sided
525 printing. This option does not expect or allow a value.%
526 }%
527 \entry{\Option{page}}{%
528 This composite option sets \Option{hoffset}, \Option{voffset},
529 \Option{width}, \Option{height}, and \Option{align} so that the layer
530 spans the the whole paper. This option does not expect or allow a value.%
531 }%
532 \entry{\ChangedAt{v3.16}{\Package{scrlayer}}%
533 \OptionVName{pretocontents}{code}}{%
534 The value of \PName{code} is prefixed the current value of the
535 \Option{contents} attribute, so the new content will appear before the
536 existing content. For more information about the handling of \PName{code},
537 see the \Option{contents} option.%
538 }%
539 \entry{\Option{rightmargin}}{%
540 This composite option sets \Option{hoffset}, \Option{voffset},
541 \Option{width}, \Option{height}, and \Option{align} so that the layer
542 spans the right margin, from the right edge of the text area to the right
543 edge of the paper and from the top to the bottom edge of the paper. This
544 option does not expect or allow a value.%
545 }%
546 \entry{\Option{textarea}}{%
547 This composite option sets \Option{hoffset}, \Option{voffset},
548 \Option{width}, \Option{height}, and \Option{align} so that the layer
549 spans the entire text area. This option does not expect or allow a value.%
550 }%
551 \entry{\Option{topmargin}}{%
552 This composite option sets \Option{hoffset}, \Option{voffset},
553 \Option{width}, \Option{height}, and \Option{align} so that the layer
554 spans the vertical distance between the top edge of the paper to the
555 header for the entire width of the paper. This option does not expect or
556 allow a value.%
557 }%
558 \entry{\Option{twoside}}{%
559 This option restricts the layer to two-sided printing. The default is for
560 layers to appear in both one-sided and two-sided printing. This option
561 does not expect or allow a value.%
562 }%
563 \entry{\ChangedAt{v3.18}{\Package{scrlayer}}%
564 \Option{unrestricted}}{%
565 This option removes all output restrictions. It is a combination of
566 \Option{backandforeground}, \Option{everyside}, and
567 \Option{floatornonfloatpage}. This option does not expect or allow a
568 value.%
569 }%
570 \entry{\KOption{voffset}{\PName{length}}}{%
571 Sets the distance of the layer from the top of the paper. How the distance
572 is measured depends on the \Option{align} option. See the \Option{height}
573 option for more information about valid expressions for \PName{length}.%
574 }%
575 \entry{\KOption{width}{\PName{length}}}{%
576 Sets the width of the layer. See the \Option{height} option for more
577 information about valid expressions for \PName{length}.%
578 }%
579 \end{desclist}
580 %
581 \EndIndexGroup
582
583
584 \begin{Declaration}
585 \Macro{ModifyLayers}\OParameter{option list}\Parameter{layer list}
586 \end{Declaration}
587 This\ChangedAt{v3.26}{\Package{scrlayer}} command executes
588 \DescRef{\LabelBase.cmd.ModifyLayer} with the given \PName{option list} for
589 all layers of the comma-separated layer list. Therefore the option can be used
590 to change attributes of several layers simultaneously.%
591 \EndIndexGroup
592
593
594 \begin{Declaration}
595 \Macro{layerhalign}%
596 \Macro{layervalign}%
597 \Macro{layerxoffset}%
598 \Macro{layeryoffset}%
599 \Macro{layerwidth}%
600 \Macro{layerheight}%
601 \end{Declaration}
602 These commands are only valid in the \PName{code} specified with
603 \Option{contents}, \Option{addcontents}, or \Option{pretocontents}. In this
604 case, they contain the layer's actual alignment, position, and dimensions that
605 will be used for the output. However, this is not necessarily the actual
606 dimensions of the layer's contents, e.\,g., if the contents are oversized or
607 do not fill the layer completely.
608
609 The primary layer attribute \PValue{align} is mapped to
610 \Macro{layerhalign}\ChangedAt{v3.19}{\Package{scrlayer}} and
611 \Macro{layervalign}. The horizontal values \PValue{l} and \PValue{r} are
612 copied to \Macro{layerhalign}. The vertical values \PValue{t} and \PValue{b}
613 are copied to \Macro{layervalign}. The value \PValue{c}, which is both
614 horizontal and vertical, is copied to both commands. If there are several
615 conflicting values for \PValue{align}, only the last one is copied. Thus the
616 resulting \Macro{layerhalign} is either \PValue{l}, \PValue{c}, or \PValue{r},
617 and the resulting \Macro{layervalign} is either \PValue{t}, \PValue{c}, or
618 \PValue{b}.
619
620 Redefining\textnote{Attention!} these instructions to change the values stored
621 in them is not permitted, as it would lead to unpredictable results.%
622 \EndIndexGroup
623
624
625 \begin{Declaration}
626 \Macro{LenToUnit}\Parameter{length}
627 \end{Declaration}
628 This\ChangedAt{v3.19}{\Package{scrlayer}} command originally came from
629 \Package{eso-pic}\IndexPackage{eso-pic}~2.0f. It converts lengths into
630 multiples of \Length{unit length} and can therefore be used everywhere \LaTeX{}
631 expects \Environment{picture} coordinates or \Length{unit length}-dependent
632 values. For more information, see \cite{package:eso-pic} and the descriptions
633 of \Macro{putUR}, \Macro{putLL}, and \Macro{putLR} below. If the command is
634 already defined, e.\,g., by loading \Package{eso-pic} before
635 \Package{scrlayer}, the package does not define it again.%
636 \iffalse% Umbruchkorrekturtext
637 \par
638 It should be noted at this point that using package
639 \Package{picture}\IndexPackage{picture}\important{\Package{picture}} (see
640 \cite{package:picture}) supersedes \Macro{LenToUnit} more or less. The package
641 extends environment \Environment{picture} and the picture commands so that you
642 can use \LaTeX{} lengths directly for coordinates.%
643 \fi
644 \EndIndexGroup
645
646
647 \begin{Declaration}
648 \Macro{putUL}\Parameter{content}%
649 \Macro{putUR}\Parameter{content}%
650 \Macro{putLL}\Parameter{content}%
651 \Macro{putLR}\Parameter{content}%
652 \Macro{putC}\Parameter{content}
653 \end{Declaration}
654 You\ChangedAt{v3.19}{\Package{scrlayer}} can use these commands inside the
655 value of \PValue{contents} layer option if the layer is declared with
656 \OptionValue{mode}{picture}. In this case, \Macro{putUL} places the
657 \PName{content} relative to the upper left corner of the layer and therefore
658 is the same as
659 \lstinline[breaklines=false]|\put(0,\LenToUnit{\layerheight})|. \Macro{putUR}
660 places the \PName{content} relative to the upper right corner of the layer and
661 therefore is the same as
662 \lstinline[breaklines=false]
663 |\put(\LenToUnit{\layerwidth},\LenToUnit{\layerheight})|.
664 \Macro{putLL} places the \PName{content} relative to the lower left corner of
665 the layer and therefore is the same as
666 \lstinline[breaklines=false]|\put(0,0)|. \Macro{putLR} places the
667 \PName{content} relative to the lower right corner and therefore is the same
668 as \lstinline[breaklines=false]|\put(\LenToUnit{\layerwidth},0)|. Last but
669 not least, \Macro{putC} places the \PName{content} relative to the centre of
670 the layer.%
671 \begin{Example}
672 You want to determine exactly how accurately
673 \OptionValueRef{typearea}{DIV}{classic} sets the height of the text area to
674 the width of the page size. You declare a layer that both borders the text
675 area and places a circle with a diameter of the paper width in the centre of
676 the text area:
677 \begin{lstcode}
678 \documentclass[DIV=classic]{scrartcl}
679 \usepackage{pict2e}
680 \usepackage{scrlayer}
681 \DeclareNewLayer[%
682 textarea,background,mode=picture,
683 contents={%
684 \putLL{\line(1,0){\LenToUnit{\layerwidth}}}%
685 \putLR{\line(0,1){\LenToUnit{\layerheight}}}%
686 \putUR{\line(-1,0){\LenToUnit{\layerwidth}}}%
687 \putUL{\line(0,-1){\LenToUnit{\layerheight}}}%
688 \putC{\circle{\LenToUnit{\paperwidth}}}%
689 }
690 ]{showtextarea}
691 \DeclareNewPageStyleByLayers{test}{showtextarea}
692 \pagestyle{test}
693 \begin{document}
694 \null
695 \end{document}
696 \end{lstcode}
697 You will notice that \Package{typearea}'s mapping to an integer \PName{DIV}
698 value is very accurate in this example.
699 \end{Example}
700 Incidentally, you will find more information about late medieval book-page
701 canon sketched in the example in \autoref{sec:typearea.circleConstruction},
702 \autopageref{sec:typearea.circleConstruction}.
703
704 The \Macro{DeclareNewPageStyleByLayers}\IndexCmd{DeclareNewPageStyleByLayers}
705 command just used in the example defines a new page style using the newly
706 declared layer. It will be explained in \autoref{sec:scrlayer.pagestyles},
707 \DescPageRef{scrlayer.cmd.DeclareNewPageStyleByLayers}.%
708 \EndIndexGroup
709
710
711 \begin{Declaration}
712 \Macro{GetLayerContents}\Parameter{layer~name}
713 \end{Declaration}
714 This\ChangedAt{v3.16}{\Package{scrlayer}} command returns the whole contents
715 of a layer. It is important to note\textnote{Attention!} that using this
716 command inside the \PName{code} of the layer attributes \Option{contents},
717 \Option{addcontents}, or \Option{pretocontents} can result in
718 infinite recursion when referencing the contents of the current layer. You
719 are responsible for avoiding such situations!%
720 \EndIndexGroup
721
722
723 \begin{Declaration}
724 \Macro{IfLayerExists}\Parameter{layer~name}
725 \Parameter{then-code}\Parameter{else-code}
726 \end{Declaration}
727 This command can be used to execute code depending on whether or not a layer
728 with the specified \PName{layer name} exists. If the layer exists, the
729 \PName{then-code} will be executed; otherwise, the \PName{else-code} will be
730 executed. Note that the command cannot really test whether a layer exists.
731 Instead it uses a heuristic which will never yield a false negative but which,
732 in extreme cases, could yield a false positive.
733 \iffalse% Umbruchvarianten
734 Nevertheless, if the test yields a false positive, something has gone wrong.
735 For example, this could indicate an incompatible package or that the user is
736 doing something he or she should not.%
737 \else
738 False positives indicate a problem, such as the use of an incompatible package
739 or a bad choice of internal macro names by the user.
740 \fi
741 \EndIndexGroup
742
743
744 \begin{Declaration}
745 \Macro{DestroyLayer}\Parameter{layer~name}
746 \end{Declaration}
747 If a layer with the given \PName{layer name} exists, all macros belonging to
748 it will be set to \Macro{relax}. In page styles already defined with
749 \Package{scrlayer}, such destroyed layers are ignored. Destroyed layers can be
750 redefined using \DescRef{\LabelBase.cmd.DeclareNewLayer} or
751 \DescRef{\LabelBase.cmd.ProvideLayer}, but they can no longer be changed using
752 \DescRef{\LabelBase.cmd.RedeclareLayer} or
753 \DescRef{\LabelBase.cmd.ModifyLayer}.%
754 \iffalse % See the note at the beginning of the end user interface section
755 \par
756 The command is intended to be used inside
757 \DescRef{\LabelBase.cmd.scrlayerOnAutoRemoveInterface} (see
758 \autoref{sec:scrlayer.enduserinterfaces},
759 \DescPageRef{scrlayer.cmd.scrlayerOnAutoRemoveInterface})
760 to remove layers defined using removable macros of an interface along with
761 that interface.%
762 \fi
763 \EndIndexGroup
764
765
766 \begin{Declaration}
767 \OptionVName{draft}{simple switch}
768 \Macro{layercontentsmeasure}%
769 \end{Declaration}
770 The \KOMAScript{} option \Option{draft} can be used to active the draft mode
771 of \Package{scrlayer}. The draft mode uses the \Macro{layercontentsmeasure}
772 command to print a ruler at each layer edge, of which the top and left one is
773 labelled in centimetres and the right and bottom one in inches. The rulers are
774 drawn behind the content of each layer. This command can also be used as
775 exclusive content of a layer.%
776 \EndIndexGroup
777
778
779 \section{Declaring and Managing Page Styles}
780 \seclabel{pagestyles}
781
782 \BeginIndexGroup
783 \BeginIndex{}{page>style}%
784 We now understand how to define and manage layers, but so far we do not know
785 how they are used. The possibly surprising answer is, with page styles. In
786 \LaTeX{}, page styles usually define headers and footers of the page.
787
788 The header and footer of odd or right-hand pages\textnote{even or odd page}
789 are printed on pages with odd page numbers in two-sided printing or on all
790 pages in one-sided printing. This is directly comparable to the layer
791 options\important[i]{\Option{evenpage}\\\Option{oddpage}} \Option{oddpage} and
792 \Option{evenpage}.
793
794 The page header\textnote{header or footer} is output before the main page
795 contents. The page footer is output after the main page contents. This
796 corresponds directly to the layer
797 options\important[i]{\Option{background}\\\Option{foreground}}
798 \Option{background} and \Option{foreground}.
799
800 Therefore it makes sense to define page styles as lists of layers. But instead
801 of just the four options mentioned above, you can use all the properties
802 explained in \autoref{sec:scrlayer.layers}, \autoref{tab:scrlayer.layerkeys},
803 on \autopageref{tab:scrlayer.layerkeys}.
804
805 As a result of these considerations, layer page
806 styles\textnote{layer page style}\Index{page style>layer}%
807 \Index{layer>page style}\Index{page>style} are one type of page style that
808 \Package{scrlayer} provides. A layer page style consists of layers as well as
809 several hooks. The layers have already been described in
810 \autoref{sec:scrlayer.layers}. The hooks\Index[indexmain]{hooks}%
811 \textnote{hooks} are points in the expansion or execution of page styles to
812 which you can add code. Experienced users already know this concept from
813 commands like \Macro{AtBeginDocument} (see \cite{latex:usrguide}) or
814 \DescRef{scrlfile.cmd.BeforeClosingMainAux} (see
815 \DescPageRef{scrlfile.cmd.BeforeClosingMainAux}).
816
817 Page-style aliases are another type of page style which \Package{scrlayer}
818 provides. A page-style alias is actually a different page style. In other
819 words, the name of a page-style alias is an alternative name for another
820 page-style alias or for a page style. As a result, manipulating a page-style
821 alias results in manipulating the original page style. If the original page
822 style is itself an alias, its manipulation again results in the manipulation
823 of the alias's original page style, and so on until a real page style is
824 finally changed. The term \emph{real page style}\textnote{real page style} is
825 used to distinguish it from a page-style alias. All page styles that are not
826 page-style aliases are real page styles. Aliases can be defined for all page
827 styles, not just those defined with \Package{scrlayer}.
828
829 \begin{Declaration}
830 \Macro{currentpagestyle}
831 \Macro{toplevelpagestyle}
832 \end{Declaration}
833 The \Package{scrlayer} package patches the \DescRef{maincls.cmd.pagestyle}
834 command so that it sets \Macro{currentpagestyle} to the currently active page
835 style. Note that \DescRef{maincls.cmd.thispagestyle} does not change
836 \Macro{currentpagestyle}. If you use \DescRef{maincls.cmd.thispagestyle},
837 however, \Macro{currentpagestyle} can change within the \LaTeX{} output
838 routine. However, this change will only occur if \Macro{currentpagestyle} has
839 been actively protected from expansion until the execution of the output
840 routine.
841
842 Note that the layer page styles described later in this section do not rely on
843 this \DescRef{maincls.cmd.pagestyle} extension because they redefine
844 \Macro{currentpagestyle} themselves. This patch was made so that other,
845 non-\Package{scrlayer} page styles can use \Macro{currentpagestyle}.
846 Additionally, \Macro{currentpagestyle} is empty after loading
847 \Package{scrlayer} and before using \DescRef{maincls.cmd.pagestyle} for the
848 first time. Therefore, when defining an end-user interface, you may find it
849 useful to set the current page style to a default with an implicit
850 \DescRef{maincls.cmd.pagestyle} statement.
851
852 If \DescRef{maincls.cmd.pagestyle} activates an alias page style,
853 \Macro{currentpagestyle} shows not the alternative name but the name of
854 the real page style. You\ChangedAt{v3.16}{\Package{scrlayer}} can get the
855 alternative name using \Macro{toplevelpagestyle}. However, it is not
856 recommended to define page styles that produce different results depending on
857 \Macro{toplevelpagestyle}, e.\,g., using \DescRef{scrbase.cmd.Ifstr}. If you
858 were to activate such a page style using \DescRef{maincls.cmd.thispagestyle}
859 you could get the wrong result.%
860 \EndIndexGroup
861
862
863 \begin{Declaration}
864 \Macro{BeforeSelectAnyPageStyle}\Parameter{code}%
865 \Macro{AfterSelectAnyPageStyle}\Parameter{code}%
866 \end{Declaration}
867 The \Macro{BeforeSelectAnyPageStyle} command adds \PName{code} to the hook%
868 \textnote{hook} that will be executed inside \DescRef{maincls.cmd.pagestyle},
869 just before the page style is selected. Within the \PName{code}, you can use
870 \texttt{\#1} as a place-holder for the argument of
871 \DescRef{maincls.cmd.pagestyle}.
872
873 The \Macro{AfterSelectAnyPageStyle} command works similarly, but the
874 \PName{code} will be executed just after the page style has been selected and
875 after \DescRef{\LabelBase.cmd.currentpagestyle} has been set to the name of
876 the real page style.
877
878 Note\textnote{Attention!} that the \PName{code} of both commands is executed
879 only if a page style is selected with \DescRef{maincls.cmd.pagestyle} and not
880 if it is chosen in a different way, e.\,g., using
881 \DescRef{maincls.cmd.thispagestyle}. Note also that you cannot remove
882 \PName{code} from the hook after adding it. But the \PName{code} will be added
883 locally, so you can use a group to limit the scope of the \PName{code}.%
884 \EndIndexGroup
885
886
887 \begin{Declaration}
888 \Macro{DeclarePageStyleAlias}\Parameter{page~style~alias~name}
889 \Parameter{original~page~style~name}
890 \Macro{DeclareNewPageStyleAlias}\Parameter{page~style~alias~name}
891 \Parameter{original~page~style~name}
892 \Macro{ProvidePageStyleAlias}\Parameter{page~style~alias~name}
893 \Parameter{original~page~style~name}
894 \Macro{RedeclarePageStyleAlias}\Parameter{page~style~alias~name}
895 \Parameter{original page style name}
896 \end{Declaration}
897 \BeginIndex{}{page style>alias}%
898 \BeginIndex{}{alias>page style}%
899 These commands can be used to define a page style with name \PName{page style
900 alias name} that is simply an alias for an existing page style with the
901 name \PName{original page style name}. If there is already a page style
902 \PName{page style alias name}, using \Macro{DeclarePageStyleAlias} or
903 \Macro{RedeclarePageStyleAlias} will destroy the alias before recreating it.
904
905 \Macro{DeclareNewPageStyleAlias} will throw an error message if a page style
906 \PName{page style alias name} has already been defined. It does not matter if
907 the previously defined page style is a layer-page style, a page style alias,
908 or another page style.
909
910 \Macro{ProvidePageStyleAlias} will define the alias only if the
911 \PName{page style alias name} page style has not been defined before. If the
912 \PName{page style alias name} page style already exists, nothing will be done.
913
914 \Macro{RedeclarePageStyleAlias} expects an existing
915 \PName{page style alias name} page style. It will destroy that page style and
916 afterwards define the alias. If the \PName{page style alias name} page style
917 does not exist, you will get an error.%
918 \iffree{\csname @tempswafalse\endcsname}{\csname @tempswatrue\endcsname}%
919 \csname if@tempswa\endcsname% Umbruchkorrekturtext
920 \begin{Example}
921 Suppose you write a class and use the \PageStyle{chapter} page style for the
922 first page of each chapter. By default, this page style should match the
923 \PageStyle{plain} page style. Therefore, you can use the \Package{scrlayer}
924 package and use
925 \begin{lstcode}
926 \DeclareNewPageStyleAlias{chapter}{plain}
927 \end{lstcode}
928 to define the \PageStyle{chapter} page style as an alias for the
929 \PageStyle{plain} page style. If, on the other hand, you later decide that
930 the \PageStyle{chapter} plage style should correspond to the
931 \PageStyle{empty} page style, you can achieve this with:
932 \begin{lstcode}
933 \RedeclarePageStyleAlias{chapter}{empty}
934 \end{lstcode}%
935 \end{Example}%
936 \fi
937 \EndIndexGroup
938
939
940 \begin{Declaration}
941 \Macro{DestroyPageStyleAlias}\Parameter{page~style~name}%
942 \end{Declaration}
943 \BeginIndex{}{page style>alias}%
944 \BeginIndex{}{alias>page style}%
945 This command renders the page style named \PName{page style name} undefined
946 for \LaTeX{} if it is an alias for another page style. Afterwards, the page
947 style can be newly defined with
948 \DescRef{\LabelBase.cmd.DeclareNewPageStyleAlias} or
949 \DescRef{\LabelBase.cmd.ProvidePageStyleAlias}.%
950 \iffalse % See the note at the beginning of the end user interface section
951 \par
952 This command is intended to be used inside the argument code of
953 \DescRef{\LabelBase.cmd.scrlayerOnAutoRemoveInterface} to remove page styles
954 that have been declared as part of an end-user interface when removing this
955 interface automatically.%
956 \fi%
957 \EndIndexGroup
958
959
960 \begin{Declaration}
961 \Macro{GetRealPageStyle}\Parameter{page~style~name}%
962 \end{Declaration}
963 \BeginIndex{}{page style>alias}%
964 \BeginIndex{}{alias>page style}%
965 This command will result in the (recursive) real page name of the page style
966 if \PName{page style name} is an alias of another page style. In all other
967 cases, even if there's no alias and no page style named \PName{page style
968 name}, the result is simply \PName{page style name}. The command is fully
969 expandable and may be used, e.g., in the second argument of \Macro{edef}.%
970 \EndIndexGroup
971
972
973 \begin{Declaration}
974 \Macro{DeclarePageStyleByLayers}\OParameter{option list}
975 \Parameter{page style name}
976 \Parameter{layer list}
977 \Macro{DeclareNewPageStyleByLayers}\OParameter{option list}
978 \Parameter{page style name}
979 \Parameter{layer list}
980 \Macro{ProvidePageStyleByLayers}\OParameter{option list}
981 \Parameter{page style name}
982 \Parameter{layer list}
983 \Macro{RedeclarePageStyleByLayers}\OParameter{option list}
984 \Parameter{page style name}
985 \Parameter{layer list}
986 \end{Declaration}
987 \BeginIndex{}{page style>layers}%
988 \BeginIndex{}{layers>page style}%
989 These commands declare a page style named \PName{page style name}. The page
990 style will consist of the layers given in \PName{layer list}, a comma
991 separated list of layer names. Note\textnote{Attention!} that the \PName{page
992 style name} and the layer names in the \PName{layer list} must be fully
993 expandable and should expand to letters. Several other characters are also
994 accepted, but their use is recommended only for experienced users.
995
996 The \PName{option list} is a comma-separated list of options in the form
997 \texttt{\PName{key}=\PName{value}}. These options may be used to set
998 additional features. Currently they are used to set the code that should be
999 expanded or executed at several hooks\Index{hooks}. See the introduction to
1000 this section for more general information about hooks. See
1001 \autoref{tab:scrlayer.pagestyle.hooks} for detailed information on specific
1002 hooks.
1003
1004 \begin{desclist}
1005 \desccaption{%
1006 Hook options for page styles (in order of
1007 execution)\label{tab:scrlayer.pagestyle.hooks}%
1008 }{%
1009 Hook options for page styles (\emph{continued})%
1010 }%
1011 \entry{\OptionVName{onselect}{code}}{%
1012 The \PName{code} of this hook\Index{hook} is executed whenever the page
1013 style is selected, for example with \DescRef{maincls.cmd.pagestyle}. Note
1014 that \DescRef{maincls.cmd.thispagestyle} itself does not directly select a
1015 page style. In this case, the page style is only activated within \LaTeX's
1016 output routine.%
1017 }%
1018 \entry{\OptionVName{oninit}{code}}{%
1019 The \PName{code} of this hook\Index{hook} is executed whenever the output
1020 of the page style's layers is initialised. Note that this happens twice
1021 for each page: once for background layers and once for foreground layers.%
1022 }%
1023 \entry{\OptionVName{ononeside}{code}}{%
1024 The \PName{code} of this hook\Index{hook} is executed whenever the output
1025 of the page style's layers in one-sided printing is initialised. Note that
1026 this happens twice for each page: once for background layers and once for
1027 foreground layers.%
1028 }%
1029 \entry{\OptionVName{ontwoside}{code}}{%
1030 The \PName{code} of this hook\Index{hook} is executed whenever the output
1031 of the page style's layers in two-sided printing is initialised. Note that
1032 this happens twice for each page: once for background layers and once for
1033 foreground layers.%
1034 }%
1035 \entry{\OptionVName{onoddpage}{code}}{%
1036 The \PName{code} of this hook\Index{hook} is executed whenever the output
1037 of the page style's layers on an odd page is initialised. Note that this
1038 happens twice for each page: once for background layers and once for
1039 foreground layers. Note also that in one-sided printing all pages are odd
1040 pages, not just those with odd page numbers.%
1041 }%
1042 \entry{\OptionVName{onevenpage}{code}}{%
1043 The \PName{code} of this hook\Index{hook} is executed whenever the output
1044 of the page style's layers on an even page is initialised. Note that this
1045 happens twice for each page: once for background layers and once for
1046 foreground layers. Note also that in one-sided printing there are no even
1047 pages. Instead, all pages are treated as odd pages, not just those with
1048 odd page numbers.%
1049 }%
1050 \entry{\OptionVName{onfloatpage}{code}}{%
1051 The \PName{code} of this hook\Index{hook} is executed whenever the output
1052 of the page style's layers on a float page is initialised. Note that this
1053 happens twice for each page: once for background layers and once for
1054 foreground layers. Note also that float pages are only those pages with
1055 one or more p-placed floating environments.%
1056 }%
1057 \entry{\OptionVName{onnonfloatpage}{code}}{%
1058 The \PName{code} of this hook\Index{hook} is executed whenever the output
1059 of the page style's layers on a non-float page is initialised. Note that
1060 this happens twice for each page: once for background layers and once for
1061 foreground layers. Note also that float pages are only the pages on which
1062 one or more p-placed floating environments are output. Other pages may
1063 well have t-, h-, or b-placed floating environments.%
1064 }%
1065 \entry{\OptionVName{onbackground}{code}}{%
1066 The \PName{code} of this hook\Index{hook} is executed whenever the output
1067 of the page style's background layers is initialised. Note that this
1068 happens once each page.%
1069 }%
1070 \entry{\OptionVName{onforeground}{code}}{%
1071 The \PName{code} of this hook\Index{hook} is executed whenever the output
1072 of the page style's foreground layers is initialised. Note that this
1073 happens once each page.%
1074 }%
1075 \end{desclist}
1076
1077 \iffalse% Umbruchvarianten
1078 While the \Macro{DeclarePageStyleByLayers} command always defines the page
1079 style, \Macro{DeclareNewPageStyleByLayers} generates an error message if a
1080 page style with the same name already exists. Note\textnote{Attention!} that
1081 the declaration of a page style that is already an alias for another page
1082 style (see, for example, \Macro{DeclareAliasPageStyle} earlier in this
1083 section) will redefine not the specified page style alias but the real page
1084 style (see \DescRef{\LabelBase.cmd.GetRealPageStyle} earlier in this
1085 section).%
1086 \else%
1087 The \Macro{DeclarePageStyleByLayers} command defines the page style
1088 regardless of whether a page style of \PName{page style name} already
1089 exists. If necessary, the existing page style is completely
1090 redefined. However, if a page style alias \PName{page style name} already
1091 exists, the associated real page style, not the page style alias itself, is
1092 redefined (see \DescRef{\LabelBase.cmd.GetRealPageStyle} earlier in this
1093 section).
1094
1095 The \Macro{DeclareNewPageStyleByLayers} command differs if a page style of
1096 the same name already exists. Regardless of whether it is a real or an alias
1097 page style, an error will be reported in this case.
1098 \fi
1099
1100 In contrast, \Macro{ProvidePageStyleByLayers} preserves the page style
1101 unchanged if a page style with name \PName{page style name} already exists. If
1102 no such page style exists, it is defined as in
1103 \Macro{DeclarePageStyleByLayers}.
1104
1105 The \Macro{RedeclarePageStyleByLayers} in turn expects that a page style of
1106 of the name \PName{page style name} already exists and then redefines its real
1107 page style. However, if no page style of the specified name exists, an error
1108 message results.
1109
1110 Also note the remarks below about the pseudo-page style
1111 \PageStyle{@everystyle@}.%
1112 \EndIndexGroup
1113
1114
1115 \begin{Declaration}
1116 \PageStyle{@everystyle@}%
1117 \PageStyle{empty}
1118 \end{Declaration}
1119 \BeginIndex{}{page style>layers}%
1120 \BeginIndex{}{layers>page style}%
1121 The \Package{scrlayer} package defines two specific page styles worth noting.
1122 The first of these is \PageStyle{@everystyle@}%
1123 \important{\PageStyle{@everystyle@}}. This page style should never be used
1124 like a normal page style, for example with \DescRef{maincls.cmd.pagestyle} or
1125 \DescRef{maincls.cmd.thispagestyle}, or as the target of a page-style alias.
1126 Instead, the layers and hooks\Index{hooks} of this page style are used by all
1127 other layer page styles. The hooks of \PageStyle{@everystyle@} are placed in
1128 front of their respective hooks, and the layers in front of the respective
1129 layers, of the active page style.
1130
1131 Thus adding a layer to the pseudo-page style \PageStyle{@everystyle@} or code
1132 to a hook of this page style is like adding a layer or hook code to all layer
1133 page styles, even the empty one. There's one crucial difference: commands that
1134 reference the layers of a page style which include
1135 \DescRef{\LabelBase.cmd.ForEachLayerOfPageStyle}, e.\,g., the commands
1136 \DescRef{\LabelBase.cmd.AddLayersToPageStyleBeforeLayer} or
1137 \DescRef{\LabelBase.cmd.AddLayersToPageStyleAfterLayer}, disregard the layers
1138 of the page style \PageStyle{@everystyle@} when applied to a different layer
1139 page style.
1140
1141 The second, slightly different page style is \PageStyle{empty}. Normally the
1142 \LaTeX{} kernel defines the \PageStyle{empty} page style to have an empty
1143 header and footer. The \Package{scrlayer} package redefines this page style as
1144 a layerless page style. Nonetheless, you can use it like any other layer page
1145 style. The main advantage of the layer page style over the original page
1146 style from the \LaTeX{} kernel is that it also executes the hooks and layers
1147 of the psuedo-layer page style \PageStyle{@everystyle@}.%
1148 \EndIndexGroup
1149
1150
1151 \begin{Declaration}
1152 \OptionVName{onpsselect}{code}%
1153 \OptionVName{onpsinit}{code}%
1154 \OptionVName{onpsoneside}{code}%
1155 \OptionVName{onpstwoside}{code}%
1156 \OptionVName{onpsoddpage}{code}%
1157 \OptionVName{onpsevenpage}{code}%
1158 \OptionVName{onpsfloatpage}{code}%
1159 \OptionVName{onpsnonfloatpage}{code}%
1160 \OptionVName{onpsbackground}{code}%
1161 \OptionVName{onpsforeground}{code}
1162 \end{Declaration}
1163 \BeginIndex{}{page style>layers}%
1164 \BeginIndex{}{layers>page style}%
1165 There is also a \KOMAScript{} option for each of the hooks\Index{hooks} in
1166 \autoref{tab:scrlayer.pagestyle.hooks}%
1167 \iftrue
1168 . The names of the \KOMAScript{} options are similar to those for declaring
1169 page style layers, except that a ``\texttt{ps}'' is inserted after
1170 ``\texttt{on}'' at the beginning of the name
1171 \else
1172 , into the names of which a ``\texttt{ps}'' is inserted
1173 \fi
1174 . The values of these \KOMAScript{} options are used as the initial values for
1175 the corresponding hooks. These initial values are then extended by all the
1176 values assigned to the corresponding hooks in the \PName{option list} of the
1177 declaration commands. You can remove the default with
1178 \DescRef{\LabelBase.cmd.ModifyLayerPageStyleOptions}, which is explained later
1179 in this section.%
1180 \EndIndexGroup
1181
1182
1183 \begin{Declaration}
1184 \OptionVName{singlespacing}{simple switch}
1185 \end{Declaration}
1186 If\ChangedAt{v3.24}{\Package{scrlayer}\and \Package{scrlayer-scrpage}} a
1187 document is printed with increased line spacing, e.\,g., using the
1188 \Package{setspace}\IndexPackage{setspace}\important{\Package{setspace}}
1189 package, it is often undesirable for the header and footer to be printed with
1190 this increased spacing. This is particularly true if the header and footer
1191 consist of only a single line. In this case you can use \KOMAScript{} option
1192 \Option{singlespacing}. However, the default\textnote{default} is
1193 \OptionValue{singlespacing}{false}! The option generally applies to all layer
1194 page styles. If you want single-spacing for only some page styles, use
1195 \OptionValue{oninit}{\Macro{linespread}\PParameter{1}\Macro{selectfont}} for
1196 those page styles.%
1197 \EndIndexGroup
1198
1199
1200 \begin{Declaration}
1201 \OptionVName{deactivatepagestylelayers}{simple switch}%
1202 \Macro{ForEachLayerOfPageStyle}\Parameter{page style name}\Parameter{code}%
1203 \Macro{ForEachLayerOfPageStyle*}\Parameter{page style name}\Parameter{code}
1204 \end{Declaration}
1205 \BeginIndex{}{page style>layers}%
1206 \BeginIndex{}{layers>page style}%
1207 As long as the \KOMAScript{} option \Option{deactivatepagestylelayers} is not
1208 enabled, the \Macro{ForEachLayerOfPageStyle} command can execute arbitrary
1209 \PName{code} for each layer of the page style named \PName{page style name}.
1210 Inside of \PName{code}, the place holder \PValue{\#1} serves as a
1211 reference to the name of the current layer.
1212 \begin{Example}
1213 If you want to print the names of all layers of the \PValue{scrheadings}
1214 page style as a comma-separated list, you can use:
1215 \begin{lstcode}
1216 \let\commaatlist\empty
1217 \ForEachLayerOfPageStyle{scrheadings}{%
1218 \commaatlist#1\gdef\commaatlist{, }}
1219 \end{lstcode}
1220 \end{Example}
1221 In\textnote{Attention!} the example above, we had to use \Macro{gdef} instead
1222 of \Macro{def} because \Macro{ForEachLayerOfPageStyle} executes the
1223 \PName{code} inside a group to minimise side effects. However, \Macro{gdef}
1224 redefines \Macro{commaatlist} globally so the change will persist when the
1225 \PName{code} for the next layer is executed.
1226
1227 Alternatively,\ChangedAt{v3.18}{\Package{scrlayer}} you can use \Macro{def}
1228 with the starred variant \Macro{ForEachLayerOfPageStyle*}. This form dispenses
1229 with the extra group when executing \PName{code}. However, the user then has
1230 to take make sure that the \PName{code} has no unwanted side effects. In
1231 particular, deactivating all layers using
1232 \OptionValue{deactivatepagestylelayers}{true} within \PName{code} would
1233 persist beyond the call to \Macro{ForEachLayerOfPageStyle*}.
1234
1235 Various \Package{scrlayer} commands also use \Macro{ForEachLayerOfPageStyle}
1236 internally. Their behaviour can therefore also be changed using the
1237 \KOMAScript{} option \Option{deactivatepagestylelayers}. With this option,
1238 you can temporarily disable and thus hide all layers of all layer page
1239 styles.%
1240 \EndIndexGroup
1241
1242
1243 \begin{Declaration}
1244 \Macro{AddLayersToPageStyle}%
1245 \Parameter{page style name}\Parameter{layer list}%
1246 \Macro{AddLayersAtBeginOfPageStyle}%
1247 \Parameter{page style name}\Parameter{layer list}%
1248 \Macro{AddLayersAtEndOfPageStyle}%
1249 \Parameter{page style name}\Parameter{layer list}%
1250 \Macro{RemoveLayersFromPageStyle}%
1251 \Parameter{page style name}\Parameter{layer list}%
1252 \end{Declaration}
1253 \BeginIndex{}{page style>layers}%
1254 \BeginIndex{}{layers>page style}%
1255 You can use these commands to add layers to a layer page style or to remove
1256 layers from a layer page style. The page style is referenced by its
1257 \PName{page style name}. The layers are given by a comma-separated
1258 \PName{layer list}.
1259
1260 Both the \Macro{AddLayersToPageStyle} and the
1261 \Macro{AddLayersAtEndOfPageStyle}\textnote{add at the end} commands insert the
1262 new layers at the bottom of the page style's layer list. Logically, the newly
1263 added layers lie above or in front of the old layers. Background layers, of
1264 course, still are logically behind the text layer and thus behind all
1265 foreground layers.
1266
1267 In contrast, the \Macro{AddLayersAtBeginOfPageStyle}\textnote{add at the
1268 beginning} command inserts the new layers at the top of the page style's
1269 layer list. The layers are separately inserted to the top of the list in the
1270 same order they appear in the \PName{layer list} parameter. This means that
1271 the last layer in the \PName{layer list} parameter will become the first, and
1272 thus the lowest, layer of the page style.
1273
1274 \iffalse% Umbruchkorrekturtext (beim Aktiveren muss unten \textnote{remove}
1275 % entfernt werden!)
1276 The \Macro{RemoveLayersFromPageStyle} command is exactly the opposite. It
1277 removes\textnote{remove} the specified page-style levels.%
1278 \fi
1279
1280 The \Macro{RemoveLayersFromPageStyle}\textnote{remove} command removes layers
1281 from the layer list of the page style named \PName{page style name}.
1282 Attempting to remove layers which are not part of the page style's layer list
1283 will be ignored. But attempting to add layers to or remove layers from a page
1284 style that is neither a layer page style nor a page-style alias is an error
1285 and will be reported as such.%
1286 \EndIndexGroup
1287
1288
1289 \begin{Declaration}
1290 \Macro{AddLayersToPageStyleBeforeLayer}%
1291 \Parameter{page style name}\Parameter{layer list}%
1292 \Parameter{reference layer name}%
1293 \Macro{AddLayersToPageStyleAfterLayer}%
1294 \Parameter{page style name}\Parameter{layer list}%
1295 \Parameter{reference layer name}
1296 \end{Declaration}
1297 \BeginIndex{}{page style>layers}%
1298 \BeginIndex{}{layers>page style}%
1299 \iffalse% Umbruchvarianten
1300 These two commands are similar to the previous ones, but they take an
1301 additional parameter, \Parameter{reference layer name}. The layer list of
1302 the page style named in \Parameter{page style name} is searched for this
1303 reference layer. %
1304 \else%
1305 These commands are similar to the previous ones. The existing layers of the
1306 page style, however, are searched for the \PName{reference layer name}. %
1307 \fi%
1308 The layers in the \Parameter{layer list} parameter are then inserted
1309 before\textnote{add before/after layer} or after this reference layer%
1310 \iffalse% Umbruchkorrekturtext
1311 in the layers of the page style%
1312 \fi%
1313 . The order of the layers in the \PName{layer list} is retained.
1314
1315 If the reference layer named \PName{reference layer name} is not part of the
1316 given page style, nothing is inserted. On the other hand, if the page style is
1317 neither a layer page style nor a page-style alias, an error will be reported.%
1318 \EndIndexGroup
1319
1320
1321 \begin{Declaration}
1322 \Macro{UnifyLayersAtPageStyle}\Parameter{page style name}
1323 \end{Declaration}
1324 \BeginIndex{}{page style>layers}%
1325 \BeginIndex{}{layers>page style}%
1326 The commands for defining page styles or adding layers to a page style do not
1327 care how many times a layer appears in a page style, so it is quite
1328 permissible for a layer to appear multiple times. In most cases, however, it
1329 does not make sense to use the same layer several times in one page style.
1330 Therefore, you can use \Macro{UnifyLayersAtPageStyle} to remove all layer
1331 duplicates from the layer page style of the specified \Parameter{page style
1332 name}.
1333
1334 Note\textnote{Attention!} that this function can change the order of layers.
1335 So if you need a specific order, you should remove all layers and add the
1336 layers in the order you want instead of using \Macro{UnifyLayersAtPageStyle}.%
1337 \EndIndexGroup
1338
1339
1340 \begin{Declaration}
1341 \Macro{ModifyLayerPageStyleOptions}%
1342 \Parameter{page style name}\Parameter{option list}%
1343 \Macro{AddToLayerPageStyleOptions}%
1344 \Parameter{page style name}\Parameter{option list}
1345 \end{Declaration}
1346 \BeginIndex{}{page style>layers}%
1347 \BeginIndex{}{layers>page style}%
1348 These two commands can be used to modify the options, and thus the
1349 hooks\Index{hooks}, of a layer page style. With
1350 \Macro{ModifyLayerPageStyleOptions}\textnote{change page-style options}, only
1351 the options in the comma-separated \PName{option list} will be set to the new
1352 values given there. The previous values are lost. All options from
1353 \autoref{tab:scrlayer.pagestyle.hooks},
1354 \autopageref{tab:scrlayer.pagestyle.hooks} are allowed. Options or hooks that
1355 are not specified in the \PName{option list} will remain unchanged. If you
1356 want to set an option to do nothing you can set it to the value \Macro{relax}.
1357 Setting an option to a new value using \Macro{ModifyLayerPageStyleOptions}
1358 will remove the previous value, including the global default value. This
1359 statement is the only way to remove the global defaults of the \KOMAScript{}
1360 options from a page style.
1361
1362 \Macro{AddToLayerPageStyleOptions}\textnote{extend page-style options}, on the
1363 other hand, does not overwrite the previous values. Instead it adds\,---\,or,
1364 more precisely, concatenates\,---\, the new values to old ones.%
1365 \EndIndexGroup
1366
1367
1368 \begin{Declaration}
1369 \Macro{IfLayerPageStyleExists}%
1370 \Parameter{page style name}\Parameter{then code}\Parameter{else code}%
1371 \Macro{IfRealLayerPageStyleExists}%^
1372 \Parameter{page style name}\Parameter{then code}\Parameter{else code}%
1373 \end{Declaration}
1374 \BeginIndex{}{page style>layers}%
1375 \BeginIndex{}{layers>page style}%
1376 With these commands, you can execute code depending on whether a page style is
1377 a layer page style or not. The \Macro{IfLayerPageStyleExists} command executes
1378 the \PName{then code} if \PName{page style name} is the name of a layer page
1379 style or a page-style alias that results in a layer page style. Otherwise, the
1380 command executes the \PName{else code}. Internally, this command is often used
1381 to throw an error message if you use one of the layer page style commands with
1382 an \PName{page style name} that does not correspond to a layer page style.
1383
1384 The \Macro{IfRealLayerPageStyleExists} command goes one step further and
1385 executes the \PName{then code} only if the page style specified by \PName{page
1386 style name} is itself a layer page style. So if \PName{page style name} is a
1387 page-style alias, this command executes the \PName{else code} even if the
1388 alias resolves to a real layer page style.%
1389 \EndIndexGroup
1390
1391
1392 \begin{Declaration}
1393 \Macro{IfLayerAtPageStyle}%
1394 \Parameter{page style name}\Parameter{layer name}%
1395 \Parameter{then code}\Parameter{else code}%
1396 \Macro{IfSomeLayerAtPageStyle}%
1397 \Parameter{page style name}\Parameter{layer list}%^
1398 \Parameter{then code}\Parameter{else code}%
1399 \Macro{IfLayersAtPageStyle}%
1400 \Parameter{page style name}\Parameter{layer list}%
1401 \Parameter{then code}\Parameter{else code}%
1402 \end{Declaration}
1403 \BeginIndex{}{page style>layers}%
1404 \BeginIndex{}{layers>page style}%
1405 These commands can be used to test whether one or more layers are part of a
1406 page style. The \Macro{IfLayerAtPageStyle} command expects exactly one
1407 \PName{layer name}\textnote{exactly one layer} as the second argument. If this
1408 layer is part of the page style specified in \PName{page style name}, the
1409 \PName{then code} will be executed. Otherwise, the \PName{else code} will be
1410 executed.
1411
1412 The \Macro{IfSomeLayerAtPageStyle} and \Macro{IfLayersAtPageStyle} commands
1413 allow a comma-separated \PName{layer list}. \Macro{IfSomeLayerAtPageStyle}
1414 will execute the \PName{then code} if \emph{at least one} of the layers in the
1415 \PName{layer list} parameter is part of the layer list of \PName{page style
1416 name}. In contrast, \Macro{IfLayersAtPageStyle} executes the \PName{then
1417 code} only if \emph{all} the layers in the \PName{layer list} parameter are
1418 part of the page style. If the condition is not met, the \PName{else code}
1419 will be executed.
1420
1421 With suitable nesting of these commands, you can construct complex conditions.
1422 If you use only one \PName{layer name} in the \PName{layer list}, all three
1423 statements are synonymous.%
1424 \EndIndexGroup
1425
1426
1427 \begin{Declaration}
1428 \Macro{DestroyRealLayerPageStyle}\Parameter{page style name}
1429 \end{Declaration}
1430 \BeginIndex{}{page style>layers}%
1431 \BeginIndex{}{layers>page style}%
1432 \iftrue
1433 This statement makes a layer page style undefined. If a page-style alias or
1434 ordinary page style is specified, the command is ignored.
1435 \else
1436 With this command you can remove a the definition of a layer page style.
1437 However, this only occurs if a layer page style named \PName{page style name}
1438 exists. If, instead, it is a page-style alias, a different (non-layer) page
1439 style, or not a page style at all, nothing happens; the command is ignored.%
1440 \fi
1441
1442 If \PName{page style name} is the name of the current page style, the current
1443 page style will becomes a kind of empty page style. If the page style set with
1444 \DescRef{maincls.cmd.thispagestyle} is \PName{page style name}, it will simply
1445 be reset. The previous \DescRef{maincls.cmd.thispagestyle} command loses its
1446 current effect.
1447
1448 Note\textnote{Attention!} that the layers of the page style are not destroyed
1449 automatically. If you want to destroy the layers too, you can do this with:
1450 \begin{lstcode}
1451 \ForEachLayerOfPageStyle{...}{\DestroyLayer{#1}}
1452 \end{lstcode}
1453 before destroying the layer page style itself.%
1454 \iffalse % See the note at the beginning of the end user interface section
1455 \par
1456 The command is intended to be used within the \PName{code} argument of
1457 \DescRef{\LabelBase.cmd.scrlayerOnAutoRemoveInterface} to remove page styles
1458 that are defined as part of an end-user interface. See
1459 \autoref{sec:scrlayer.enduserinterfaces} below for more information about
1460 auto-removal code.%
1461 \fi%
1462 \EndIndexGroup
1463 \EndIndexGroup
1464
1465 \LoadCommonFile{headfootheight}% \section{Height of Page Head and Foot}
1466
1467 \LoadCommonFile{pagestylemanipulation}% \section{Manipulation of Defined Page Styles}
1468
1469 \section{Defining and Managing Interfaces for End Users}
1470 \seclabel{enduserinterfaces}
1471
1472 \iftrue% The whole mechanism is deprecated and should not be used any
1473 % longer. So the documentation is also deactivated.
1474 % TODO: Fix new translation
1475 Until version 3.27\ChangedAt{v3.28}{\Package{scrlayer}} package
1476 \Package{scrlayer} provided mechanism to manage concurrent end user
1477 interfaces. The mechanism has been marked as experimental and the usability
1478 limited. Only \KOMAScript{} itself has used this mechanism and from version
1479 3.28 it is marked as deprecated. So the commands
1480 \Macro{scrlayerInitInterface}\IndexCmd{scrlayerInitInterface},
1481 \Macro{scrlayerAddToInterface}\IndexCmd{scrlayerAddToInterface},
1482 \Macro{scrlayerAddCsToInterface}\IndexCmd{scrlayerAddCsToInterface},
1483 \Macro{scrlayerOnAutoRemoveInterface}\IndexCmd{scrlayerOnAutoRemoveInterface}%
1484 \important{\Macro{scrlayerOnAutoRemoveInterface}}
1485 and the options
1486 \Option{forceoverwrite}\IndexOption{forceoverwrite},
1487 \Option{autoremoveinterfaces}\IndexOption{autoremoveinterfaces}
1488 should not be used any longer.%
1489 % :ODOT
1490 \else%
1491 The \Package{scrlayer} package provides an experimental interface to define
1492 and manage (concurrent) interfaces for end users. \iffree{In the long run,
1493 this interface may disappear from \Package{scrlayer} and be taken over by
1494 \Package{scrbase} instead.}{} Currently, this interface is highly
1495 experimental%
1496 \iffree{ and therefore \Package{scrlayer} provides these interface commands
1497 only for the use of subpackages of \Package{scrlayer}}{}%
1498 . Given the current state of development, you should not depend on automatic
1499 removal of a concurrent interface to work. Instead, you should avoid using
1500 concurrent end-user interfaces.
1501
1502 This section only describes the interface commands for defining an end-user
1503 interface. For end users themselves, it is of little interest. Rather, this
1504 section is intended for authors of packages and classes that build on
1505 \Package{scrlayer}. End users will find information about specific end-user
1506 interfaces in \autoref{cha:scrlayer-scrpage},
1507 \autoref{cha:scrlayer-scrpage-experts}, and \autoref{cha:scrlayer-notecolumn}.
1508
1509 \begin{Declaration}
1510 \Macro{scrlayerInitInterface}\OParameter{interface name}
1511 \end{Declaration}
1512 The \Macro{scrlayerInitInterface} command registers a new interface named
1513 \PName{interface name}. The \PName{interface name} must be unique. If an
1514 interface with the same name has already been registered, an error will occur.
1515
1516 This command should always appear as the first command when defining an
1517 end-user interface and therefore is described here first. If the optional
1518 argument\,---\,including the square brackets\,---\,is omitted,
1519 \PValue{\Macro{@currname}.\Macro{@currext}} will be used instead. For classes
1520 and packages, this is the file name of the class or package. But of course you
1521 can use any other sequence of characters with a category of \emph{letter} or
1522 \emph{other}. This is useful, for example, when a class or package defines
1523 multiple end-user interfaces%
1524 \EndIndexGroup
1525
1526
1527 \begin{Declaration}
1528 \OptionVName{forceoverwrite}{simple switch}%
1529 \OptionVName{autoremoveinterfaces}{simple switch}%
1530 \Macro{scrlayerAddToInterface}%
1531 \OParameter{interface name}\Parameter{command}\Parameter{code}%
1532 \Macro{scrlayerAddCsToInterface}%
1533 \OParameter{interface name}\Parameter{command sequence}\Parameter{code}
1534 \end{Declaration}
1535 One of the special features of \Package{scrlayer}'s end user interfaces is
1536 that they should register all interface-dependent commands (also known as
1537 \emph{macros}). You can do this using \Macro{scrlayerAddToInterface}. The
1538 optional argument \PName{interface name} must be an interface name previously
1539 registered with \DescRef{\LabelBase.cmd.scrlayerInitInterface}. An error will
1540 occur if the interface has not been initialised.
1541
1542 If\textnote{Attention!} your interface defines macros not just when the class
1543 or package is being loaded but also at runtime, you must provide the interface
1544 name in the optional argument even if it corresponds to the file name of the
1545 class or package, since the values of \Macro{@currname} and \Macro{@currext}
1546 are only valid while the class or package is being loaded.
1547
1548 The first mandatory argument is the \PName{command}\footnote{The
1549 \PName{command} consists of a backslash followed by a \PName{command
1550 sequence} that consists of characters of the category code \emph{letter},
1551 or of exactly one character of the category \emph{other}, or of a character
1552 of the category \emph{active} (without the backslash).} to be added to the
1553 interface. If the command can be defined, this will be done. In addition, it
1554 will set to \Macro{relax} and \PName{code} will be executed. Within
1555 \PName{code}, you can then define \PName{command}, e.\,g., using
1556 \Macro{newcommand}.
1557
1558 But when can a command be defined? If a command is undefined or \Macro{relax},
1559 it can always be defined. If a command has already been defined \emph{and}
1560 registered for another interface \emph{and} if the \KOMAScript{} option
1561 \Option{autoremoveinterfaces} has been activated, the other interface will be
1562 removed automatically, and the \PName{command} will be set to \Macro{relax}
1563 and registered for the new interface specified. If a \PName{command} is
1564 already defined but is \emph{not} part of another interface, \emph{and} if the
1565 \KOMAScript{} option \Option{forceoverwrite} has been activated, the
1566 \PName{command} is also set to \Macro{relax} and registered for the specified
1567 interface. In all other cases, however, the command is not definable, in
1568 particular if it is already defined and the \KOMAScript{} options
1569 \Option{autoremoveinterfaces} and \Option{forceoverwrite} are deactivated.
1570
1571 The \Macro{scrlayerAddCsToInterface} command is similar to
1572 \Macro{scrlayerAddToInterface} but it expects the first argument to be not a
1573 \PName{command} but a command sequence\footnote{A command sequence must be
1574 fully expandable and its expansion must result in characters of the category
1575 code \emph{letter}, \emph{other}, or \emph{space}.}.%
1576 \EndIndexGroup
1577
1578
1579 \begin{Declaration}
1580 \Macro{scrlayerOnAutoRemoveInterface}%
1581 \OParameter{interface name}\Parameter{code}
1582 \end{Declaration}
1583 The \Macro{scrlayerOnAutoRemoveInterface} command registers \PName{code} to be
1584 executed in the event that the end-user interface with the specified
1585 \PName{interface name} is automatically removed (see
1586 \DescRef{\LabelBase.option.autoremoveinterfaces} earlier in this section).
1587 This can be used, for example, to automatically destroy layers or page styles
1588 that rely on commands from the end-user interface (see
1589 \DescRef{\LabelBase.cmd.DestroyLayer},
1590 \DescRef{\LabelBase.cmd.DestroyPageStyleAlias}, and
1591 \DescRef{\LabelBase.cmd.DestroyRealLayerPageStyle}). Regarding the default for
1592 the optional argument, please refer to the explanation for
1593 \DescRef{\LabelBase.cmd.scrlayerInitInterface}.%
1594 \EndIndexGroup%
1595 \fi%
1596 %
1597 \EndIndexGroup
1598
1599 %%% Local Variables:
1600 %%% mode: latex
1601 %%% TeX-master: "scrguide-en.tex"
1602 %%% coding: utf-8
1603 %%% ispell-local-dictionary: "en_GB"
1604 %%% eval: (flyspell-mode 1)
1605 %%% End: