Note: This document is a translation of the German koma script manual


Chapter 5: Adapting Page Headers and Footers with scrlayer-scrpage



Yüklə 2,79 Mb.
Pdf görüntüsü
səhifə22/60
tarix03.02.2017
ölçüsü2,79 Mb.
#7439
1   ...   18   19   20   21   22   23   24   25   ...   60

Chapter 5: Adapting Page Headers and Footers with scrlayer-scrpage

230

\usefontofkomafont{element }

\useencodingofkomafont{element }

\usesizeofkomafont{element }

\usefamilyofkomafont{element }

\useseriesofkomafont{element }

\useshapeofkomafont{element }

Sometimes

v3.12

and despite the recommendation users use the font setting feature of elements



not only for font settings but for other settings too. In this case it may be useful to

switch only to the font setting of an element but not to those other settings. You may

use \usefontofkomafont in such cases. This will activate the font size and baseline skip, the

font encoding, the font family, the font series, and the font shape of an element, but no further

settings as long as those further settings are local.

You may also switch to one of those attributes only using one of the other commands. Note,

that \usesizeofkomafont will activate both, the font size and the baseline skip.

You should not misunderstand these commands as a legitimation of using all kind of com-

mands at the font setting of an element. Hence this would result in errors sooner or later (see

section 21.3

,

page 444


).

5.4. Usage of Predefined Page Styles

The easiest way to your desired design for page header and footer with scrlayer-scrpage is to

use one of the predefined page styles.

\pagestyle

{scrheadings}

\pagestyle

{plain.scrheadings}

Package scrlayer-scrpage provides two page styles, which may be reconfigured to meet your

individual reqirements. Let’s first of all discuss page style scrheadings which has been de-

signed as a style using running heads. Its defaults are similar to the page style headings

of the L

A

TEXstandard classes or the KOMA-Script classes. What exactly gets printed in the



header or footer can be configured via the commands and otions described hereafter.

The second page style to be mentioned here is plain.scrheadings, which has been designed

to be a style with no running head. Its defaults are very similar to page style plain of L

A

TEX’s



standard classes or the KOMA-Script classes. The following will describe the commands and

options you may use to adjust the contents of the header and footer .

You could of course configure scrheadings to be a page style without a running head

and plain.scrheadings to be a page style using running heads. It is, however, far

more expedient to adhere to the conventions mentioned above, if for the only reason that

both page styles mutually influence one another. Once you have opted to apply one of

these page styles, scrheadings will become accessible as headings and the page style


Chapter 5: Adapting Page Headers and Footers with scrlayer-scrpage

231

plain.scrheadings

will become accessible as plain. Thus, if you use a class or package that

automatically switches between headings and plain, you only need to select scrheadings

or plain.scrheadings once and the switching class or package will then switch between

scrheadings

and plain.scrheadings without even being aware of these page styles. Patches

or other adaptions of classes (or packages) will not be necessary. This pair of page styles may

thus serve as a drop-in replacement for headings and plain. Should additional similar pairs

be required I’d like to point you to

section 18.2

in

part II



for further reference.

For users of the older scrpage2, I’d like to mention that, for compatibility with scrpage2,

page style plain.scrheadings may also be used under its alias name of scrplain.

\lehead[plain.scrheadings’s content ]{scrheadings’s content }

\cehead[plain.scrheadings’s content ]{scrheadings’s content }

\rehead[plain.scrheadings’s content ]{scrheadings’s content }

\lohead[plain.scrheadings’s content ]{scrheadings’s content }

\cohead[plain.scrheadings’s content ]{scrheadings’s content }

\rohead[plain.scrheadings’s content ]{scrheadings’s content }

The contents of the header of page style plain.scrheadings and scrheadings can be defined

using these commands. Thereby the optional argument defines the content of an element

of page style plain.scrheadings, while the mandatory argument sets the content of the

corresponding element of page style scrheadings.

Contents of left — so called even — pages can be set with \lehead, \cehead, and \rohead.

Remark: The “e” at the second position of the commands’ names means “even”.

Contents of right — so called odd — pages can be set with \lohead, \cohead, and \rohead.

Remark: The “o” at the second position of the commands’ names means “odd”.

Please note that there are only odd pages within single side layouts independent of whether

or not they have an odd page number.

Each header consists of a left aligned element that will be defined by \lehead respectively

\lohead

. Remark: The “l” at the first position of the commands’ names means “left aligned”.



Similarly each header has a centred element that will be defined by \cehead respectively

\cohead


. Remark: The “c” at the first position of the command’ names means “centred”.

Similarly each header has a right aligned element that will be defined by \rehead respec-

