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ə23/60
tarix03.02.2017
ölçüsü2,79 Mb.
#7439
1   ...   19   20   21   22   23   24   25   26   ...   60

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

239

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.


\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 }

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

\ifoot


:

\documentclass[twoside]{scrartcl}

\usepackage{scrlayer-scrpage}

\ihead{John Doe}

\ohead{Page style with \KOMAScript}

\ifoot*{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.

pagestyleset=setting

In the examples above you can already find some information about the defaults of

scrheadings

and plain.scrheadings. Indeed scrlayer-scrpage provides two different defaults

yet. You may select one of those defaults manually using option pagestyleset.

If setting is KOMA-Script the defaults will be used that would also be activated automat-

ically if a KOMA-Script class has been detected. In this case and within double-sided layout

scrheadings

uses running heads outer aligned in the page head. The page number will be



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

240

printed outer aligned in the page footer. Within single-sided layout the running head will

be printed in the middle of the page head and the page number in the middle of the page

footer. Upper and lower case will be used for the automatic running head as given by the

words you have typed. This would be same like using Option

markcase=used

. Page style

plain.scrheadings

has not got running heads, but the page numbers will be printed in the

same manner.

If setting is standard the defaults will be used that are similar to page style headings

and plain of the standard classes. This setting will also be activated automatically if

the option has not been used and KOMA-Script class cannot be detected. Within double-

sided layout thereby scrheadings uses running heads aligned inner in the page head and the

page numbers will be printed — also in the page head — aligned outer. Within single-sided

layout scrheadings is the same. But because of single side layout knows only odd pages, the

running head will be aligned left always and the page number will be aligned right. In spite

of typographic objection, the automatic running head will be converted into upper cases like

they would using

markcase=upper

. Within single side layout page style plain.scrheadings

differs a lot from scrheading, because the page number will be printed in the middle of the

page footer. Using double side layout page style plain.scrheadings differs from standard

classes’ plain. The standard classes would print the page number in the middle of the page

footer. But this would not harmonise with the scrheadings, so plain.scrheadings does not

print a page number. But like plain it does not print a running head.

Please note that together with this option page style scrheadings will be activated. This

will be also the case, if you use the option inside the document.

Options komastyle and standardstyle, provided by scrpage, are defined only for compati-

bility reasons in scrlayer-scrpage. But they are implemented using option pagestyleset. They

are deprecated and you should not use them.

5.5. Manipulation of Defined Page Styles

Section 5.4

states the predefined defaults for the page style scrheadings and

plain.scrheadings

and how they can be adapted. But information about the generation of,

i. e., the running heads, the manipulation of the widths of page head and footer, and how you

can get horizontal lines printed above or below the page head or footer are still missing. Even

though all these are features of package scrlayer, they will be described consecutively, because

these basic features of scrlayer are also a fundamental part of the features of scrlayer-scrpage.


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

241

\automark[section level of the right mark ]{section level of the left mark }

\automark*[section level of the right mark ]{section level of the left mark }

\manualmark

automark

autooneside=simple switch

manualmark

With the L

A

TEX standard classes or the KOMA-Script classes the decision whether using automatic



running heads, or static or manual running heads would be done using either page style headings

or myheadings. Automatic running heads are replications of a significant, characterizing text

snippet of the page mostly inside the page head, sometimes in the page footer.

The article classes article or scrartcl with page style headings use the section heading, which

article

,

scrartcl



is either the mandatory or the optional argument of

\section


, for the automatic running head of

single side documents. Double side documents use this section heading as the left mark and at

once use the subsection heading as the right mark. The left mark will be printed on left pages,

which founds the name left mark. The right mark will be printed on right — in single side mode

this means every — page. The classes by default also remove the right mark whenever they put

the section heading into the left mark.

The report and book classes start one level higher. So they use the chapter heading to be the

report


,

scrreprt


,

book


,

scrbook


right mark in single side layout. In double side layout they use the chapter heading to be the left

mark and the section heading to be the right mark.

If you are using myheadings instead of headings, the marks in the page header still exists and

would be printed same like using headings. But section commands will not automatically set the

marks any longer. Soyou can fill them only using the commands

\markright

and

\markboth



,

which will be described later in this section.

This difference between those two page styles has been abolished by scrpage2 and also by

scrlayer. Instead of distinguishing between automatic and manual running head by the selection

of a page style, two new commands, \automark and \manualmark, are provided.

The command \manualmark switches to manual marks and deactivates the automatic filling

of the marks. In contrast to this \automark and \automark* can be used to define, which

section levels should be used for the automatic mark filling. The optional argument is the



section level of the right mark

, the mandatory argument the section level of the



left mark

. The arguments always should be the name of a section level like part, chapter,

section

, subsection, subsubsection, paragraph, or subparagraph.



Generally the higher level should be used for the left mark and the lower level for the right

mark. This is only a convention and not a need, but it makes sense.

Please note that not every class provides running heads for every section level. For example

the standard classes never setup the running head of

\part

. The KOMA-Script classes provide



running heads for every section level.

The difference in \automark and \automark* is, that \automark deletes all prior usages of

\automark

or \automark*, while \automark* changes only the behaviour of the section levels



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

242

of its arguments. So you can even build more complex cases.



Example: Assume you want the chapter heading to be the running head of even pages and

the section heading to be the running head of odd pages like this is usual for books.

But on odd pages you also want the chapter headings as a running head as long

as the first section appears. To do so, you first have to load scrlayer-scrpage and

select page style scrheadings. So you’re document starts with:

\documentclass{scrbook}

\usepackage{scrlayer-scrpage}

\pagestyle{scrheadings}

Next you will setup the chapter heading to be not only the left but also the right

mark:


\automark[chapter]{chapter}

Then the section heading should also become a right mark:

\automark*[section]{}

Here the star version is used, because the prior \automark command should be

still valid. Additionally the mandatory argument for the section level of the

left mark

is empty, because this mark should be unchanged.

Now you just need some document contents to see a result:

\usepackage{lipsum}

\begin{document}

\chapter{Chapter Heading}

\lipsum[1-20]

\section{Section Heading}

\lipsum[21-40]

\end{document}

We once again use package lipsum to generate some dummy text with command

\lipsum


. The package is really useful.

If you’d test the example, you’d see, that the chapter start page does not have a

running head as usual. This is, because it automatically uses the plain page style

plain.scrheadings

. Pages 2–4 have the chapter headings in the running head.

After the section heading on page 4 the running head of page 5 changes into this

section heading. From this page to the end the running head alternates between

chapter and section heading from page to page.

Instead of the commands you may also use the options manualmark and automark to switch

between manual and automatic running heads. Thereby automark always uses the default

\automark[section]{chapter}


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

243

for classes with

\chapter

and


\automark[subsection]{section}

for classes without

\chapter

.

But normally in single side mode you do not want that the lower level influences the right



mark, you want the higher level, that will fill only the left mark in double side layout, to be

the running head of all pages. The default option autooneside corresponds to this behaviour.

The option understands the values for simple switches, that can be found in

table 2.5

on

page 39


. If you’d deactivate the option, in single side layout the optional and the obligatory

arguments of \automark and \automark* will influence the running head again.



Example: Assume you have a single sided report but want similar running heads as in the

book example before. The chapter headings should be used as a running head as

long as the first section appears. From the first section on, the section heading

should be used. So we modify the previous example a little bit:

\documentclass{scrreprt}

\usepackage[autooneside=false]{scrlayer-scrpage}

\pagestyle{scrheadings}

\automark[section]{chapter}

\usepackage{lipsum}

\begin{document}

\chapter{Chapter Heading}

\lipsum[1-20]

\section{Section Heading}

\lipsum[21-40]

\end{document}

You can see, that we do not need a \automark* command in this case. Please

try the example also with autooneside set to true or remove the option and its

value. You should find a difference at the running head in the pages’ head from

page 4 on.

Please note, only loading the package does not have any effect on the fact whether automatic

or manual running heads are used or what kind of section headings do fill up the marks. Only

using an explicit option automark or manualmark or one of the commands \automark or

\manualmark

can reach a well defined state.

draft=simple switch

This KOMA-Script option understands the values for simple switches, that are shown in

table 2.5

on

page 39



. If the option is active, all elements of the page styles will also show

dimension lines. This might be useful while draft editing.If the option has been set as a global

option (see the optional argument of

\documentclass

), but you do not want the dimension


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

244

lines, you can deactivate them for the package only using draft=false as an optional argument

of

\usepackage



while loading the package.

\MakeMarkcase{string }

The automatic running head and only this uses \MakeMarkcase for its output. If the command

has not been defined, e. g., by the class, while loading scrlayer, it would be defined with

the default of outputting the argument string without changes. But the default can be

change either redefining \MakeMarkcase or using option

markcase

, that will be described

next. Depending on the setting the argument could, e. g., be converted into upper or lower

cases.


markcase=Wert

As already mentioned with scrlayer you may switch between manual and automatic running

heads. Using automatic running heads the corresponding marks will be filled by the section

heading commands. Some culture areas do convert the running heads into upper case letters

in opposite to the German typographic habit. The L

A

TEX standard classes do so by default.



Package scrlayer optionally provides this too. Therefor you’d use option markcase=upper

which results in a redefinition of

\MakeMarkcase

, a command, that is used by scrlayer for

automatic running heads.

Unfortunately L

A

TEX’s command for upper case letter typesetting, \MakeUppercase results



in an very inadequate typesetting, because it neither uses letter spacing nor does it space

balancing. One reason for this behaviour might be, that a glyph analyzing would be needed,

to incorporate the letter shapes and their combination while space balancing. Because of

this KOMA-Script author suggests to abstain from upper case letter typesetting for run-

ning heads. This could be achieved using markcase=used. Nevertheless, some classes would

add \MarkUppercase or even TEX command \uppercase into the running heads. For such

cases option markcase=noupper can be used. This will also deactivate \MakeUppercase and

\uppercase

inside the running heads.

You can find all valid values for markcase in

table 5.2

.

\leftmark



\rightmark

\headmark

\pagemark

If you want to differ from the predefined page styles, usually you need to decide, where to

place the marks’ contents. With \leftmark you can state the contents of the left mark.

Similar you can use \rightmark to state the contents of the right mark. For more in-

formation about some intricacies of this see the further description of

21.1


in

section 21.1

,

page 441


.

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

245

Table 5.2.: Possible values for option markcase to select upper/lower case letter typesetting in auto-

matic running heads

lower


redefines

\MakeMarkcase

to convert the automatic running heads into lower case

letters using \MakeLowercase (lower case typesetting).

upper

redefines


\MakeMarkcase

to convert the automatic running heads into upper case

letters using \MakeUppercase (upper case typesetting).

used


redefines

\MakeMarkcase

to use automatic running heads without any case changes.

ignoreuppercase

, nouppercase, ignoreupper, noupper

redefines not only

\MakeMarkcase

but also locally to the running heads

\MakeUppercase

and \uppercase to leave the automatic running heads unchanged.

Somehow easier would be usage of \headmark. This extension of scrlayer aliases either

\leftmark

or \rightmark depending on whether the current page is even or odd.

Strictly thought command \pagemark is not involved by TEX’s mark mechanism. It is only

used to output a formatted page number. The font of element pagenumber will be used for

the output. This can be changed using command \setkomafont or

\addtokomafont

(see also

section 3.6

,

page 57



).

Example: Assume you want to use a left aligned running head and right aligned page number

in the head of the pages of a document in single side layout. The following minimal

but working examples would do so:

\documentclass{scrreprt}

\usepackage{blindtext}

\usepackage[automark]{scrlayer-scrpage}

\pagestyle{scrheadings}

\ihead{\headmark}

\ohead[\pagemark]{\pagemark}

\chead{}

\cfoot[]{}

\begin{document}

\blinddocument

\end{document}

Here package blindtext with its command \blinddocument has been used to easily

generate content for an example document.

Commands

\ihead


and

\ohead


have been used to place the wanted marks. Al-

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

246

though the page mark will be place not only to pages in page style scrheadings

but using the optional argument also to pages in page style plain.scrheadings.

Because of both page styles already have marks in the middle of the page head

and page foot, those elements will be cleared using

\chead


and

\cfoot


with empty

arguments. Alternatively you’d use

\clearpairofpagestyles

before

\ihead


. You

will find a description of this command in

section 18.2

.

Please note, that the empty optional argument of



\cfoot

in the example above is not the

same like omitting the optional argument. Please try it out and have a look at the difference

in the footer of the first page.

If all the mark features described above are not sufficient, experienced users can find more

of them on

page 415

. For example, you can find there

\leftfirstmark

and


\rightbotmark

,

which seem to be useful for lexicon like documents.



\partmarkformat

\chaptermarkformat

\sectionmarkformat

\subsectionmarkformat

\subsubsectionmarkformat

\paragraphmarkformat

\subparagraphmarkformat

Usually the KOMA-Script classes and package scrlayer use these commands internally to bring

the section numbers into wanted form and additionally they support the

\autodot


mechanism

of the KOMA-Script classes. If wanted these commands may be redefined to get another form

of section numbers.

Example: Assume you do not want section numbers but section heading text only in the

running head. So:

\renewcommand*{\sectionmarkformat}{}

would be a simple solution for this.



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

247

\partmark{Text }

\chaptermark{Text }

\sectionmark{Text }

\subsectionmark{Text }

\subsubsectionmark{Text }

\paragraphmark{Text }

\subparagraphmark{Text }

Most classes use these commands to setup marks corresponding to the section commands.

Thereby the only argument is the text without the number of the section heading, that should

be used for the running head. For the number simply the number of the current section level

will be used, if the current level uses numbers.

Unfortunately, not all classes use such a command for every section level. The standard

classes for example do not call \partmark. The KOMA-Script classes support such commands

for all section levels and therefore also use \partmark.

If users redefine these commands, they should take care to also use the counter

secnumdepth

for the test whether or not the section level should output a number, even in the case the user

does not change counter

secnumdepth

himself, because packages and classes may do so locally

and rely on correct handling of

secnumdepth

.

However, package scrlayer redefines these commands whenever you use



\automark

or

\manualmark



or the corresponding options, to activate or deactivate the wanted running heads.

\markleft{left mark }

\markright{right mark }

\markboth{left mark }{right mark }

Independent of whether currently manual or automatic running heads are active, you may

change the contents of the left mark or the right mark at any time using these com-

mands. You should note, that the resulting contents of \leftmark is the left mark of the

last \markleft or \markboth command of the current page. In opposite to this the resulting

contents of \rightmark is the right mark of the first \rightmark or \markboth command

of the current page.

If you are using manual running heads, the marks will stay valid until one of the corre-

sponding commands will be used again. If you are using automatic running heads the marks

can loose their validity with the next section heading depending on the configuration of the

automatism.

You may also use these commands together with the star versions of the section commands.


Yüklə 2,79 Mb.

Dostları ilə paylaş:
1   ...   19   20   21   22   23   24   25   26   ...   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