Example: Because of incomprehensible reasons, the headings of \paragraph shouldn’t be
run-in headings any longer but headings similar to \subsubsection. The vertical
skip above the heading should be 10 pt and the following text should be set without
any vertical distance. To do so, you can simply use:
\RedeclareSectionCommand[%
394
Chapter 21.
Table 21.3.: Additional keys and value s of attributes declaring a section-like command with style
chapter
key
value
Description
afterskip
length
The absolute value is the vertical skip below the head-
ing.
beforeskip
length
The absolute value of the vertical skip before the head-
ing. If the value is negative, then the paragraph indent
of the text following the heading is suppressed.
font
font commands
The initial font setting that should be used be-
side disposition for the heading.
You can use
all settings, that are allowed for \setkomafont and
\addtokomafont
for the element of the heading.
innerskip
length
The vertical skip between the prefix line and the head-
ing’s text, if a prefix line is used.
pagestyle
page style name
The name of the page style that should be used auto-
matically on pages with the heading. There is no val-
idation whether or not page style name is really the
name of a page style. Therefore, wrong names will result
in error messages at usage of the section-like command.
prefixfont
font commands
The initial font setting that should be used beside
disposition
and the element of the heading for the
prefix line of the heading. You can use all settings that
are allowed for \setkomafont and \addtokomafont for
the element of the prefix line.
beforeskip=-10pt,%
afterskip=1sp%
]{paragraph}
The negative value of beforeskip does not only result in a positive vertical skip
before the heading, but also deactivates the paragraph indentation of the following
text. Despite the specification of no vertical skip after the heading a value of 1 sp
has been given to afterskip. This is because L
A
TEX here doesn’t accept 0 pt as
positive value. So 1 sp is the lowest possible positive value.
Generally, for the vertical adjustment it is better to have some tolerance in the
declaration of gaps — the so called glue:
\RedeclareSectionCommand[%
beforeskip=-10pt plus -2pt minus -1pt,%
afterskip=1sp plus -1sp minus 1sp%
395
Chapter 21.
Table 21.4.: Additional keys and value s of attributes declaring a section-like command with style
part
key
value
Description
afterskip
length
The absolute value is the vertical skip below the head-
ing.
beforeskip
length
The absolute value of the vertical skip before the head-
ing. If the value is negative, then the paragraph indent
of the text following the heading is suppressed.
font
font commands
The initial font setting that should be used be-
side disposition for the heading.
You can use
all settings, that are allowed for \setkomafont and
\addtokomafont
for the element of the heading.
innerskip
length
The vertical skip between the prefix line and the head-
ing’s text of scrbook and scrreprt.
pagestyle
page style name
The name of the page style that should be used auto-
matically on pages with the heading. There is no val-
idation whether or not page style name is really the
name of a page style. Therefore, wrong names will result
in error messages at usage of the section-like command.
This feature is only available with scrbook or scrreprt.
prefixfont
font commands
The initial font setting that should be used beside
disposition
and the element of the heading for the
prefix line of the heading. You can use all settings that
are allowed for \setkomafont and \addtokomafont for
the element of the prefix line.
]{paragraph}
Doing so you have to know, that the glue also switches the algebraic sign before
becoming a skip, if the value is negative. That is the reason for the negative glue
values in the example. Additionally we used the occasion to minimize the vertical
skip after the heading using glue too.
In the example above only beforeskip and afterskip were needed, because since v3.15
KOMA-Script defines \paragraph itself using \DeclareSectionCommand. All other values are
just reused with their initial definition. Furthermore, the original definition of \paragraph in
scrartcl reads:
\DeclareSectionCommand[%
level=4,
396
Chapter 21.
Table 21.5.: Defaults of the chapter headings of scrbook and scrreprt subject to option headings
With headings=big:
Attribute
Default Value
afterskip
1.725\baselineskip plus .115\baselineskip minus .192\baselineskip
beforeskip
3.3\baselineskip+\parskip
font
\huge
With headings=normal:
Attribute
Default Value
afterskip
1.5\baselineskip plus .1\baselineskip minus .167\baselineskip
beforeskip
3\baselineskip+\parskip
font
\LARGE
With headings=small:
Attribute
Default Value
afterskip
1.35\baselineskip plus .09\baselineskip minus .15\baselineskip
beforeskip
2.8\baselineskip+\parskip
font
\Large
indent=0pt,
beforeskip=3.25ex plus 1ex minus .2ex,
afterskip=-1em,
font={},
tocindent=7em,
tocnumwidth=4.1em,
counterwithin=subsubsection
]{paragraph}
scrreprt and scrbook use slightly different values.
Some settings of \chapter depend on option headings (see
section 3.16
,
page 86
).
Ta-
ble 21.5
shows the default values of these settings. An overview of all settings is shown in
table 21.6
. For more information
Beta-
Feature
about the default of the toc-entry styles see
section 15.3
,
page 310
. Please note, that 1ex and \baselineskip depend on the default font size of the
heading or the table of contents entry.
397
Chapter 21.
Table 21.6.: Default of the headings of scrbook and scrreprt
\part
:
Attribute
Default Value
afterskip
0pt plus 1fil
beforeskip
0pt plus 1fil + \baselineskip
font
see element part,
table 3.15
,
page 92
innerskip
20pt
level
-1
prefixfont
see element partnumber,
table 3.15
,
page 92
tocindent
0pt
toclevel
-1
tocnumwidth
2em
tocstyle
part
\chapter
:
Attribute
Default Value
afterskip
see
table 21.5
beforeskip
see
table 21.5
font
see element chapter,
table 3.15
,
page 92
innerskip
0pt
level
0
prefixfont
see element chapterprefix,
table 3.15
,
page 92
tocindent
0pt
toclevel
0
tocnumwidth
1.5em
tocstyle
chapter
. . .
398
Chapter 21.
Table 21.6.: Default of the headings of scrbook and scrreprt (Continuation)
\section
:
Attribute
Default Value
afterskip
2.3ex plus .2ex
beforeskip
-3.5ex plus -1ex minus -.2ex
font
see element section,
table 3.15
,
page 92
indent
0pt
level
1
tocindent
1.5em
toclevel
1
tocnumwidth
2.3em
tocstyle
section
\subsection
:
Attribute
Default Value
afterskip
1.5ex plus .2ex
beforeskip
-3.25ex plus -1ex minus -.2ex
font
see element subsection,
table 3.15
,
page 92
indent
0pt
level
2
tocindent
3.8em
toclevel
2
tocnumwidth
3.2em
tocstyle
section
\subsubsection
:
Attribute
Default Value
afterskip
1.5ex plus .2ex
beforeskip
-3.25ex plus -1ex minus -.2ex
font
see element subsubsection,
table 3.15
,
page 92
indent
0pt
level
3
tocindent
7.0em
tocnumwidth
4.1em
toclevel
3
tocstyle
section
. . .
399
Chapter 21.
Table 21.6.: Default of the headings of scrbook and scrreprt (Continuation)
\paragraph
:
Attribute
Default Value
afterskip
-1em
beforeskip
3.25ex plus 1ex minus .2ex
font
see element paragraph,
table 3.15
,
page 92
indent
0pt
level
4
tocindent
10em
toclevel
4
tocnumwidth
5em
tocstyle
section
\subparagraph
:
Attribute
Default Value
afterskip
-1em
beforeskip
3.25ex plus 1ex minus .2ex
font
see element subparagraph,
table 3.15
,
page 92
indent
\scr@parindent
level
5
tocindent
12em
toclevel
5
tocnumwidth
6em
tocstyle
section
\DeclareSectionCommands[attributes ]{list of names }
\DeclareNewSectionCommands[attributes ]{list of names }
\RedeclareSectionCommands[attributes ]{list of names }
\ProvideSectionCommands[attributes ]{list of names }
With
v3.15
these commands you can either define or change several section-like commands at once.
The names of the section-like commands are given by the comma-separated list of names .
There are two more differences to the previously described commands that only
define or change a single section-like command.
Firstly, in case of error — if
\DeclareNewSectionCommands
is used for an already defined TEX command sequence or if
\RedeclareSectionCommands
is used for an undefined TEX command sequence — the defini-
tion will be done in spite of raising an error message.
Secondly, there is one more attribute increaselevel with an optional integer argument.
This attribute changes the meaning of the attributes level and toclevel (see
table 21.1
)
400
Chapter 21.
so their values become start values for the first section-like command of the list of names .
From section-like command to section-like command of the list of names the value of level
and toclevel will be increased by the value of increaselevel. If attribute increaselevel
is used without an assignment the increase value is 1.
\chapterheadstartvskip
\chapterheadmidvskip
\chapterheadendvskip
\partheadstartvskip
\partheadmidvskip
\partheadendvskip
\partheademptypage
These commands are used inside of the definition of the headings \chapter, \part, \addchap,
\addpart
and their star-variations.
Thereby \chapterheadstartvskip is designed to
be a command, that inserts a vertical distance before the chapter heading. Analogues
\chapterheadendvskip
is designed to be a command, that inserts a vertical distance after the
chapter heading. If
v3.15
the chapter heading has a prefix number line (see option chapterprefix
in
section 3.16
,
page 85
), \chapterheadmidvskip will be used between the number line and
the heading text.
Vertical distance above and below part headings will be inserted using the commands
\partheadstartvskip
and \partheadendvskip. A page break would be interpreted to be
part of the vertical distance and therefore is already part of the default of \partheadendvskip
in scrbook and scrreprt. Command \partheademptypage
v3.02
is used to produce the empty page
scrbook
,
scrreprt
after the part heading page of scrbook and scrreprt.
Since KOMA-Script 3.15
v3.15
the defaults of these seven commands are independent from option
headings
(see
section 3.16
,
page 86
). The original definitions of the chapter heading reads
since KOMA-Script 3.157
v3.17
:
\newcommand*{\chapterheadstartvskip}{\vspace{\@tempskipa}}
\ newcommand*{\chapterheadmidvskip}{\ par\ nobreak\ vskip\@tempskipa}
\newcommand*{\chapterheadendvskip}{\vskip\@tempskipa}
Every usage of headings=big, headings=normal, or headings=small reactivates these default
definitions.
Command \chapter automatically sets the internal length \@tempskipa to the value of the
\DeclareSectionCommand
attribute beforeskip before calling \chapterheadstartvskip.
Correspondingly it sets the length to the value of attribute afterskip before calling
\chapterheadendvskip
and innerskip before calling \chapterheadmidvskip. If you re-
define \chapterheadstartvskip, \chapterheadmidvskip, or \chapterheadendvskip you
should also correspond the new definition to \@tempskipa to respect the values of
\DeclareSectionCommand
.
The default values of the distances of \part do not depend on option headings. So the
corresponding commands will not be redefined using the options. The
v3.17
original definitions of
401
Chapter 21.
these commands of scrbook and scrreprt read:
\newcommand*{\partheadstartvskip}{%
\null\vskip-\baselineskip\vskip\@tempskipa
}
\newcommand*{\partheadmidvskip}{%
\ par\ nobreak
\vskip\@tempskipa
}
\newcommand*{\partheadendvskip}{%
\ vskip\@tempskipa\ newpage
}
and of scrartcl:
\ newcommand*{\partheadstartvskip}{ %
\addvspace{\@tempskipa}%
}
\newcommand*{\partheadmidvskip}{%
\ par\ nobreak
}
\newcommand*{\partheadendvskip}{%
\ vskip\@tempskipa
}
Again \part sets \@tempskipa to the values of \DeclareSectionCommand before the internal
usage of the command.
It
v3.17
is not recommended to redefine the command for the distances above or below the
headings only for changing these distances, because you can reconfigure these distances
much easier using \RedeclareSectionCommand. Redefinition of the commands should be
reserved to more complex changes. An example that redefines \chapterheadstartvskip and
\chapterheadendvskip
to print extra rules above and below the chapter heading may be
found at [
KDP
] (in German).
\chapterlineswithprefixformat{level }{number }{text }
\chapterlinesformat{level }{number }{text }
These
v3.19
commands are used by headings with style chapter to output the heading number and
heading text depending on option chapterprefix (see
section 3.16
,
page 85
). If the option is
true \chapterlineswithprefixformat
is used, otherwise \chapterlinesformat.
The arguments number and text are already formatted, i. e., they contain font selections.
At least the order and layout of both has to be done with these commands. If a heading
has no number argument number will be completely empty also without any format or font
commands.
The default definitions are very simple:
\newcommand{\chapterlinesformat}[3]{%
402
Chapter 21.
\@hangfrom{#2}{#3}%
}
\newcommand{\chapterlineswithprefixformat}[3]{%
#2#3 %
}
Example: You want to have chapter headings with yellow background. For the headings
without prefix line you use the follow definition in the document preamble:
\makeatletter
\renewcommand{\chapterlinesformat}[3]{%
\colorbox{yellow}{%
\parbox{\dimexpr\linewidth-2\fboxrule-2\fboxsep}{%
\@hangfrom{#2}#3%
}%
}%
}
\makeatother
For chapter headings without prefix line you use:
\renewcommand{\chapterlineswithprefixformat}[3]{%
\colorbox{yellow}{%
\parbox{\dimexpr\linewidth-2\fboxrule-2\fboxsep}{%
#2#3%
}%
}%
}
Unfortunately you will find, that these re-definitions result in justified text
for the headings. The reason is the \parbox command. To change this,
you can use \raggedchapter (see
section 3.16
,
page 96
) inside the argu-
ment of \parbox.
Otherwise \raggedchapter would be used only before
\chapterlineswithprefixformat
and \chapterlinesformat:
\makeatletter
\renewcommand{\chapterlinesformat}[3]{%
\colorbox{yellow}{%
\parbox{\dimexpr\linewidth-2\fboxrule-2\fboxsep}{%
\raggedchapter
\@hangfrom{#2}#3%
}%
}%
}
\makeatother
\ renewcommand{\ chapterlineswithprefixformat}[3]{ %
\colorbox{yellow}{%
403
Chapter 21.
\parbox{\dimexpr\linewidth-2\fboxrule-2\fboxsep}{%
\raggedchapter
#2#3%
}%
}%
}
Remember to use \makeatletter and \makeatother only at the document pream-
ble. Do not use it inside your own wrapper-class or package. It is only needed
because of \@hangfrom in the definition of \chapterlinesformat.
As the example shows, users, who change the definition of one of the commands, should
take care of several side effects. The alignment of the text is only one thing. They also have
to prevent page breaks in the headings, e. g., if they add extra space into the output. The
example above does not have page break problems. Not only the boxes prevent page breaks.
KOMA-Script itself also changes \interlinepenalty as part of text to prevent page breaks.
It also finishes text with an internal paragraph break using \@par.
Command
\raggedchapter
is
not
part
of
text
but
executed
before
\chapterlineswithprefixformat
or \chapterlinesformat. This makes it much eas-
ier to use, e. g., \MakeUppercase at a re-definition. Please note, typographers use individual
letter spacing at majuscule text, but L
A
TEX command \MakeUppercase does not.
The first argument, level , is not used by the default definition and also not needed in
the example above. It is of interest only, if a user would define several commands with
chapter
style and need to distinguish the different levels. The predefined commands \chapter,
\chapter*
, \addchap, and \addchap* all share the same level chapter .
\sectionlinesformat{level }{indent }{number }{text }
\sectioncatchphraseformat{level }{indent }{number }{text }
These
v3.19
commands are used by headings with style section to output the heading number and
heading text. If the heading is printed as catch phrase at the very beginning of the following
paragraph text \sectioncatchphraseformat is used, otherwise \sectionlinesformat.
In both cases indent is the value of the horizontal indention of the heading relative to the
text area. If the value is negative the heading should even move into the left margin.
The arguments number and text are already formatted, i. e., they contain font selections.
At least the order and layout of both has to be done with these commands. If a heading
has no number argument number will be completely empty also without any format or font
commands.
The default definitions are:
\newcommand{\sectionlinesformat}[4]{%
\@hangfrom{\hskip #2#3}{#4}%
}
404
Chapter 21.
\newcommand{\sectioncatchphraseformat}[4]{%
\hskip #2#3#4%
}
If the user re-defines one of these commands, he has to take care to prevent page breaks
inside the printing of the heading. KOMA-Script itself only changes \interlinepenalty to
impede page breaks.
Example: Like chapter headings in the previous example, headings of level section should
be printed with a background colour. The lower levels should be affected:
\makeatletter
\renewcommand{\sectionlinesformat}[4]{%
\@tempswafalse
\ifstr{#1}{section}{%
\hspace*{#2}%
\colorbox{yellow}{%
\parbox{\dimexpr\linewidth-2\fboxrule-2\fboxsep-#2}{%
\raggedsection
\@hangfrom{#3}{#4}%
}%
}%
}{%
\@hangfrom{\hskip #2#3}{#4}%
}%
}
\makeatother
With this code the indention part of indented headings would not be coloured, but
with negative indention the background of the margin part of the headings will
also become yellow. You can move the \hspace* command into the \colorbox to
change this.
Again remember to use \makeatletter and \makeatother only at the document
preamble. Do not use it inside your own wrapper-class or package. It is only
needed because of \@hangfrom in the definition of \sectionlinesformat.
The first argument, level , is not used by the default definition. The example shows how
to use it to distinguish different heading levels of the same style section.
405
Chapter 21.
\SecDef{star command }{command }
\scr@startsection{name }{level }{indent }{beforeskip }{afterskip }
{style commands }[short version ]{heading }
\scr@startsection{name }{level }{indent }{beforeskip }{afterskip }
{style commands }*{heading }
\At@startsection{code }
\Before@ssect{code }
\Before@sect{code }
As
v3.15
already explained in
section 3.16
in the description of the sectioning commands beginning
with
page 89
, KOMA-Script provides additional features for the optional argument of those
commands. Therefore, it was necessary to replace some L
A
TEX kernel commands, especially
\secdef
and \@startsection. The meaning of the parameters of these commands can be
found in the L
A
TEX kernel manual [
BCJ
+
05
].
Unfortunately these commands are often redefined by other packages in a way that col-
lides with the functionality of KOMA-Script. So KOMA-Script not only changes the defini-
tion of these commands but also defines the additional, alternative commands \SecDef and
\scr@startsection
. Package authors are permitted to use these commands like they would
use the corresponding L
A
TEX kernel commands and therefore participate in the additional fea-
tures of KOMA-Script. Nevertheless these commands should not be redefined, because they
could be changed in future and so the redefinition would impair KOMA-Script again.
KOMA-Script internally uses \SecDef and \scr@startsection instead of \secdef and
\@startsection
, e. g., defining section-like commands by \DeclareSectionCommand. So later
redefinition of \secdef or \@startsection will not influence the sectioning commands of
KOMA-Script.
As an alternative to the redefinition of such commands, KOMA-Script provides the execution
of additional code at several states of the KOMA-Script replacements. The code of each usage
of \At@startsection, \Before@sect, or \Before@ssect will be cumulated independently.
Later removing of added code is not provided.
The code of \At@startsection is executed immediately after the evaluation of beforeskip
and calculation of the resulting \@tempskipa, before adding the vertical gap itself. So you
still may change the value of \@tempskipa.
The code of \Before@sect and \Before@ssect is executed just before \@sect and \@ssect
inside \scr@startsection, respectively. At this state the vertical gap of \@tempskipa has
already been added using \addvspace.
The commands \At@startsection, \Before@sect, and \Before@ssect are suggested for
package authors.
\appendixmore
There is a peculiarity within the \appendix command in the KOMA-Script classes. If
the command \appendixmore is defined, this command is executed also by the \appendix
command. Internally the KOMA-Script classes scrbook and scrreprt take advantage of this
scrbook
,
scrreprt
406
Chapter 21.
behaviour to implement the options appendixprefix (see
section 3.16
,
page 85
). You
should take note of this in case you decide to define or redefine the macro \appendixmore.
In case one of this option has been used, you will receive an error message when using
\newcommand{\appendixmore}{
. . . }. This behaviour is intended to prevent you from dis-
abling options without noticing it.
Dostları ilə paylaş: |