Example:
\newenvironment{SourceCodeFrame}{%
\begin{addmargin*}[1em]{-1em}%
\begin{minipage}{\linewidth}%
\rule{\linewidth}{2pt}%
}{%
\rule[.25\baselineskip]{\linewidth}{2pt}%
\end{minipage}%
\end{addmargin*}%
}
If you now put your source code in such an environment it will show up as:
You define yourself the following environment:
\newenvironment{\SourceCodeFrame}{%
\begin{addmargin*}[1em]{-1em}%
\begin{minipage}{\linewidth}%
\rule{\linewidth}{2pt}%
}{%
\rule[.25\baselineskip]{\linewidth}{2pt}%
\end{minipage}%
\end{addmargin*}%
}
This may be feasible or not. In any case it shows the usage of this envi-
ronment.
The optional argument of the addmargin* environment makes sure that the inner
margin is extended by 1 em. In turn the outer margin is decreased by 1 em. The
result is a shift by 1 em to the outside. Instead of 1em you can of course use a
length, for example, 2\parindent.
Chapter 3: The Main Classes: scrbook, scrreprt, and scrartcl
119
Whether a page is going to be on the left or right side of the book can not be determined
for certain in the first L
A
TEX run. For details please refer to the explanation of the commands
\ifthispageodd
(
section 3.11
,
page 76
) and \ifthispagewasodd (
section 21.1
,
page 441
).
There may be several questions about coexistence of lists and paragraphs. Because of this
additional information may be found at the description of option parskip in
section 21.1
,
page 441
.
Also at the expert part, in
section 21.1
,
page 441
, you may find additional information about page
breaks inside of addmargin*.
3.19. Math
There are no math environments implemented in the KOMA-Script classes. Instead of this,
the math features of the L
A
TEX kernel have been supported. With this also, the options
leqno
and
fleqn
are available.
You will not find a description of the math environments of the L
A
TEX kernel here. If you
want to use displaymath, equation, and eqnarray you should read a short introduction into
L
A
TEX like [
OPHS11
]. But if you want more than very simple mathematics, usage of package
amsmath would be recommended (see [
Ame02
]).
leqno
Equations are normally numbered on the right. The standard option leqno causes the standard
option file leqno.clo to be loaded. The equations are then numbered on the left. This
option has to be used as an optional argument of
\documentclass
. Usage as an argument
of
\KOMAoptions
or
\KOMAoption
is not supported. This would not make sense, because the
recommended math package amsmath supports the option at loading time only too and would
not react on run-time changes of the option.
fleqn
Displayed equations are normally centered. The standard option fleqn causes the standard
option file fleqn.clo to be loaded. Displayed equations are then left-justified. This op-
tion may be used as an optional argument of
\documentclass
but not as an argument of
\KOMAoptions
or
\KOMAoption
. The latter would not make sense, because the recommended
math package amsmath supports the option at loading time only too and would not react on
run-time changes of the option.
3.20. Floating Environments of Tables and Figures
With the floating environments, L
A
TEX offers a very capable and comfortable mechanism for
automatic placement of figures and tables. But often these floating environments are slightly
misunderstood by beginners. They often ask for a fixed position of a table or figure within
the text. However, since these floating environments are being referenced in the text this is
Chapter 3: The Main Classes: scrbook, scrreprt, and scrartcl
120
not necessary in most cases. It is also not sensible because such an object can only be set on
the page if there is enough space left for it. If this is not the case the object would have to be
shifted onto the next page, thereby possibly leaving a huge blank space on the page before.
Often one finds in a document for every floating object the same optional argument for
positioning the object. This also makes no sense. In such cases one should rather change the
standard parameter globally. For more details refer to [
Wik
].
One last important note before starting this section: most mechanisms described here which
extend the capabilities of the standard classes no longer work correctly when used together
with packages which modify the typesetting of captions of figures and tables. This should be
self evident, but it is often not understood.
captions=selection
The standard classes format titles of floating environments, which are placed with
\caption
(see below), like signatures. They differentiate between one-line and multi-line table or figure
captions. One-line captions are centered while multi-line captions are left-justified.
For tables, however, headings are often used. That’s because there may be tables that span
several pages. Surely the reader wants to know the purpose of the table at the first page
already. Furthermore tables will be read row by row from top down to bottom. So there are
at least two good reasons to generally use table headings. KOMA-Script therefor supports
option captions=tableheading, which changes the caption format into headings at tables
only.
Please note that multi-page tabulars may not use any floating environment. To have an
automatic page break at any kind of tabular you also need additional packages like longtable
(see [
Car04
]) or tabu (see [
Che11
]).
You may switch back to the default table signatures using captions=tablesignature. Note
that using any of these options does not change the position of the caption from above the
top of the table to below the bottom of the table or vice versa. It only affects whether the
text is formatted as a caption for use above or below a table. Whether the text is in fact
placed above or below a table is set through the position of the
\caption
command inside
the table environment. This may change using package float and command \restylefloats
(see [
Lin01
]).
Of course similar features exist
v3.09
for figures using options captions=figureheading and
captions=figuresignature
. Nevertheless, figures like photos will be viewed as a whole, and
a diagram or graph will mostly be examined from left bottom to the right. Therefore, in
general, signatures should be used and it would not be useful to change the caption format
from signatures to headings.
Nevertheless sometimes all floating environments shall use headings. For this KOMA-Script
supports
v3.09
options captions=heading and captions=signature to switch the format of every
floating environment. These options may be used also inside a floating environment but before
using
\caption
.
Chapter 3: The Main Classes: scrbook, scrreprt, and scrartcl
121
Note that when using the float package, the options captions=tablesignature and
float
captions=tableheading
cease to act correctly when \restylefloat is applied to tables.
More details of the float package and \restylefloat can be found in [
Lin01
]. Additional
support in KOMA-Script for the float package may be found at the explanation of komaabove
(see
page 129
).
Furthermore, KOMA-Script supports to switch off the distinguish of captions with only one
line or more than one line using option captions=nooneline. This may be useful, if one-line
captions should not be centered. The default of centering one-line captions corresponds to
captions=oneline
.
Another special feature of KOMA-Script is to alternatively put the caption neither above
nor below the floating object but beside it. For this you need Environment
captionbeside
,
that will be described from
page 126
. Several settings for this environment may be done also
using caption. You may find all the available settings at
table 3.17
.
Table 3.17.: Available values for option captions to select formation of captions as headings or signa-
tures at floating environments
bottombeside
, besidebottom
Captions and contents of environment
captionbeside
(see
section 3.20
,
page 126
)
will be vertically align depending on the bottommost base lines.
centeredbeside
, besidecentered, middlebeside, besidemiddle
Captions and contents of environment
captionbeside
(see
section 3.20
,
page 126
)
will be vertically centered
figureheading
, figureabove, abovefigure, topatfigure
v3.09
Captions of figures will use heading formation — maybe in discrepancy to captions=
signature
.
figuresignature
, belowfigure, bottomatfiggure
v3.09
Captions of figures will use signature formation — maybe in discrepancy to
captions=headings
.
heading
, above, top
v3.09
Captions of floating environments will use heading formation. Nevertheless this does
not influence whether they are really placed at the top or at the bottom of the object.
This options also implies captions=tableheading and captions=figureheading.
. . .
Chapter 3: The Main Classes: scrbook, scrreprt, and scrartcl
122
Table 3.17.: Available values for option captions (continuation)
innerbeside
, besideinner
Captions of environment
captionbeside
(siehe
section 3.20
,
page 126
) will be placed
innermost beside the contents of the environment at double-side printing. At single-
side printing captions=leftbeside will be used.
leftbeside
, besideleft
Captions of environment
captionbeside
(siehe
section 3.20
,
page 126
) will be placed
left beside the contents of the environment.
nooneline
Captions with only one line will not be handled different from captions with more
than one line.
oneline
Captions with only one line will be centered horizontally.
outerbeside
, besideouter
Captions of environment
captionbeside
(siehe
section 3.20
,
page 126
) will be placed
outermost beside the contents of the environment at double-side printing. At single-
side printing captions=rightbeside will be used.
rightbeside
, besideright
Captions of environment
captionbeside
(siehe
section 3.20
,
page 126
) will be placed
right beside the contents of the environment.
signature
, below, bot, bottom
v3.09
Captions of floating environments will use signature formation. Nevertheless this
does not influence whether they are really placed at the top or at the bottom of
the object. This options also implies captions=tablesignature and captions=
figuresignature
.
tableheading
, tableabove, abovetable, abovetabular, topattable
Captions of tables will use heading formation — maybe in discrepancy to captions=
signature
.
tablesignature
, belowtable, belowtabular, bottomattable
Captions of tables will use signature formation — maybe in discrepancy to captions=
heading
.
. . .
Chapter 3: The Main Classes: scrbook, scrreprt, and scrartcl
123
Table 3.17.: Available values for option captions (continuation)
topbeside
, besidetop
Captions and contents of environment
captionbeside
(see
section 3.20
,
page 126
)
will be vertically align depending on the topmost base lines.
\caption[entry ]{title }
\captionbelow[entry ]{title }
\captionabove[entry ]{title }
In the standard classes caption text title of tables and figures is inserted with the \caption
command below the table or figure. In general this is correct for figures. Opinions differ as
to whether captions of tables are to be placed above or, consistent with captions of figures,
below the table. That is the reason why KOMA-Script, unlike the standard classes, offers
\captionbelow
for captions below and \captionabove for captions above tables or figures.
Not only for tables but also for figures or all kind of floating environments the behaviour of
\caption
may be modified using option
captions
described at the beginning of this section.
For compatibility reasons the default behaviour of \caption used with all kinds of floating
environments is similar to \captionbelow. Nevertheless it is recommended to use table head-
ings and therefor switch behaviour of \caption inside table environments into \captionabove
using option
3.20
. Alternatively you may use \captionabove instead of \caption inside of
every table environment.
Example: Instead of using captions below a table you want to place your captions above it,
because you have tables which span more then one page. In the standard classes
you could only write:
\begin{table}
\caption{This is an example table}
\begin{tabular}{llll}
This & is & an & example.\\\hline
This & is & an & example.\\
This & is & an & example.
\end{tabular}
\end{table}
Then you would get the unsatisfying result:
Table 30.2: This is an example table.
This is an example.
This is an example.
This is an example.
Using KOMA-Script you write instead:
Chapter 3: The Main Classes: scrbook, scrreprt, and scrartcl
124
Table 3.18.: Font defaults for the elements of figure or table
captions
element
default
caption
\normalfont
captionlabel
\normalfont
\begin{table}
\captionabove{This is just an example table}
\begin{tabular}{llll}
This & is & an & example.\\\hline
This & is & an & example.\\
This & is & an & example.
\end{tabular}
\end{table}
Then you get:
Table 30.2: This is just an example table
This is an example.
This is an example.
This is an example.
Since you want all your tables typeset with captions above, you could of course use
the option
3.20
instead (see
page 120
). Then you can use \caption as you would
in the standard classes. You will get the same result as with \captionabove.
The font style
v2.8p
for the description and the label — “Figure” or “Table”, followed by
the number and the delimiter — can be changed with the commands
\setkomafont
and
\addtokomafont
(see
section 3.6
,
page 57
). The respective elements for this are caption
and captionlabel (see
table 3.2
,
page 58
). First the font style for the element caption is
applied to the element captionlabel too. After this the font style of captionlabel is applied
on the respective element. The default settings are listed in
table 3.18
.
Example: You want the table and figure descriptions typeset in a smaller font size. Thus you
could write the following in the preamble of your document:
\addtokomafont{caption}{\small}
Furthermore, you would like the labels to be printed in sans serif and bold. You
add:
\setkomafont{captionlabel}{\sffamily\bfseries}
As you can see, simple extensions of the default definitions are possible.
Chapter 3: The Main Classes: scrbook, scrreprt, and scrartcl
125
\captionof{float type }[entry ]{title }
\captionbelowof{float type }[entry ]{title }
\captionaboveof{float type }[entry ]{title }
KOMA-Script supports a command \captionof
v3.05
similar to packages caption and capt-of. You
may use this command to place a floating environment caption with corresponding entry into
the list of that kind of floating environment but even inside a another floating environment or
outside any floating environment. In difference to
\caption
the kind of floating environment
has to be set as first parameter.
Furthermore, KOMA-Script provides the additional commands \captionaboveof
v3.09
and
\captionbelowof
. These are like \captionabove and \captionbelow but with the addi-
tional features and parameter of \captionof.
Of course KOMA-Script
v3.09a
takes care of the heading and signature setting of option
captions
. But this feature may be lost, loading package capt-of or caption. Please note
the manual of package caption for this!
Example: Assumed you want to create a floating object with a table and a figure side by
side. As you know, there are now mixed floating environment. Therefor you use a
figure
environment primarily:
\ begin{figure}
\begin{minipage}{.5\linewidth}
\centering
\rule{4cm}{3cm}
\caption{A rectangle}\label{fig:rechteck}
\end{minipage}%
\begin{minipage}{.5\linewidth}
\centering
\captionaboveof{table}
[Measure of the rectangle in
figure~\ref{fig:rechteck}]%
{Measure of the rectangle}
\label{tab:rechteck}
\begin{tabular}{ll}
Width:
& 4\,cm\\
Height: & 3\,cm
\end{tabular}
\end{minipage}
\end{figure}
Two minipage environments have been used to have figure and table side by side.
The percent char after the end of the first minipage is important. Without an
additional inter-word distance would be made between the minipage environments.
The figure signature has been done using
\caption
. The table heading has been
Chapter 3: The Main Classes: scrbook, scrreprt, and scrartcl
126
Figure 3.3.: Example:
Usage
of
\captionaboveof
inside
another floating environment
Figure 3.2.: A rectangle
Table 3.19.: Rectangle size
Width: 4 cm
Height: 3 cm
done using \captionaboveof with first argument table. Because of this KOMA-
Script knows, that despite the figure environment a table caption should be made.
The optional argument of \captionaboveof does make the entry into the list of
tables. Without the optional argument, the last mandatory argument would have
been used for the list of tables too. Although this caption text is sufficient for
the environment itself, it would be very useful at the list of tables. Therefor a
somehow more detailed description has been used for the list of tables using the
optional argument. The
figure 3.3
shows the result of the example code.
A non-floating table with a caption may be produced in the same kind like the table inside a
figure environment in the example above. In such a case also a minipage environment should
be used, to avoid page breaks between table caption an tabular. An additional flushleft
environment around the minipage environment may be used, to have a pleasing distance above
and below is and to avoid the paragraph indentation of the minipage environment.
\begin{captionbeside}[entry ]{title }[placement ][width ][offset ]
. . . \end{captionbeside}
\begin{captionbeside}[entry ]{title }[placement ][width ][offset ]*
. . . \end
{captionbeside}
Apart
v2.8q
from captions above and below the figure, one often finds captions, in particular with
small figures, which are placed beside the figure. In general in this case both the baseline of
the figure and of the caption are aligned at the bottom. With some fiddling and the use of
two \parbox commands this could also be achieved in the standard classes. However, KOMA-
Script offers a special environment for this which can be used within the floating environment.
The first optional parameter entry and the obligatory parameter title mean the same as
the corresponding parameters of
\caption
,
\captionabove
or
\captionbelow
. The caption
text title is placed beside the content of the environment in this case.
Whether the caption text title is placed on the left or the right can be determined by the
parameter placement . Exactly one of the following letters is allowed:
l
– left
Chapter 3: The Main Classes: scrbook, scrreprt, and scrartcl
Dostları ilə paylaş: |