tively \rohead. Remark: The “r” at the first position of the commands’ names means “right

aligned

”.

However, these elements do not have their own font attributes that may be changed using



commands

\setkomafont

and

\addtokomafont



(see

section 3.6

,

page 57


), but are grouped

in an element named pagehead. And before the font of that element additionally the font of

element pageheadfoot will be used. See

table 5.1

for the font default of these elements.

The semantics of the described commands within two-sided layouts are also sketched in

figure 5.1

.


Chapter 5: Adapting Page Headers and Footers with scrlayer-scrpage

232

\lehead


\rehead

\cehead


\lohead

\rohead


\cohead

\ihead


\chead

\ohead


6

6

6



6

6

6



Figure 5.1.: The meaning of the commands to define the contents of the page head of the page styles

sketched on a schematic double page



Example: Assume you’re writing a short article and you want the title of that article to be

shown left aligned and the author’s name to be shown right aligned at the page

head. You may for example use:

\documentclass{scrartcl}

\usepackage{scrlayer-scrpage}

\lohead{John Doe}

\rohead{Page style with \KOMAScript}

\pagestyle{scrheadings}

\begin{document}

\title{Page styles with \KOMAScript}

\author{John Doe}

\maketitle

\end{document}

But what happens: On the first page there’s only a page number at the page foot,

but the header is empty!

The explanation is very easy. Document class scrartcl switches to page style plain

for the page with the title head. After command

\pagestyle

{scrheadings}

in the preamble of the short document this will actually result in page style

plain.scrheadings

. Using a KOMA-Script class the default of this page style

is an empty page header and a page number in the footer. In the example

code the optional arguments of \lohead and \rohead are omitted. So page style

plain.scrheadings

remains unchanged as default and the result for the first page

is indeed correct.

Please add some text below

\maketitle

until a second page will be printed. Al-

ternatively you may just add \usepackage{lipsum} into the document preamble

and \lipsum below

\maketitle

. You will see that the head of the second page

will show the author and the document title as we wanted.

To see the difference you should also add an optional argument to \lohead and

\rohead

containing some content. To do so, change the example above:



Chapter 5: Adapting Page Headers and Footers with scrlayer-scrpage

233

\documentclass{scrartcl}

\usepackage{scrlayer-scrpage}

\lohead[John Doe]

{John Doe}

\rohead[Page style with \KOMAScript]

{Page style with \KOMAScript}

\pagestyle{scrheadings}

\begin{document}

\title{Page styles with \KOMAScript}

\author{John Doe}

\maketitle

\end{document}

Now, you also get a page header above the title head of the first page. That

is because you have reconfigured page style plain.scrheadings with the two

optional arguments. Most of you will also recognise that it would be better to

leave this page style unchanged, because the running head above the document

title is certainly annoying.

Allow me an important note: You should never put a section heading or section number

directly into the page head using a new declaration by one of these commands. This could

result in a wrong number or heading text in the running head, because of the asynchronous

page generation and output of TEX. Instead you should use the mark mechanism and ideally

you should use it together with the automatism described in the following section.

\lehead*[plain.scrheadings’s content ]{scrheadings’s content }

\cehead*[plain.scrheadings’s content ]{scrheadings’s content }

\rehead*[plain.scrheadings’s content ]{scrheadings’s content }

\lohead*[plain.scrheadings’s content ]{scrheadings’s content }

\cohead*[plain.scrheadings’s content ]{scrheadings’s content }

\rohead*[plain.scrheadings’s content ]{scrheadings’s content }

The previously described commands have also a version with star

v3.14

that differs only if you omit



the optional argument plain.scrheadings’s content . In this case the version without star

does not change the content of plain.scrheadings. The version with star on the other hand

uses the obligatory argument scrheading’s content also as default for plain.scrheadings.

So, if both arguments should be the same, you can simply use the star version with the

obligatory argument only.

Example: You can shorten the previous example using the star version of

\lohead


and

\rohead


:

\documentclass{scrartcl}

\usepackage{scrlayer-scrpage}


Chapter 5: Adapting Page Headers and Footers with scrlayer-scrpage

234

\lohead*{John Doe}

\rohead*{Page style with \KOMAScript}

\pagestyle{scrheadings}

\begin{document}

\title{Page styles with \KOMAScript}

\author{John Doe}

\maketitle

\end{document}

The obsolete package scrpage2 does not provide this feature.

\lefoot[plain.scrheadings’s content ]{scrheadings’s content }

\cefoot[plain.scrheadings’s content ]{scrheadings’s content }

\refoot[plain.scrheadings’s content ]{scrheadings’s content }

