Example: You can shorten the previous example using the star version of \lohead and
\rohead
:
\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}
The obsolete package scrpage2 does not provide this feature.
212
Chapter 5.
\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 53
), 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
.
Example: Let’s return to the example of the short article. Assuming you want to print the
\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
213
Chapter 5.
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
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
214
Chapter 5.
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.
\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.
215
Chapter 5.
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.
\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 210
and
figure 5.2
on
page 212
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}
216
Chapter 5.
\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
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}
217
Chapter 5.
\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 auto-
matically 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 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. Pagestyle
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.
218
Chapter 5.
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.
\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. So you can fill them only using the commands \markright, \markleft, 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.
219
Chapter 5.
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
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}
220
Chapter 5.
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}
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 38
. 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.
Dostları ilə paylaş: |