Example: Assume you are using a preface with several pages just before the table of contents,
that should not have an entry at the table of contents itself. Because of using a
separation line at the page head, you want also a running head for this preface:
\documentclass[headsepline]{book}
Chapter 5: Adapting Page Headers and Footers with scrlayer-scrpage
248
\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}
\usepackage{blindtext}
\begin{document}
\chapter*{Preface}
\markboth{Preface}{Preface}
\blindtext[20]
\tableofcontents
\blinddocument
\end{document}
First of all this seems to produce the wanted result. But have a closer look: In
difference to the other running heads “Preface” is not in upper case letters. But
you can fix this easily:
\documentclass[headsepline]{book}
\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}
\usepackage{blindtext}
\begin{document}
\chapter*{Preface}
\markboth{\MakeMarkcase{Preface}}{\MakeMarkcase{Preface}}
\blindtext[20]
\tableofcontents
\blinddocument
\end{document}
Using command
\MakeMarkcase
results in getting the same letter case as for au-
tomatic running heads.
Now, let’s move command
\tableofcontents
in front of the preface. Let’s remove
the \markboth command too. You’ll realise, that the preface now has the running
head “CONTENTS”. This is because of a quirk of
\chapter*
(see also
section 3.16
on
page 99
). If in such cases the running head should be removed, \markboth with
two empty arguments would be useful:
\documentclass[headsepline]{book}
\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\chapter*{Preface}
\markboth{}{}
\blindtext[20]
\blinddocument
\end{document}
Chapter 5: Adapting Page Headers and Footers with scrlayer-scrpage
249
headwidth=width :offset :offset
footwidth=width :offset :offset
By default the page head and foot are as wide as the type area. This can be changed using
these KOMA-Script options. The value width is the wanted width of the head respective
foot. The offset defines how much the head or foot should be moved towards the outer — in
single side layout to the right — margin. All three
v3.14
values are optional and can be omitted. If
you omit a value, you can also omit the corresponding colon left beside. If there is only one
offset
it is used for both, odd and even pages. Otherwise, the first offset is used for odd
and the second offset for even pages in two-side mode. If you only use one value without
colon, this will be the width .
For the width as well as the offset you can use any valid length value, L
A
TEX length, TEX
dimension or TEX skip. In addition you may use an ε-TEX dimension expression with basic
arithmetic operations +, -, *, /, and parenthesis. See [
Tea98
, section 3.5] for more information
on such expressions. See
section 5.1
for more information on using, e. g., a L
A
TEX length as an
option value. The width can alternatively be one of the symbolic values shown in
table 5.3
.
By default the head and the foot are as wide as the text area. The default offset depends
on the used width . In single side layout generally the half of the difference of width and the
width of the text area will be used. This results in horizontal centring the page head above
or the page footer below the text area. In difference to this, in double side layout generally a
third of the difference of offset and the width of the text area will be used. But if width is
the width of the whole text area plus the marginal note column, default offset will be zero.
If you think, this is complicated, you should simply use an explicit offset .
headtopline=thickness :length
headsepline=thickness :length
footsepline=thickness :length
footbotline=thickness :length
The KOMA-Script classes provide only a separation line below the page head and above the
page head, and you may only switch each of these lines on or off. But package scrlayer-scrpage
provides four such horizontal lines: one above the head, one below the head, one above the
foot, and one below the foot. And you can not only switch them on an off, but also configure
the length and thickness of each of these lines.
Both values are optional. If you omit the thickness , a default value of 0.4 pt will be used,
a so called hairline. If you omit the length , the width of the head respective the foot will be
used. If you omit both, you can also omit the colon. If you use only one value without colon,
this will be the thickness .
For sure, the length can be not only shorter than the current width of the page head
respectively the page foot, but also longer. See additionally options
ilines
,
clines
, and
olines
later in this section.
Chapter 5: Adapting Page Headers and Footers with scrlayer-scrpage
250
Table 5.3.: Possible symbolic values for the width value of options headwidth and footwidth
foot
the current width of the page foot
footbotline
the current length of the horizontal line below the page foot
footsepline
the current length of the horizontal line above the page foot
head
the current width of the page head
headsepline
the current length of the horizontal line below the page head
headtopline
the current length of the horizontal line above the page head
marginpar
the current width of the marginal note column including the distance between the
text area and the marginal note column
page
the current width of the page considering a binding correction of package typearea
(see option
BCOR
in
section 2.6
,
page 31
)
paper
the current width of the paper without considering a binding correction
text
the current width of the text area
textwithmarginpar
the current width of the text area plus the marginal note column including the
distance between them (note: in this case and only in this case the default of offset
would be zero)
Chapter 5: Adapting Page Headers and Footers with scrlayer-scrpage
251
Beside the length and thickness also the colour of the lines can be changed. First of all the
colour depends on the colour of the head or foot. But independent from those or additional to
them the settings of the corresponding elements headtopline, headsepline, footsepline,
and footbotline will be used. You may change these using command
\setkomafont
or
\addtokomafont
(see
section 3.6
from
page 57
). By default those settings are empty, which
means no change of the current font or colour. Change of font in opposite to colour would not
make sense and is not recommended for these elements.
Package scrpage2 has additionally to the options that do not take any values, also four
commands \setheadtopline, \setheadsepline, \setfootsepline, and \setfootbotline.
These have a first optional argument for the length , a second mandatory argument for
the thickness , and a third optional argument for the setting of font or colour. Package
scrlayer-scrpage does also provide those commands. Nevertheless, these commands are depre-
cated and should not be used any longer. To get it clear: These commands have never been
made to switch the lines on or off. They have been made to configure already switched on
lines. Users often ignored this!
plainheadtopline=simple switch
plainheadsepline=simple switch
plainfootsepline=simple switch
plainfootbotline=simple switch
These options can be used to inherit the settings of the lines also for the plain page style.
Possible values for simple switch can be found in
table 2.5
on
page 39
. If a option is
activated, the plain page style will use the line settings given by the options and commands
described above. If the option is deactivated, the plain will not show the corresponding line.
ilines
clines
olines
You have already been told that the horizontal lines above or below the page head or foot can
be shorter or longer than the page head or page foot itself. Only the answer to the question
about the alignment of those lines is still missing. By default all lines are left aligned at single
side layout and aligned to the inner margin of the head or foot at double side layout. This is
same like using option ilines. Alternatively, you can use option clines to centre the lines
in the head or foot, or option olines to align them right respectively to the outer margin.
Chapter 6: The Day of the Week Using scrdate
252
The Day of the Week Using scrdate
With version 3.05a the functionality of this package enhanced a lot. Beside of the current day
of the week this package provides the day of the week of every date of the Gregorian calendar
now.
\CenturyPart{ year }
\DecadePart{year }
The
v3.05a
command \CenturyPart offers the value of the century digits — hundreds and thou-
sands — of a year . The command \DecadePart in difference offers the other digits which are
the units and tens. The number of digits of year does not care. The value may be assigned
to a counter or may be used for calculations, i. e., using \numexpr. For output of an Arabic
number of the value prefix it with \the.
Example: You want to calculate and output the century of the current year.
The year \the\year\ is the year \the\DecadePart{\year}
of the \engord{\numexpr\CenturyPart{\year}+1\relax} century.
The result would be:
The year 2017 is the year 17 of the 21st century.
Package engord has been used for this example. See [
Obe10
] for more information.
Please note, that within used method of counting the year 2000 is the year 0 — and therefore
the first year — of the 21st century.
\DayNumber{year }{month }{day }
\ISODayNumber{ISO-date }
These
v3.05a
two commands offers the value of the number of the day of the week of any date. The
differ only in the kind of date declaration. Command \DayNumber needs year , month , and
day
as separate parameters. Command \ISODayNumber expects an ISO-date as a single
argument. The expected format of the ISO-date is: year -month -day . It does not matter
whether month or day have one or two digits. The result of both commands may be assigned
to a counter or used for calculations, i. e., using \numexpr. For output of an Arabic number
of the value prefix it with \the.
Example: You want to know the number of the day of the week of the 1st May 2027.
The 1st~May~2027 has \the\ISODayNumber{2027-5-1}
as the number of the day of the week.
The result will be:
Chapter 6: The Day of the Week Using scrdate
253
The 1st May 2027 has 6 as the number of the day of the week.
A special feature is to walk a number of days into future or past from a given date.
Example: You want to know the number of the day of the week, that will be in 12 days and
that will be 24 days before the 24th December 2027.
In 12~days the number of the day of the week
will be \the\DayNumber{\year}{\month}{\day+12} and
24~days before the 24th~December~2027 it will be
\the\ISODayNumber{2027-12-24-24}.
The result may be, e. g.:
In 12 days the number of the day of the week will be 5 and 24 days
before the 24th December 2027 it will be 2.
The days of the week are numbered: Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3,
Thursday = 4, Friday = 5, and Saturday = 6.
\DayNameByNumber{number of the day of the week }
\DayName{year }{month }{day }
\ISODayName{ISO-date }
Usually
v3.05a
you do not want to know the number of the day of the week, but the name of the
day of the week. Because of this, the command \DayNameByNumber offers the name of the day
of the week corresponding with a number. The number may be the result of \DayNumber or
\ISODayNumber
. The two commands \DayName and \ISODayName directly offer the name of
the day of the week of a given date.
Example: You want to know the name of the day of the week of the 24th December 2027.
Please pay you bill until \ISODayName{2027-12-24},
24th~December~2027.
The result will be:
Please pay you bill until Friday, 24th December 2027.
Again a special feature is to make some calculations inside the argument of \DayName.
Example: You want to know the names of the days of the week, that will be in 12 days and
that will be 24 days before the 24th December 2027.
In 12~days the name of the day of the week
will be \DayName{\year}{\month}{\day+12} and
24~days before the 24th~December~2027 it will be
\ISODayName{2027-12-24-24}. Nevertheless two weeks
and three days after a Wednesday a
\DayNameByNumber{3+2*7+3} will follow.
Chapter 6: The Day of the Week Using scrdate
254
The result may be, e. g.:
In 12 days the name of the day of the week will be Friday and 24 days
before the 24th December 2027 it will be Tuesday. Nevertheless two
weeks and three days after a Wednesday a Saturday will follow.
\ISOToday
\IsoToday
\todaysname
\todaysnumber
In the prior examples the current date have been given cumbersomely and explicitly using
the TEX registers \year, \month, and \day. The commands \ISOToday
v3.05a
and \IsoToday offers
the current date in ISO-notation directly. These commands differ in the number of digits
for numbers less than 10 only. \ISOToday prefixes numbers less than 10 for the month and
day with a 0. In opposite to this \IsoToday will show numbers less than 10 for the month
and day with one digit only. Command \todaysname directly offers the name of the current
day of the week. Command \todaysnumber offers the number of that name instead. More
information about usability of this value may be found at previous description of
\DayNumber
and
\ISODayNumber
.
Example: I want to show you the name of the weekday in which this document has been
type-set:
I have done the {\LaTeX} run of this document
on a \todaysname.
This will result in, e. g.:
I have done the L
A
TEX run of this document on a Sunday.
Note that the package is not able to decline words. The known terms are the nominative
singular that may be used, e. g., in the date of a letter. Given this limitation, the example
above can work correctly only for some languages.
The names of the weekdays are saved in capitalized form, i. e., the first letter is a capital letter,
all the others are lowercase letters. But for some languages you may need the names completely
in lowercase. You may achieve this using the standard L
A
TEX command \MakeLowercase, e. g.:
\ MakeLowercase{\ todaysname}
This converts the whole argument into lower case letters. Of course, this may be done also using
previous described commands
\DayNameByNumber
,
\DayName
and
\ISODayName
.
Chapter 6: The Day of the Week Using scrdate
255
\nameday{name }
Analogous to how the output of \today can be modified using
\date
, so the output of
\todaysname
can be changed to name by using \nameday.
Example: You change the current date to a fixed value using
\date
. You are not interested
in the actual name of the day, but want only to show that it is a workday. So you
set:
\nameday{workday}
After this the previous example will result in:
I have done the L
A
TEX run of this document on a workday.
There’s no such command for changing the result of
\ISOToday
or
\IsoToday
.
\newdaylanguage{language }{Monday }{Tuesday }{Wednesday }{Thursday }{Friday }{Saturday }
{Sunday }
Currently the package scrdate knows the following languages:
• Croatian (croatian),
• Czech (czech
v3.13
),
• Danish (danish),
• Dutch (dutch),
• English (american
v3.13
, australian, british, canadian, english, UKenglish, and USen-
glish),
• Finnish (finnish),
• French (acadian, canadien, francais
v3.13
, and french),
• German (austrian
v3.08b
, german, naustrian, ngerman, nswissgerman, and swissgerman
v3.13
),
• Italian (italian),
• Norwegian (norsk),
• Polish (polish
v3.13
),
• Spanish (spanish),
• Swedish (swedish).
Chapter 6: The Day of the Week Using scrdate
256
If you want to configure it for other languages, you may use this command. The first argument
is the name of the language and the other arguments are the names of the corresponding days.
In the current implementation it does not matter whether you load scrdate before or after
german, ngerman, babel or similar packages. In both cases the correct language will be used.
To explain a little bit more exactly: while you are using a language selection which works in a
compatible way to babel or ngerman, the correct language will be used by scrdate. If you are
using another language selection you will get (US-)English names.
By the way: If you found a suitable definition for a language, that has not been defined
before, please mail it to the KOMA-Script author. There is a good chance, that he will add
support for the language to scrdate.
Chapter 7: Getting the Time with Package scrtime
257
Getting the Time with Package scrtime
This package provides an answer to the question of the current time. Since version 3.05 this
package uses the option interface already known from the KOMA-Script classes and several
other KOMA-Script packages. See for example
section 2.4
for more information.
\thistime[delimiter ]
\thistime*[delimiter ]
\thistime
results in the current time. The delimiter between the values of hour, minutes and
seconds can be given in the optional argument. The default symbol of the delimiter is “:”.
\thistime*
works in almost the same way as \thistime. The only difference is that unlike
with \thistime, with \thistime* the value of the minute field is not preceded by a zero when
its value is less than 10. Thus, with \thistime the minute field has always two places.
Example: The line
Your train departs at \thistime.
results, for example, in:
Your train departs at 11:59.
or:
Your train departs at 23:09.
In contrast to the previous example a line like:
This day is already \thistime*[\ hours and\ ] minutes old.
results in:
This day is already 11 hours and 59 minutes old.
or:
This day is already 12 hours and 25 minutes old.
\settime{ time }
\settime
sets the output of
\thistime
and
\thistime*
to the value time . Now the op-
tional parameter of
\thistime
or
\thistime*
is ignored, since the result of
\thistime
or
\thistime*
was completely determined using \settime.
Chapter 7: Getting the Time with Package scrtime
258
12h=simple-switch
With option 12h
v3.05a
one can select whether the result of
\thistime
and
\thistime*
is in 12- or
in 24-hour format. The option understands the values for simple-switch listed in
table 2.5
,
page 39
. The option without a value is same like 12h=true and therefore 12-hour-format will
be used. The default is 24h.
You may use this option either as a global option in the optional argument of
\documentclass
, as a package option in the optional argument of
\usepackage
or after load-
ing the package using
\KOMAoptions
or
\KOMAoption
(see, e. g.,
section 2.4
,
page 30
). The
option has no effect on the results of
\thistime
and
\thistime*
if
\settime
is used.
Only for compatibility with former releases of scrtime also option 24h will switch to 24-hour
format if used in the optional argument of \documentclass or \usepackage. Nevertheless,
you should not use this option any longer.
|