\lofoot[plain.scrheadings’s content ]{scrheadings’s content }

\cofoot[plain.scrheadings’s content ]{scrheadings’s content }

\rofoot[plain.scrheadings’s content ]{scrheadings’s content }

The contents of the footer of page style plain.scrheadings and scrheadings can be defined

using these commands. Thereby the optional argument defines the content of an element

of page style plain.scrheadings, while the mandatory argument sets the content of the

corresponding element of page style scrheadings.

Contents of left — so called even — pages can be set with \lefoot, \cefoot, and \rohead.

Remark: The “e” at the second position of the commands’ names means “even”.

Contents of odd pages can be set with \lofoot, \cofoot, and \rofoot. Remark: The “o”

at the second position of the commands’ names means “odd”.

Please note that there are only odd pages within single side layouts independent of whether

or not they have an odd page number.

Each footer consists of a left aligned element that will be defined by \lefoot respectively

\lofoot


. Remark: The “l” at the first position of the commands’ names means “left aligned”.

Similarly each footer has a centred element that will be defined by \cefoot respectively

\cofoot

. Remark: The “c” at the first position of the command’ names means “centred”.



Similarly each footer has a right aligned element that will be defined by \refoot respectively

\rofoot


. Remark: The “r” at the first position of the commands’ names means “right aligned”.

However, these elements do not have their own font attributes that may be changed using

commands

\setkomafont

and

\addtokomafont



(see

section 3.6

,

page 57


), but are grouped

in an element named pagefoot. And before the font of that element additionally the font

of element pageheadfoot will be used. See

table 5.1

for the defaults of the fonts of these

elements.

The semantics of the described commands within two-sided layouts are also sketched in

figure 5.2

.


Chapter 5: Adapting Page Headers and Footers with scrlayer-scrpage

235

Example: Let’s return to the example of the short article. Assuming you want to print the

publisher at the left side of the page footer, you would change the example above

into:

\documentclass{scrartcl}



\usepackage{scrlayer-scrpage}

\lohead{John Doe}

\rohead{Page style with \KOMAScript}

\lofoot{Smart Alec Publishing}

\pagestyle{scrheadings}

\usepackage{lipsum}

\begin{document}

\title{Page styles with \KOMAScript}

\author{John Doe}

\maketitle

\lipsum

\end{document}

Once again the publisher is not printed on the first page with the title head. For

the reason see the explanation about \lohead in the example above. And again

the solution to print the publisher on the first page would be similar:

\lofoot[Smart Alec Publishing]

{Smart Alec Publishing}

But now you also want to replace the slanted font used in page head and footer

by a upright smaller font. This may be done using:

\setkomafont{pageheadfoot}{\small}

Furthermore, the head but not the footer should be bold:

\setkomafont{pagehead}{\bfseries}

For the last command it is important to have it just after scrpage-scrlayer has

been loaded, because the KOMA-Script class already defines

pagehead

and


pageheadfoot

but with the same meaning. Only loading scrpage-scrlayer changes

\lefoot

\refoot


\cefoot

\lofoot


\rofoot

\cofoot


\ifoot

\cfoot


\ofoot

?

?



?

?

?



?

Figure 5.2.: The meaning of the commands to define the contents of the page footer of the page styles

sketched on a schematic double page


Chapter 5: Adapting Page Headers and Footers with scrlayer-scrpage

236

the meaning of

pagehead

and makes it an element independent of

pageheadfoot

.

Now, please add one more \lipsum and add option twoside to the loading of



scrartcl. First of all, you will see the page number moving from the middle of the

page footer to the outer margin, due to the changed defaults of scrheadings and

plain.scrheadings

using double-sided layout and a KOMA-Script class.

Simultaneously the author, document title and publisher will vanish from page 2.

It only appears on page 3. This is a consequence of using only commands for odd

pages. You can recognise this by the “o” on the second position of the commands’

names.


Now, we could simply copy those commands and replace the “o” by an “e” to

define the contents of even pages. But with double sided layout it makes more

sense to use mirror-inverted elements. So the left element of an odd page should

become the right element of the even page and visa versa. To achieve this, we also

replace the first letter “l” by “r”:

\documentclass[twoside]{scrartcl}

\usepackage{scrlayer-scrpage}

\lohead{John Doe}

\rohead{Page style with \KOMAScript}

\lofoot[Smart Alec Publishing]

{Smart Alec Publishing}

\rehead{John Doe}

\lohead{Page style with \KOMAScript}

\refoot[Smart Alec Publishing]

{Smart Alec Publishing}

\pagestyle{scrheadings}

\usepackage{lipsum}

\begin{document}

\title{Page styles with \KOMAScript}

\author{John Doe}

\maketitle

\lipsum\lipsum

\end{document}

After reading the example it may appear to you that it is somehow uncomfortable to duplicate

commands to have the same contents on mirror positions of the page header or footer of a

double page. Therefore you will learn to know an easier solution for this standard case next.

Before allow me an important note: You should never put a section heading or section

number directly into the page’s footer using a new declaration by one of these commands.

This could result in a wrong number or heading text in the running footer, because of the

asynchronous page generation and output of TEX. Instead you should use the mark mechanism

ideally together with the automatism described in the following section.


Chapter 5: Adapting Page Headers and Footers with scrlayer-scrpage

237

\lefoot*[plain.scrheadings’s content ]{scrheadings’s content }

\cefoot*[plain.scrheadings’s content ]{scrheadings’s content }

\refoot*[plain.scrheadings’s content ]{scrheadings’s content }

\lofoot*[plain.scrheadings’s content ]{scrheadings’s content }

\cofoot*[plain.scrheadings’s content ]{scrheadings’s content }

\rofoot*[plain.scrheadings’s content ]{scrheadings’s content }

The previously described commands have also a version with star

v3.14

that differs only if you omit



the optional argument plain.scrheadings’s content . In this case the version without star

does not change the content of plain.scrheadings. The version with star on the other hand

uses the obligatory argument scrheading’s content also as default for plain.scrheadings.

So, if both arguments should be the same, you can simply use the star version with the

obligatory argument only.

Example: You can shorten the previous example using the star version of

\lofoot


and

\refoot


:

\documentclass[twoside]{scrartcl}

\usepackage{scrlayer-scrpage}

\lohead{John Doe}

\rohead{Page style with \KOMAScript}

\lofoot*{Smart Alec Publishing}

\rehead{John Doe}

\lohead{Page style with \KOMAScript}

\refoot*{Smart Alec Publishing}

\pagestyle{scrheadings}

\usepackage{lipsum}

\begin{document}

\title{Page styles with \KOMAScript}

\author{John Doe}

\maketitle

\lipsum\lipsum

\end{document}

The obsolete package scrpage2 does not provide this feature.



Chapter 5: Adapting Page Headers and Footers with scrlayer-scrpage

238

\ohead[plain.scrheadings’s content ]{scrheadings’s content }

\chead[plain.scrheadings’s content ]{scrheadings’s content }

\ihead[plain.scrheadings’s content ]{scrheadings’s content }

\ofoot[plain.scrheadings’s content ]{scrheadings’s content }

\cfoot[plain.scrheadings’s content ]{scrheadings’s content }

\ifoot[plain.scrheadings’s content ]{scrheadings’s content }

To define the contents of page headers and footers of odd and the even pages of a double-sided

layout using the commands described before, you would have to define the contents of the

even page different from the contents of the odd page. But in general the pages should be

symmetric. An element, that should be printed left aligned on an even page, should be right

aligned on an odd page and vise versa. Elements, that are centred on odd pages, should be

centred on even pages too.

To simplify the definition of such symmetric page styles, scrlayer-scrpage provides a kind of

abbreviation. Command \ohead is same like usage of both

\lehead


and

\rohead


. Command

\chead


is same like

\cehead


and

\cohead


. And command \ihead is same like

\rehead


and

\lohead


. The corresponding commands for the page footer are defined accordingly. A sketch

of these commands can be found also in

figure 5.1

on

page 232



and

figure 5.2

on

page 235


together with the relationships of all the page header and footer commands.

Example: You can simplify the example before using the new commands:

\documentclass[twoside]{scrartcl}

\usepackage{scrlayer-scrpage}

\ihead{John Doe}

\ohead{Page style with \KOMAScript}

\ifoot[Smart Alec Publishing]

{Smart Alec Publishing}

\pagestyle{scrheadings}

\usepackage{lipsum}

\begin{document}

\title{Page styles with \KOMAScript}

\author{John Doe}

\maketitle

\lipsum\lipsum

\end{document}

As you can see, you can spare half of the commands but get the same result.

In single-sided layouts all pages are odd pages. So in LaTeX’s single-sided mode these com-

mands are synonymous for the odd page commands. Therefore in most cases you will only

need these six commands instead of the twelve described before.

Once again, allow me an important note: You should never put a section heading or section

number directly into the page head or page foot using a new declaration by one of these

commands. This could result in a wrong number or heading text in the running header or



Yüklə 2,79 Mb.

Dostları ilə paylaş:
1   ...   18   19   20   21   22   23   24   25   ...   60




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin