Академический Документы
Профессиональный Документы
Культура Документы
with LATEX
O utstations Staff
O verall B reakdow n
to grou p m em bers
<D ---------------------------------
n
g By qualification
fem ale
total
o
Sb degree
C a m b rid g e 90 24 11 79 15 64
B e r lin 37 12 8 29 7 22
T okyo 30 8 2 28 6 22
P asad en a 36 13 3 33 8 25
Herbert Voss
Typesetting Tables w ith IATe X
Typesetting Tables w ith IATe X
Herbert Voss
UIT
CAMBRIDGE, ENGLAND
Published by
UIT Cambridge Ltd.
PO Box 145
Cambridge
CB4 1 GQ
England
ISBN 978-1-906860-25-7
10 9 8 7 6 5 4 3 2 1
Contents
1 Introduction 3
1.1 The tabular environment................................................................................ 3
1.2 The tabbing environment................................................................................ 12
1.3 Notes................................................................................................................ 17
2 Packages 19
2.1 a r r a y ................................................................................................................ 21
2.2 a ry d s h ln .......................................................................................................... 27
2.3 bigdelim, bigstrut, m ultirow ....................................................................... 30
2.4 b lk a r r a y .......................................................................................................... 38
2.5 booktab s.......................................................................................................... 46
2.6 c e lls p a c e ....................................................................................................... 53
2.7 c ta b le ............. 54
2.8 d a t a to o l.......................................................................................................... 58
2.9 e a s y ta b le ....................................................................................................... 62
2.10 h h lin e .............................................................................................................. 64
2.11 m a k e ce ll.......................................................................................................... 65
2.12 mdwtab.............................................................................................................. 72
2.13 sla sh b o x .......................................................................................................... 74
2.14 sp re a d ta b ....................................................................................................... 76
2.15 t a b ls ................................................................................................................ 82
2.16 t a b u la r h t ....................................................................................................... 84
2.17 ta b u la r k v ....................................................................................................... 86
2.18 ta b u la r x .......................................................................................................... 87
2.19 ta b u la r y .......................................................................................................... 90
C o ntents
6 Examples 177
Bibliography 217
People 231
Preface
You might be surprised that we’ve dedicated a whole book to typesetting tables in fflgX
but a quick glance at the volume of questions and contributions online about this topic
highlights the need for a publication of this kind. The IfljpC Companion [42] offers only a short
introduction to the basics of tables and the use of the most widely known packages in its
40-page chapter on the subject. More useful was the tabsatz [50] document created by Axel
Reichert just over a decade ago, providing a general reference for problems with tables; we’ve
included all of Axel’s examples or adaptations of them in this publication.
Time has moved on since tabsatz was published, however, and more and more packages
have been developed that support creating tables in many different ways. This book introduces
all existing packages to you, though sometimes the scope of this publication limited the
coverage we could give each package, especially for the datatool package by Nicola Talbot.
In principle, TgX does not distinguish between a table and a matrix (array). Nevertheless,
this book only deals with tables containing normal text. If you want to find out more about
typesetting tables containing mathematical elements, look in M athematics with BTpX [56].
You can download all the examples as complete FIpX documents at CTAN (Comprehensive
TgX Archive Network - h ttp : //www. ctan. org) in the directory CTAN: //inf o/examples/
Tabellen/. Only use them for experimenting; often loading packages or general code has
been moved into the non-visible preamble in the examples for space reasons; for example
loading the package eurosym when using the € symbol. The omitted parts are never important
to understand the examples though. Some of the examples use non-standard packages or
further external programs; they are available in the same CTAN directory.
If nothing else has been specified, the packages from T^XLive 2007 or the packages from
CTAN from the end of 2007 are used. Newer versions of TjgXLive should not cause any
problems unless individual packages have made extreme changes to the syntax. Sometimes
explanations of different packages will seem similar; we decided it would be better to restate
Preface
them instead of referring the reader to the appropriate explanation given for a different
package. It is always difficult to evaluate which individual packages are best, but loading the
array, booktabs, tabularx, and (for external data) datatool packages should always be a
sensible default. Identifying preferences between the other packages is left to the reader.
Conventions used in this book:
> Names of commands, environments, packages etc. when referred to in the text are set
in a monospace font, like longtable.
> Throughout the book we have referred to mathematics as math.
> Optional symbols or parameters are signified in syntax by being set against a
jjj^pbackground. For environments, this applies especially to the starred variant (* ).
> In some cases parts of a preamble have been moved to the non-visible part of an
example’s coding to save space. There is always a note in the text where this has
CTAN been done. This will not limit the user’s understanding; the entire source code of all
the examples can be downloaded from c t a n at any time (h ttp : //mirror. CTAN. org/
info/examples/Tabulars-E/).
> The symbol <<*>in the margin indicates an issue that the user should bear in mind as it
can cause a problem.
My thanks, as always, go to Klaus Hoppner, Lutz Ihlenburg, Christoph Kaeder, Rolf
Niepraschk, Uwe Ziegenhagen, and especially Volker RW Schaa, who kindly looked over the
manuscript, pointed out errors, and gave valuable feedback. And last but not least a big thank
you to Lars Kotthoff, who translated this English version from the German original and to
Catherine Jagger for her excellent job of proof reading.
In t r o d u c t io n
1.1 The tabular environment................................................................................... 3
1.2 The tabbing environment.................................................................................. 12
1.3 N otes................................................................................................................ 17
When you display information in a table, the typography you choose is very important; tables
containing the same information can be typeset in many different ways, but some layouts
will be much clearer than others. It’s difficult (and subjective) to define conventions that will
always result in a table that is easily understood, but the following points are good guidelines:
> no vertical lines
> no double lines
> rows not too narrow
> columns not too far apart
> rows left- and right-aligned with horizontal lines
> horizontal lines of different widths
This first chapter looks at the two environments supported in standard KTeX for typesetting
tables: the tabular environment and the tabbing environment. Chapters 2-4 introduce all
the additional packages that provide support for typesetting tables, with chapter 3 focusing
on the use of colour and chapter 4 on multi-page tables. Chapters 5 and 7 cover some general
points that are not package specific, while chapter 6 provides a large and useful set of examples
to help the reader.
\end{tabular}
\begin{ tabular* }{widf/i} [position] {column definition}
\end{tabular*}
Table 1.1: This example illustrates the use of left right p{3cm} foi-oi-i~]
the \tabcolsep space; the lighter block marks
the left side of a column and the darker block l e f t ® right!|p{3cm} |
the right.
width value
\tabcolsep 6 .Opt
\widthof {left} 1 3 .36996pt
2 \tabcolsep 1 2 .Opt
\widthof {right} 1 9 .96996pt
2 \tabcolsep 1 2 .Opt
p{3cm} 8 5 .35826pt
Ytabcolsep 6 .Opt
full width 1 5 4 .69818pt
If the whole table is put into a box, the resulting width is 156.29816pt when using the
array package at the same time; this corresponds to a difference of 1.59998pt, or rounded
1 .6pt. This is the sum of the width of the four vertical lines in Table 1 .1 , which is given by the
width of \arrayrulewidth=0.4pt. If these vertical lines are omitted, or the array package is
not used, the width of the box is 154.69818pt. All of the lengths specified here were measured
by TgX and output with \the\<length> to ensure that the calculation was correct.
4
1.1 T h e t a b u la r en viro n m en t
Being able to determine the exact width of a table is especially useful when you want a
table to span several pages, using the whole width of each page. However, actually achieving
this is only possible through reading an external file or using other packages, as shown in
Section 4.3 on page 141. Without any extension package, there are only two special symbols
that you can use for extended column definitions, * and @:
*{number} {colum n type}, where num ber is the repetition factor and colum n type an
arbitrary code sequence.
1 1 1 r r r r \usepackage{array}
L L L R R R R \b eg in {ta b u la r}
{ I * { 3 } { 1 } |* { 4 } { r |} } \c lin e { l- 3 }
l&l&l&r&r&r&rW L&L&L&R&R&R&RX\\cline{l-3}
\end {tab ular}
©{...}, where “... ” stands for an arbitrary code sequence that is now inserted on each line
instead of the column spacing. There is no space to the left and right between two columns.
In the following example, firstly a colon and then an arrow are inserted instead of the column
space.
Using the starred version of the tabular environment lets you specify a certain table
width; however, only adapts the width of the last column to achieve the specification.
The following example shows this clearly; the last column of the second table is right-aligned,
but this has no effect as the space that follows remains the same as in the first table.
1 2 3 \b e g in { ta b u la r * } { \lin e w id th } { lll}
A B left 1 & 2 & 3 \\\h lin e A & B & le ft \\\h lin e
\en d {ta b u la r* }\p a r\b ig sk ip
\b e g in { ta b u la r * } { \lin e w id th } { llr }
1 2 3
1 & 2 & 3 \ \ \ h l i n e A & B & r ig h t \ \ \ h l i n e
A B right \end {tab ular*}
This doesn’t usually produce a satisfactory result, but if you also use the ©operator and
the \extracolsep command, an even distribution of the “column widths” can be achieved.
The syntax of the \extracolsep command is:
To achieve an even distribution of columns, you have to pass the dynamic length \ f i l l
as the { len gth } or column distance. The difference between enlarging the column width
and the spacing between columns (\tabcolsep) becomes visible when using vertical lines;
the following examples clearly illustrate that the tabular* environment only changes the
spacing between columns.
In tro d u c tio n
1 2 3 \b e g in { ta b u la r* } { \lin e w id th } %
{ | M { \ e x t r a c o l s e p { \ f i l l } } 11 11 1}
A B c 1 & 2 & 3 \\\h lin e A & B & C \\\h lin e
\e n d { t a b u la r * } \ p a r \b i g s k i p
1 2 3 \b e g in { ta b u la r* } { \lin e w id th } %
A B c { | 1 | 1 |@ { \ e x t r a c o l s e p { \ f i l l } } r |}
1 & 2 & 3 \\\h lin e A & B & C \\\h lin e
\e n d { ta b u la r * }
As the first table above showed, inserting @ { \e x t r a c o ls e p { \f ill} } after the first table
column distributes the additional column spacing evenly. Alternatively you can insert it
before the first column if you don’t want a \t a b c o ls e p space at the left-aligned border, as
shown below.
1 2 3 \b e g in { ta b u la r* } { \lin e w id th } %
{ |@ { \ e x t r a c o l s e p { \ f i l l } } l 1 1 11@{} I}
A B C
1 & 2 & 3 \\\h lin e A & B & C \\\h lin e
\e n d { t a b u la r * }\ p a r \ b i g s k i p
1 2 3 \b e g in { ta b u la r* } { \lin e w id th } %
left left right { |@ { \ e x t r a c o l s e p { \ f i l l } } l |1 |r@ { } |}
1 & 2 & 3 \\\h lin e
le f t & le f t & rig h t \\\h lin e
\e n d { ta b u la r * }
To achieve better results, you should use the ta b u la rx environment from the package
tabu larx of the same name when creating tables o f a certain width; corresponding examples can be
found in Section 2.18 on page 87. Alternatively, the widths of the columns can be calculated
manually, as shown already in Table 1.1 on page 4. The advantage of this is that it is the
widths o f the columns that cire adapted to achieve the specified width and not the spacing
between the columns.
1 . 1.1 L in e s
You should always bear in mind that lines usually do not improve the clarity o f a table and
using them is often counterproductive. This is especially true for vertical lines. Therefore,
the following examples are explicitly not intended as a guide, but only as examples of how to
create lines. Horizontal lines spanning the whole table width Eire created with \h lin e , or you
can use \ c l i n e to add a horizontal line across a specified range of columns.
\h lin e
\ c l i n e {sta rt column-end column}
You usually need to precede either of these commands with \ \ or \ta b u la r n e w lin e; the only
exception is when you want to get a line above a table, in which case the relevant command is
placed immediately after the column definition. If the values for start column and end column
are the same, the line spans only this single column.
6
1.1 T h e ta b u la r e n v iro n m e n t
Horizontal lines always take precedence over vertical lines (particularly important to
remember if you are using double lines). This results from the fact that TgK typesets the
vertical lines line by line, only taking the line height into account. The following example
shows how to use \ h l i n e to create borders and multiple lines:
\ c l i n e { 2-2} creates a line only below the second column and \c lin e { 2 -3 } below the
second and third columns. If a \ c l i n e command is preceded or followed by a \h l i n e
command, it has no effect as it is overwritten by \h lin e . \ c l i n e may occur several times
in a row, but behaves like a single \ c l i n e without code modifications! However, you can
use \ c l i n e several times in a row to achieve horizontal lines over various ranges of columns,
as in Example 01-01-11 on the next page. To find out how to colour horizontal lines, see
Section 3.3 on page 122.
Very thick lines can look bad as can’t join them neatly at the corners and doesn’t
take the width of the lines into account when determining the line spacing, as illustrated here: thick lines
\s e t l e n g t h \ a r r a y r u l e w i d t h { 5 p t }
01-01-9
\ b e g i n { t a b u l a r } { |c |c |} \ h l i n e
A & B \\\c lin e { l-l}
C & D \\\h lin e
\e n d { ta b u la r }
You can easily influence the height of an individual row by inserting a \r u l e command in
one o f its cells. Setting the width to null makes the inserted line invisible. Vertical lines are
more problematic as their width does not affect the horizontal width of a table; the lines are
drawn “on top” o f the text. Bear this in mind especially for thick vertical lines. The array vertical lines
package (cf. Section 2.1 on page 21) fixes the corner connections and produces better results
with thick vertical lines (cf. Section 2. 1.1 on page 26). This example uses both the array
package and the \ r u l e command to produce a better result:
7
In tro d u c tio n
\u s e p a c k a g e { a r r a y }
\s e tle n g th \a r r a y r u le w id th { 5 p t}
\ b e g i n { t a b u l a r } { |c |c |} \ h l i n e
A & B \\\c lin e { l-l}
\ru le { 0 p t} { 3 .2 e x } C & D \ \ \ h l i n e
\e n d { ta b u la r }
1 . 1.2 C e ll s c o v e r i n g s e v e r a l c o l u m n s
The \m u lticolum n command allows you to merge several cells within a row into one cell
with an independent column definition, including the possibility of adding vertical lines that
are only valid for this cell. It can also be used for an individual cell to change the column type.
The syntax is:
For the column definition , you can use any o f the notations valid for the standard ta b u la r
environment. More options are available when using the array package, (cf. Section 2.1 on
page 21).
people profession
number sex employed freelance
222 m 160 62
2 n 1 2
97 w 70 27
sums
319 230 89
319
Using the \m u lticolum n command is fairly straightforward, but you need to take a little
care over vertical lines. The table’s overall column definition, controlling each column’s type
and vertical lines, is ignored through \m ulticolum n, so part of a vertical line will be missing
unless you remember to repeat the line definition within \m ulticolum n. Normally this only
1 .1 T h e ta b u la r e n v iro n m e n t
people profession \ b e g i n { t a b u l a r } { |c c |c c |} \ h l i n e
|~01-01-12 |
\m u ltic o lu m n { 2 } { |c } { \te x tb f{ p e o p le } } &
\m u ltic o lu m n { 2 } { c |} { \te x tb f { p r o f e s s io n } } \ \ \ h l i n e
number sex employed freelance
\m u ltic o lu m n { 4 } { c } { } \\% empty l i n e w ith o u t |
222 m 160 62 num bers sex& employedS f r e e l a n c e \ \ \ h l i n e
2 n 1 2 222 & m & 160 & 62 \ \
97 w 70 27 2 & n & \te x tb f{ l} & 2 \ \ [ 5 p t ]
97 & w & 70 & 27 \ \ \ h l i n e
sums
\m u ltico lu m n { 4 } { c}{ su m s} \\\c lin e { l-l}
319 230 89
\m u lt ic o l u m n { l} { |c |>{319} & & 230 & 89
319 \\\c lin e { l-l} \c lin e { 3 - 4 }
& & \m u ltic o lu m n { 2 } { c |} { 3 1 9 } \\\c lin e { 3 -4 }
\e n d { ta b u la r }
people profession \ b e g i n { t a b u l a r } { |c c |c c |}
\m u ltic o lu m n { 2 } { |c |} { \e m p h { p e o p le } } &
number sex employed freelance \m u ltic o lu m n { 2 } { c |} { \e m p h { p ro f e s s io n } } \\[5 p t]
222 m 160 62 number & se x & em ployed & f r e e l a n c e \ \ \ h l i n e
2 n 1 2 222 & m & 160 & 62 \ \
2 & n & \te x tb f{ l} & 2 \ \ [ 5 p t ]
97 w 70 27 97 & w & 70 & 27 \ \ \ h l i n e
sums \m u ltic o lu m n { 4 } { |c |} { s u m s} \\\c lin e { l-l}
319 230 89 \m u lt ic o l u m n { l} { |c |>{319} & & 230 & 89
319 \\\c lin e { l-l} \c lin e { 3 - 4 }
\m u ltic o lu m n { l} { c } { }
& & \m u ltic o lu m n { 2 } { c |} { 3 1 9 } \ \ \ c l i n e { 3 - 4 }
\e n d { ta b u la r }
1 .1 .3 N e ste d ta b le s
Tables can be nested arbitrarily. We recommend that you align the code clearly though, as
nestings frequently make it harder to get an overview and errors are introduced more easily,
which are then very hard to find. Nesting tables lets you typeset any complex arrangement
without having to resort to using the m ultirow package (cf. Section 2.3 on page 30), which
doesn’t always produce the desired result. In the following example, the cells with lowercase
characters are part of a nested table, which can be framed easily with the \ h l i n e or \ c l i n e
command.
\b e g in { ta b u la r } { c c c c c }
A1 & A1 & A1 & A1 & A l \ \ \ h l i n e
A2 & \ b e g i n { t a b u l a r } { |c |} \ h l i n e
a l\\a l\\a l\\\h lin e
\e n d { ta b u la r }
9
In tro d u c tio n
Al Al Al Al Al
al a2 a3
A2 al a2 A a3
al a2 a4
A3 A3 A3 A3 A3
A4 A4 A4* A4
A5 A5 A5 A5 A5
The following example shows an unsatisfactory result, with the spacing between the
columns much too large. This is caused by the \ta b c o ls e p space that precedes every table,
leading to additional space when a table is nested inside another table. According to Table 1.1
on page 4, in this example there is a space of 3 \ta b c o ls e p or 4 \ta b c o ls e p between any two
columns.
col 11 co 2 ll co3 ll \ b e g i n { t a b u l a r } { |c c c |}
c o l 11 & co2 11 & co3 1 1 \ \
col 12 c o 4 12
co2 12/3 \b e g i n { ta b u l a r } { c } c o l 1 2 \ \ c o l 1 3 \e n d { ta b u la r}
col 13 c o 4 13
& \ b e g i n { t a b u l a r } ! I c |} \ h l i n e
col 14 co2 14 co3 14
co2 1 2 / 3 \ \ \ h l i n e \e n d { ta b u la r }
& \b e g in { ta b u la r} { c } c o 4 1 2 \\c o 4 1 3 \ e n d { t a b u la r } \ \
c o l 14 & co2 14 & co3 14
\e n d { ta b u la r }
Using the @column operator corrects these additional spaces, as shown in the following ex
ample. In this case the superordinate table uses a column definition of { | @{ }c @{ }c@{} c@{ } | }
to ensure that all the columns have no extra space (as can be seen on the outside of the
external columns). Nevertheless, there is still a space of 2\ta b c o ls e p between the inner
columns, caused by the inner (nested) tables.
l @{ } an d The order o f | and @f } has to be observed; at the start of a column definition you must
<a{} / are jl specify first the vertical line, then no additional space. If you did the reverse, (@{ } then | ), @{ }
different
10
1.1 T h e ta b u la r e n v iro n m e n t
would have no effect - it is cancelled by the vertical line, which is then followed by either the
default \t a b c o ls e p or whatever else is specified next.
You can take different approaches, depending on what structure of table and placement of
lines you want to produce. For example inner tables can be typeset without spacing between
the columns, or the frame of an inner table can be put around it from the outside, as illustrated
in the following example.
It is also a good idea to define abbreviations to make your code clearer and therefore
reduce the likelihood of errors with nested tables. For example we define:
\newcommand\Btab{}% make s u r e t h a t i t d o es n o t e x i s t
\r e n e w c o m m a n d \B ta b [2 ][ c ]{ \ta b u la r [# l] { # 2 } }
\newcommand\Etab{}% d i t t o
\renew com m and\Et a b { \e n d t a b u l a r }
We will define and use these commands in the following example. Also in this case the
first line is extended upwards and the last line downwards to achieve a better placement of
the frame; this is done using \r u le .
\newcomm and\Btab{}
| 01-01-18 | col ll co2 ll co3 ll \r e n e w c o m m a n d \B ta b [2 ][c ]{ \ta b u la r[# l]{ # 2 } }
col 12 C0412 \n ew co m m an d \E tab {}\ren ew co m m an d \E tab {\en d tab u lar}
co2 12/3
col 13 C0413
\B tab{|@ {}c @{}c@{} c @ { } |} \h lin e
col 14 C02 14 C03 14
\ru le { 0 p t} { 3 e x } % b e t t e r s p a c in g above
c o l 11 & co2 11 & co3 l l \ \ \ c l i n e { 2 - 2 }
\ B t a b { c |} c o l 1 2 \ \ c o l 13 \E ta b &
\B ta b { c } co2 1 2 / 3 \ \ \E ta b &
\B ta b { |c } co4 1 2 \\c o 4 13 \E ta b \ \ \ c l i n e { 2 - 2 }
\r u le [ - l.5 e x ] { 0 p t} { 2 e x } % b e t t e r s p a c in g below
c o l 14 & co2 14 & co3 1 4 \ \ \ h l i n e
\E ta b
11
In tro d u c tio n
1 .1 .4 F o o t n o t e s
The \ f o o tn o te command doesn’t work as expected within a table as the text of the footnote
doesn’t display. Instead, there are packages that support footnotes in tables or you can use
the \footn otem ark and \f o o t n o t e t e x t combination o f commands. The latter works in
virtually all cases where the \f o o t n o t e command fails.
\footn otem ark increments the footnote counter fo o tn o te and only typesets the number of
the footnote, while \f o o t n o t e t e x t only typesets the text of the footnote without changing
the counter. If the optional argument is given, the footnote counter is not changed and number
is taken as the footnote, where number must be a positive number.
L1 C R \b e g in { c e n te r } ,---------
\b e g in { ta b u la r} { lc r} \h lin e 101—
L C R
L \fo o tn o te m a rk & C & R \\
L c2 R
L & C & R \\
L C R L & C \fo o tn o te m a rk & R \\
L c R3 L & C & R \\
L & C & R \f o o t n o te m a r k \ \\h l in e
Normal line of text after the centred table with \e n d { ta b u la r }
normal footnote4. \a d d to c o u n te r { f o o tn o te } { - 2 }
\f o o tn o te te x t{ le f t-a lig n e d }
\s te p c o u n t e r { f o o tn o t e } \f o o t n o te t e x t{ c e n t r e d }
^eft-aligned \s te p c o u n te r{ fo o tn o te } \fo o tn o te te x t{ rig h t- a lig n e d }
2centred \e n d { c e n te r }
3right-aligned Normal l i n e o f t e x t a f t e r th e c e n tr e d t a b l e w ith
4normal footnote no rm al f o o tn o te \f o o tn o te { n o r m a l f o o tn o te } .
\b e g in { ta b b in g }
A \=example lin e ... \ k i l l \ \
\>formatted lin e s \\
\en d {ta b b in g }
12
1 .2 T h e ta b b in g e n v iro n m e n t
command meaning
\= Puts a tab at the current position.
\> Jumps to the next tab.
\< Puts text to the left o f the left margin without changing it.
\+ The left margin is moved one tab to the right.
\- The left margin is moved one tab to the left.
\ ’ The text before the \ ’ command is right-aligned and the text after it is
left-aligned.
V The text after the \ ‘ command is right-aligned on the line.
\a To typeset accents within the tab b in g environment; for example \ a ’ e
displays as e.
\k ill Deletes the current (example) line and keeps the tabs defined in it.
\p u sh ta b s Saves all current tabs.
\p o p ta b s Loads all last saved tabs.
The example line in conjunction with the \ k i l l command lets you specify the individual
tabs easily; \ k i l l deletes the line, but not the positions specified through \=.
first tab \b e g in { ta b b in g }
second tab The \= ex am p le l i n e \= c a n
\= b e \ = “ k i l l e d ” \ k i l l \ \
third
\ > f i r s t t a b \ \ \> \> s e c o n d t a b \ \
fourth
\> \> \> th ir d \\ \> \> \> \> fo u rth \\
0 1 2 3 4
0 \>1 \>2 \>3 \>4
\e n d { ta b b in g }
Current tab positions can be saved and reloaded with the \p u sh ta b s and \p op tab s
commands. They work like a LIFO-system: last in, first out.
13
In tro d u c tio n
12 3 4 \b e g in { ta b b in g }
01-02-3
1 2 3 4 0 0 \= 0 0 0 \= 0 0 0 0 \= \k ill
1 2 3 \p u s h ta b s % sa v e ta b b in g p o s i t i o n s
accents Problems can arise when using some short commands if they are defined as accents at the
same time. In these cases the accents within a tab b in g environment have to be introduced
by \a ; an alternative is to use the Tabbing package (cf. Section 2.29 on page 109).
first café \b e g in { ta b b in g }
01-02-4
second café The \= exam ple l i n e \= c a n \= b e \ = ‘ ‘k i l l e d ’ ’\ k i l l \ \
mâitre \ > f i r s t c a f \ a ’e \ \ \> \> s e c o n d c a f \ a ’e \ \
\> \> \> m \a Aa i t r e \ \
crème brûlée
\ > c r \ a ‘e m e \> \> \> b r\a Au l \ a ’ee
\e n d { ta b b in g }
If the following lines need to be inset, the \+ command can be used to set the left margin
for the next (and future) lines one tab position further in. This saves you coding a \> at the
start of the next (and future) lines as the current left margin o f the text now corresponds
to the position o f that tab. This effect can be reversed through \ - ; the current left margin
is moved to the left by exactly one tab. These two commands are especially useful when
typesetting algorithms if you are unable to use the usual l i s t i n g s package.
As with a normal table, the individual elements between the tabs are typeset as a group,
so if you want to change the font for a whole tab b in g environment you must do it before
the environment. Extra tab stops can be added after the example line by inserting \= at the
appropriate place; however these new tabs are always added to the available list, existing ones
are not deleted.
14
1 .2 T h e ta b b in g e n v iro n m e n t
You don’t need to use example text to specify tabs; you can also use \h sp ace, as in this
example:
A norm al l i n e \ l d o t s
\b e g i n g r o u p \ s m a l l \ t t f a m i l y % keep change o f f o n t l o c a l
\b e g in { ta b b in g }
\= \h s p a c e { 0 .2 5 in } \= \h s p a c e { 0 .2 5 in } \= \h s p a c e { 0 .2 5 in } \ = \ h s p a c e { 0 . 2 5 i n } \ k i l l
\> < categ o ry > \+ \ \
\> <pattern>WHAT IS A * < /p a tte r n > \+ \ \
\> < te m p la te x sra i> D E F IN E < s t a r in d e x = " l " x / s r a i > \ \
\> < /te m p la te > \ - \ - \ \
\> < /c a te g o ry > \ \ [ 0 .5 \ n o r m a l b a s e l i n e s k i p ]
\> < categ o ry > \+ \ \
\> <pattern>D O YOU KNOW WHAT A * I S < /p a tte r n > \+ \ \
\> < te m p la te x sra i> D E F IN E < s t a r in d e x =,,l ,,x / s r a i x / t e m p l a t e > \ - \ - \ \
\> < /c a te g o ry >
\e n d { ta b b in g }
\e n d g ro u p
A norm al l i n e \ l d o t s
<category>
< p a t t e r n > W H A T IS A * < / p a t t e r n >
<template><srai>DEFINE <star index ="l"></srai>
</template>
</category>
<category>
< p a t t e r n > D 0 YO U K N O W W H A T A * I S < / p a t t e r n >
< t e m p l a t e > < s r a i > D E F I N E < s t a r i n d e x = " l ,,x / s r a i > < / t e m p l a t e >
</category>
You can use the \ ’ and \ ‘ tab commands to left- or right-align words. The right-alignment
of text after the \ ‘ command always refers to the line as a whole; further tabs after \ ‘
are ignored. The \ 1 command, however, refers to the current tab, right-aligning the se
quence o f characters before the command and left-aligning the sequence that follows it;
the difference can be seen clearly in the following examples. When using the \ ’ command,
the space between the right- and left-aligned sequences o f characters is specified through
\tabbingsep=5.0ptThis spacing can be changed arbitrarily, but this must be done globally
within the tab b in g environment, as the material between two tabs is held locally internally
and a change of the length here would have no visible effect.
15
In tro d u c tio n
0 1 2 3 4 \b e g in { ta b b in g }
01-02-7
2 left-aligned The \= exam ple l i n e \= c a n
2 left-aligned \= b e \ = ‘ ‘ k i l l e d ’ ’\ k i l l \ \
1 left-aligned 0 \>1 \>2 \>3 \>4\\
\> \> 2 \ ’l e f t - a l i g n e d \ \
0 left-aligned
\g l o b a l \ s e t l e n g t h \ t a b b i n g s e p { 2 0 p t }
\> \> 2 \ ’l e f t - a l i g n e d \ \
\g l o b a l\ s e t le n g th \ ta b b i n g s e p { O p t }
\> 1 \ ’l e f t - a l i g n e d \ \
0 \ ’l e f t - a l i g n e d \ \
\e n d { ta b b in g }
0 1 2 3 4 \b e g in { ta b b in g }
01-02-8
2 right-aligned on the line The \= exam ple l i n e \= c a n
1 right-aligned \= b e \ = ‘ ‘k i l l e d ’ ’\ k i l l \ \
0 right 0 \>1 \>2 \>3 \>4\\
\> \> 2 \ ‘r i g h t - a l i g n e d on th e l i n e \ \
\> 1 \ ‘r i g h t - a l i g n e d \ \
0 V rig h t \ \
\e n d { ta b b in g }
Horizontal centring of tabbing environments is surpriginly easy - just insert the envi
ronment into a minipage of maximal width; this “clips” it to the required width after the
creation of the tabbing environment.
footn ote Footnotes in the tabbing environment behave similarly to footnotes in the tabular
environment (cf. Section 1.1.4 on page 12); in theory they are not possible but can be achieved
through the combination \footnotemark - \footnotetext or with special packages.
Remember when you use this combination of commands that \f ootnotemark increments
the footnote counter, so it has to be reset before the text of the footnote is written with
\footnotetext. This is shown in the following example:
16
1 .3 N o te s
f fb fbb \b e g in { ta b b in g }
f1 fb fbb fo o \= fo o b a r \= f o o b a r b a z \ k i l l
f fb fbb f \> fb \> f b b \ \
f\f o o tn o te m a r k \> fb \> f b b \ \
f fb*2 fbb
f \> fb \> f b b \ \
f fb fbb
f \> fb \fo o tn o te m a r k \> f b b \ \
f fb fbb3 f \> fb \> f b b \ \
f \> fb \> fb b \fo o tn o te m a r k
Normal line of text after the ta b b in g envi \e n d { ta b b in g } \a d d to c o u n te r { f o o tn o te } { - 2 }
ronment with normal footnote4. \ f o o t n o t e te x t { f o o } \ s t e p c o u n te r { f o o t n o te }
\ f o o tn o t e te x t { f o o b a r } \s t e p c o u n te r { f o o tn o t e }
Too \f o o tn o t e te x t { f o o b a r b a z }
2foobar
3foobarbaz
Normal l i n e o f t e x t a f t e r th e
4normal footnote
\ t e x t t t { t a b b i n g } en v iro n m e n t w ith norm al
f o o tn o te \f o o tn o te { n o r m a l f o o t n o t e } .
Special packages for tabs are covered in Section 2.28 on page 108. They allow for easier
setting of tabs and simplify the handling of accents.
1.3 Notes
This section summarizes some important facts and frequently made mistakes when using the
ta b u la r or tab b in g environments:
> All definitions within a table cell are local to the cell; internally the contents of a table
cell is enclosed in a \b e g in g r o u p ... \endgroup sequence.
> Vertical line segments may be missing if rows are terminated prematurely by \ \ or
\ta b u la r n e w lin e when using the array package. Empty cells should be marked as
&&.
> A common mistake is caused by too few defined designators for column types. The
following error message was caused by using three columns where only two were
defined:
! E x tra a lig n m e n t ta b h a s been changed t o \ c r .
< r e c e n tly rea d > \e n d te m p la te
1 .7 te x t & te x t &
\\
?
> The space between two columns is 2\ta b c o ls e p by default; the space to the left and
right of each column is \ta b c o ls e p .
> \m u lticolum n overwrites the existing specification for the right hand side of the
column or columns by default. This should be kept in mind especially for vertical lines.
In the case of the first column, the left margin is affected as well.
> The tab b in g environment has the advantage that it can be used in two-column mode
(\twocolumn) and additionally allows for page breaks.
17
Introduction
C h a p t e r
Packages
This chapter describes all packages related to tables that are currently available on ctan
except for packages that support tables across several pages, which are covered in Chapter 4
on page 125. It’s always worth checking before you use a package whether it has been updated
in the meantime. To help you, the following table lists all packages with their respective
version and date. Some packages are certainly more important than others, though as this is
fairly subjective we’ve listed them mostly alphabetically, just distinguishing between certain
thematic areas: “general - decimal numbers - colour - tabs - page break”, and left it up to
you to decide which packages are important and necessary.
2 Packages
20
2.1 a rra y
... continued
2.1 array
The array package by Frank Mittelbach and David Carlisle offers several better ways to
typeset tables. The use of booktabs is recommended as well. The following table is laid out
firstly with “normal” column definitions, and then each new method is shown for comparison.
Again please note that we are only using horizontal and vertical lines in these tables to
highlight the differences between the layouts; lines do not improve the readability of a table
and, in principle, we recommend that you never use vertical lines and only use horizontal
lines sparingly (cf. guidelines on page 3).
right centred \ b e g i n { t a b u l a r } { |1 |r |c |p { 2 c m } |} \ h l i n e
|02-01-1 | left box
l e f t & r i g h t & c e n tr e d & b o x \ \ \ h l i n e
i r c p{2cm}
1 &r & c & p \{ 2 c m \} \\\h lin e
\e n d { ta b u la r }
\extrarowheight increases the height of the line without affecting the depth; therefore
this space should not be set too large. Its main use is to avoid capital letters “hitting” an upper
line.
\u s e p a c k a g e { a rra y }
left right centred box
\ s e tl e n g th \ e x tr a r o w h e i g h t{ 8 p t}
i r c p{l.75cm} \ b e g i n { t a b u l a r } ! |1 |r |c |p { l . 7 5 c m } |} \ h l i n e
l e f t & r i g h t & c e n tr e d & b o x \ \ \ h l i n e
1 & r & c & p \ { 1 .7 5 c m \ } \ \ \ h l i n e
\e n d { ta b u la r }
\arraybackslash redefines the standard double backslash command for a table line
break (\\). Without this redefinition it would not retain its meaning when using one of
the formatting commands, \raggedright, \raggedleft or \centering, in a p (\parbox)
column. Now for a new row w ith in a colu m n use the \newline command and for a new ta b le
ro w use \\ or the \tabularnewline command:
21
Packages
When using the ragged2e package, however, you don’t have to insert the \arraybackslash
command explicitly:
>{...}, where “... ” is any arbitrary code sequence, executes this code b efo re th e s ta r t of
the respective column in each row. In the following example, bold font is selected for the first
column:
<{...}, where “... ” again is any arbitrary code sequence, executes this code before th e e n d
of the respective column in each row this time. In the following example, math mode was
selected by switching on inline mode through >{$} and off again through the following <{$}:
!{...}, where “...” is any arbitrary code sequence, inserts this code in s te a d o f a separator
in each row. The space to the left and right of the two columns remains the same. In this
example, a colon and an arrow are inserted instead of the separator:
22
2.1 a rra y
m{...}, where “... ” is an arbitrary length (e.g. m{3cm}), centres (middle) a box aligned
with the base line of the current row vertically.
b{...}, where “. . . ” is an arbitrary length (e.g. b{3cm}), aligns a box with the bottom of
the current row.
2.1.1 \newcolumntype
\newcolumntype{ ch a ra c te r } j|||;{ co lu m n d e fin itio n }
The \newcolumntype command lets you define arbitrary new column types that can then be
used in their abbreviated form as column definitions in the table head. You can only use a
single case sensitive letter as the ch a ra cter ; and it must be different from ones already defined
unless you don’t mind the earlier definition being overwritten, n specifies the number of
parameters; it has no effect if the definition uses no parameters. The c o lu m n d e fin itio n must
refer to a column type that exists already. The following example shows how to use the
command:
23
2 Packages
In the next example, the headers are rotated so as not to widen the columns needlessly,
which would decrease the readability of the table. If a column has a header of multiple rows,
it’s better to use the varw idth package by Donald Arseneau and the environment of the same
name. Its advantage over the m inipage environment is that you don’t need to specify the
required width explicitly.
\usepackage{array,rotating}
\newcolumntype{B}{>{\bfseries}c}
\newcolumntype{T}{>{\ttfamily}l}
\newcolumntype{R}[1 ]{>{\begin{turn}{#l}}l<{\end{turn}}}
\begin{tab u lar}[b ]{BT1}
\multicolumn{l}{R{45}}{abbreviation} & \m ulticolumn{l}{R{45}}{reference column} &
\m ulticolum n{l}{R{45}}{param eter}\\\hline B & c & - \ \ T & 1 & - \ \ R & 1 & l \ \ \ h l i n e
\end{tabular} \qquad
\begin{tabular}[b]{@{}BTl@{}}
\multicolumn{l}{R{90}}{abbreviated} & \multicolumn{l}{R{90}}{reference column} &
\multicolumn{l}{R{90}}{parameter}\\ B & c & - \ \ T & 1 & - \ \ R & 1 & 1
\end{tabular}
02-01-11
o
<u o
<
C L
J> B
tí (Ü
8 ,<aL>
B
3 Í3
Oh
B c
T T 1
R 1 R 1
hyphenation T^X is set not to hyphenate the first word o f a paragraph. However, sometimes hyphen
ation is desirable in a narrow column, and the workaround is to define a column type that
starts the column by writing a \h s p a c e { 0p t}; this is recognised as a word of length zero by
T^X, which then will be able to hyphenate the following regular word. This is clearly visible
in the following example; the first table has an error in the last column, the second one is
correct.
24
2.1 a rra y
Horizontal alignment can be adjusted with the three commands mentioned earlier:
\raggedleft, \centering, and \raggedright. Alternatively you can use the modified
commands \RaggedLeft, \Centering, and \RaggedRight from the ragged2e package by
Martin Schroder, which allow hyphenation.
\usepackage{array, ragged2e}
\newcolumntype{L}[1 ]{>{\hspace{Opt}\RaggedRight}p{#l}}
\newcolumntype{C}[1 ]{>{\hspace{Opt}\Centering}p{#l}}
\newcolumntype{R}[l]{>{\hspace{Opt}\RaggedLeft}p{#l}}
\begin{tabular}{@{}L{3cm}C{3cm}R{3cm}@{}}\hline
A l e f t aligned column with ragged right margin
& A centred column with ragged l e f t and ragged right margin
& A right aligned column with ragged l e f t margin\\
L & C & R \\\h lin e
\end{tabular>
\newcolumntype may define more than one column type as well; for example the defini
tion \newcolumntype{x}{llcll} defines five columns. Here it is in use:
Especially when using larger packages, it can sometimes be helpful to set the defined
column types to be output into the log file through \showcols.
\showcols
The log file for Example 02-01-13 contains the following lines:
25
2 Packages
Vertical lines
When using the \multicolumn command, you need to be careful about the definition of
vertical lines, especially if this definition is done in the parent column definition as well as in
the argument of \multicolumn. In the following example, we have made the affected vertical
line very wide to illustrate the potential problem:
L \usepackage{array} ,---------
L I I |c |l [ 02-01-15
llJ1 CCC L \b eg in {ta b u la r}{|1 !{\vru le width 3 p t } l|c |1 |1 |} \h lin e
L & L & C & L & L \\
LL&\multicolumn{3}{!{\vrule width 3pt}c|}{CCC} & L \\\h lin e
\end{tabular}
This shows that the vertical line was drawn by both the normal column definition as
well as by the \multicolumn one. This only occurs when using the array package, because
this considers vertical lines with their real width. In the normal tab ular environment of
standard ETgX, the lines are not considered when determining the horizontal spacing - the
lines are drawn on top of each other. The exception is a \multicolumn environment that
starts in the first column though; in this case both left and right vertical lines have to be
drawn if requried. Otherwise a line only has to be placed on the right hand side of the column
definition. Remember, lines are always assigned to the previous column except for the first
column.
L L C L L \usepackage{array> ,---------
I02-01-16
CCC L L \begin {tab u lar}{!{\vru le width 3 p t } l|1 | c | 1 | 1 |} \h lin e
L L right L&L&C&L&L \\ \c li n e { l - 3 }
\m ulticolum n{3}{!{\vrule width 3pt}c|}{CCC} & L & L \\\h lin e
L & L & \m ulticolum n{3}{r|}{right} \\\h lin e
\end{tabular}
H o r i z o n t a l lines
As long as a framed table is in its own paragraph or centred vertically on a line, for example
like this table, there are no problems with the display - apart from the typographically
adverse line spacing. If, however, you align the upper edge of a table with the base line of
the current line through the optional argument [ t ] , for example like this_____ table, then
one
two
there is a problem with the first horizontal line of the table, which is a long way below the
current text line. The fact that the bottom line is too close to the following fine of text is only
a small problem in comparison. The array package has two special commands to help you
align both the first and last horizontal lines more appropriately:
26
2 .2 a ry d s h ln
\ firs th lin e
\ lasth lin e
In the following example the first table has the usual alignment, the second is shifted up
using the \ firs th lin e command to align the first text line with the existing text, and the
third one has a small amount of additional space inserted before the following line using the
\ lasth lin e command.
\usepackage{array}
lin e
\b egin {tab u lar}[t]{ |c |} \h lin e
o n e\\tw o \\\h lin e
\end{tabular} lin e \ \
a new lin e in the paragraph\par lin e
\b eg in {ta b u la r}[t]{ |c |} \f ir s t h lin e
o n e\\tw o \\\h lin e
\end{tabular} lin e \ \
a new lin e in the paragraph\par lin e
a new line in the paragraph \b e g in {ta b u la r }[t]{|c |} \f ir s t h lin e
o n e\\tw o \\\la sth lin e
\end{tabular} lin e \ \
a new lin e in the paragraph
You can change the spacing above and below the table using the \extratabsurround
length. The default value of this length is 2.0pt.
\usepackage{array}
02-01-18 A line in the paragraph before the table,
line one line A lin e in the paragraph before the tab le.
two \par lin e
A line in a paragraph after the table. \b eg in {ta b u la r}[t]{ |c |} \f ir s t h lin e
A line in a paragraph before the table and o n e \\tw o \\\la sth lin e
\addtolength\extratabsurround{10pt}. \end{tabular} lin e \ \
A lin e in a paragraph after the tab le.\p ar
line one line A lin e in a paragraph before the table and\\
\verb+\addtolength\extratabsurround{ 10pt}+.
two
\par lin e
\addtolength\extratabsurround{ 10pt}
A line in a paragraph after the table. \b eg in {ta b u la r}[t]{ |c |} \f ir s t h lin e
o n e\\tw o \\\la sth lin e
\end{tabular} lin e \ \
A lin e in a paragraph after the tab le.
2.2 arydshln
The arydshln package by Hiroshi Nakashima lets you use dashed vertical or horizontal lines; load
it works in conjunction with the normal line commands. If you are loading several table- a r y d s h ln
specific packages, make sure to always load arydshln last, in order to avoid interferences last
with other packages.
27
2 Packages
\usepackage{arydshln} .--------
left | right |\ centred j box I02-02-1
1 1 r 1i c i p{l.5cm} \b eg in {tab u lar}{| 1 :r : | :c :p { l . 5cm }|}\hline
1 1 r !| c 1 p{l.5cm} l e f t & right & centred & box\\\hdashline
1 & r & c & p \{ l.5 c m \} \\\h lin e
1 & r & c & p \{l.5cm \}\\\h d ash lin e\h d ash lin e
\end{tabular}
The example above shows that a colon defines a vertical dashed line and \hdashline a
horizontal dashed line; they are used in the usual way. Instead of the colon, you can also
use a semicolon, which has an argument that lets you modify the the lengths of the dashes
and the gaps. And similarly to the standard lines, you can use \cdashline to draw a partial
horizontal line across a subset of columns. Both \hdashline and \cdashline also have
optional arguments, allowing you to define the appearance of the dashed line. This box shows
the syntax for each:
v e rtic a l h o r iz o n ta l
i \hdashline [dash/gap]
; { d a s h /g a p } \cdashline{/rom-
to } [dash/gap]
When using the array package (N.B. you m u s t load it before loading arydshln), there
are also corresponding versions of \ firs th lin e and \ lasth lin e available (cf. Section 2.1.1
on page 26). They have an optional argument to specify the lengths of the gaps and dashes as
well. Here is the syntax followed by an example:
28
2 .2 a ry d s h ln
You can change the line style globally through the \d a sh lin e d a sh and \d a sh lin e g a p
lengths. Both are set internally to a length of 4 pt.
The different behaviour o f standard KT^X and the array package when creating ver
tical lines has already been mentioned in sections 1. 1.1 on page 6 and 2. 1.1 on page 26.
The aryd sh ln package provides two commands that let you switch between the different
behaviours:
\ADLnullwide \ADLsomewide
\ADLnullwide enables the behaviour of standard Fl^X: the width of the row has no effect
on the width of the table. \ADLsomewide has the opposite effect. In general you w on’t need
to worry about the distinction as the line width will usually be less than 1 pt. However, in
the following example we have set the line width to be excessively large to illustrate the
difference between the two commands:
J ■ ■ L \usepackage{arydshln}
02-02-5 u one a
u two ■ \setlength\arrayrulew idthf 5pt}
JL ■ ■ L \begin{tab u lar}{:c :}\hdashline
L" ■ "J one\\tw o\\\hdashline
u one u \end{tabular}\par\medskip
u two ■ \ADLsomewide% switch to array sty le
\b egin{tab u lar}{:c :}\hdashline
one\\tw o\\\hdashline
\end{tabular}
29
2 Packages
In some circumstances the dashed lines may not end properly at the right or lower
margin. If this happens, you can change the character mode to improve the joins using
\ADLdrawingmode:
\ADLdrawingmodef mode }
There are three different modes available (numbered 1, 2, and 3); in many cases the results of
the first (default) one will be perfectly satisfactory. The following example uses each mode in
turn for the same table; you have to look closely at the intersections of the dashed lines to see
the difference.
\usepackage{arydshln}
\setlen gth \d ash linedash {3.01p t}\setlen gth \dashlinegap{3. Olpt}
\newcomraand\Tabelle[l]{\begin{tabular}[b]{ | c :c ;{2 p t/2 p t}c |}\h lin e
\noalign{\vskip-\arrayrulew idth}
\mb{A}&\mb{A}&\mb{A}\\[-\arrayrulewidth]\hdashline
\mb{B}&\mb{B}&\mb{B}\\[-\arrayrulew idth]\hdashline[2pt/2pt]
\mb{C}&\mb{C}&\mb{C}\\[-\arrayrulewidth]\hline
\multicolumn3c{(#1)}
\end{tabular}}
\begin{center}
\Tabellel\qquad\ADLdrawingmode{2}\Tabelle2\qquad\ADLdrawingmode{3}\Tabelle3
\end{center}
[ 02-02-6
2.3.1 multirow
The \m u ltirow package provides just one command, with the following alternatives as its
syntax:
30
2.3 b ig d e lim , b i g s t r u t , m u lt ir o w
The meaning of the individual mandatory and optional parameters is explained below:
rows Number of table rows that are combined to a m ultirow cell.
sum \ b i g s t r u t This optional parameter can be helpful especially in the array environment
to achieve better spacing of the rows.
width The column type of the superior table is ignored and changed locally to a p
column of the specified width.
* Assumes the column type of the superior table.
shift The optional specification of a length makes fine-tuning of the vertical
position of the text possible.
text The contents of the \m u ltiro w cell; may be another table or other complex
objects, for example a parbox.
The principle is easily understood - you place the \m u ltirow command in the cell of the
table that marks the start of the multi-row cell. A fter that , i.e. in the next rows of the table,
you leave cells empty according to the definition of the \m ultirow . By default, the text is
inserted left-aligned horizontally and centred vertically if a column width has been given for
\m ultirow ; the cell then corresponds to the p column type. There is no check to see whether
the given text fits into the specified number o f rows, as is shown in the example above; the
required number of rows must be provided manually, as below:
31
Packages
Using the star in the \multirow command instead of specifying a width simply means
that the type of the current column as declared in the header of the table is used, as in the
following example:
The horizontal lines look bad as they appear very close to the text, especially in the left
column. You can increase the space by specifying an additional line feed, \\[Dim]. To do
this, you should use the \bigstrut command from the b ig stru t package to make multirow
aware of the change, \bigstrut corresponds to a box of a specific height and depth in
relation to the base line, but zero width (height above base line 2.0pt, depth below base line
2.0ptand width O.Opt.). Then if you also use the optional sum \bigstrut argument to tell the
\multirow command how many such \bigstrut commands there are, you will still be able
to centre the text vertically.
The following example shows what happens when the optional argument is not used.
This leads to a result where the \multirow entries are not centred vertically anymore.
coll rowO col2 rowO col3 rowO \usepackage{mult irow, b ig stru t} ,---------
[ 02-03-4 I
coll rowl col2 rowl \b eg in {ta b u lar}{| 1 |r |c |} \h lin e
col2 row2 col 3 c o ll rowO & col2 rowO & col3 row0\\
coll row2
c o ll rowl & c o l 2 rowl &
coll row3 \m ultirow{3}{l.25cm }{col 3 } \b ig s t r u t \\\c lin e { l- l}
col 2
coll row4 col3 row4 c o ll row2 & c o l 2 row2 & \b ig s t r u t \\\c lin e { l- 2>
c o ll row3 & \multirow{2}{1.25cm}{col 2} & \b ig s tr u t \\
\c lin e { l- l} \c lin e { 3 - 3 }
c o ll row4 & & col3 row 4\b igstru t\\\h lin e
\end{tabular}
If you do use the optional argument to tell \multirow the number of additional ac
tive \bigstruts, then the appopriate adjustment will be made for them. The number
of “active” \bigstrut commands results from the way the command is used. With
\bigstrut I p o s itio n ] , where position may take the values t for top and b for bottom,
additional space is only inserted above, or below, so this command is only counted once.
Without an optional argument, however, space is inserted above and below, so the command
counts twice.
In the following example, the first \multirow command extends across three rows and
the second one across two rows. This determines the values of the optional arguments;
\bigstrut was used in each respective row.
32
2.3 b ig d e lim , b i g s t r u t , m u lt ir o w
c l rO c2 rO c3 rO \usepackage{multirow,b ig stru t}
c lrl c2 r l \b eg in {tab u lar}{| 1 |r |c |} \h lin e
c l r2 c2 r2 c3 c l rO & c2 rO & c3 r 0 \\
c l r l & c2 r l &
c l r3 \multirow{3}[6]{1.25cm}{c 3 } \b ig s t r u t \\\c lin e { l- l}
c2
c l r4 c 3 r4 c l r 2 & c 2 r 2 & \b ig s t r u t \\\c lin e { l- 2}
c l r3 & \multirow{2}[4]{1.25cm}{c 2} & \b ig s tr u t \\
\c lin e { l- l} \c lin e { 3 - 3 }
c l r4 & & c3 r 4 \b ig s tr u t\\\h lin e
\end{tabular}
c l rO c2 rO c3 rO \usepackage{multirow,b ig stru t}
cl rl c2 r l \b egin {tab u lar}{ 11 1r |c |} \h lin e
c l r2 c2 r2 c3 c l rO & c2 rO & c3 r 0 \\
c l r l & c2 r l & \multirow{3}[6]{1.25cm}{c 3}
c l r3 \b ig s t r u t \\\c lin e { l- l}
c l r4 f ( x , y ) = x -y c3 r4 c l r 2 & c 2 r 2 & \b ig s t r u t \\\c lin e { l- 2}
c l r3 & \m ultirow {2}[4]{2cm }{\[f(x,y)=x\cdot y \]}
& \b ig s t r u t \\\c lin e { l- l} \c lin e { 3 - 3 }
c l r4 & & c3 r 4 \b ig s tr u t\\\h lin e
\end{tabular}
We can correct this using the \a b o v e d isp la y sk ip space, which is already defined in
E^X and the factor 0.8, which has been determined through trial and error here.
c l rO c2 rO c3 rO \usepackage{multirow,b ig stru t}
cl rl c2 r l \b egin {tab u lar}{ 11 1r |c |} \h lin e
c l r2 c2 r2 c3
c l rO & c2 rO & c3 r 0 \\ c l r l & c2 r l &
\multirow{3}[6]{1.25cm}{c 3 } \b ig s t r u t \\\c lin e { l- l}
c l r3 c l r 2 & c 2 r 2 & \b ig s t r u t \\\c lin e { l- 2}
f (x, y ) = x - y
c l r4 c 3 r4 c l r3 &
\m ultirow{2}[4 ]{2cm}[ 0 . 8\abovedisplayskip]{%
\[f(x ,y )= x \c d o t y \]} &
\b ig s t r u t \\\c lin e { l- l} \c lin e { 3 - 3 }
c l r4 & & c3 r 4 \b ig s tr u t\\\h lin e
\end{tabular}
We mentioned earlier that \m u ltiro w assumes a p column type by default unless you
use the star, in which case \m u ltiro w assumes the superior column definition. A p column
is by definition always typeset left-aligned and justified. You can change this behaviour by
redefining the \m u ltiro w setu p command. This makes horizontal centring within a r column
possible, as can be seen in column 3 in the following example.
33
P ackages
c l rO c2 rO c3 rO \usepackage{multirow,bigstrut}
02-03-8
\renewcommand\multirowsetup{\centering}
cl rl c2 r l
c2 r2 c3
\begin{tabular}{| 1 | r | r |} \h lin e
c l r2
c l rO & c2 rO & c3 rO\\ c l r l & c2 r l
c l r3 & \m u ltir o w {3 }[6 ]{l.5 cm }{c3 }\b ig stru t\\\c lin e{l-l}
f(x ,y ) = x-y
c l r4 c3 r4 c l r 2 & c 2 r 2 & \b ig s t r u t \\\c lin e { l- 2}
c l r3 &
\m ultirow{2}[4 ]{2cm}[0 . 8\abovedisplayskip]{%
\[f(x ,y )= x \c d o t y \ ] } &
\b ig s t r u t \\\c lin e { l- l} \c lin e { 3 - 3 }
c l r4 & & c3 r 4 \b ig s tr u t\\\h lin e
\end{tabular}
The column definition has no impact on the display of the equation as displayed formulae
are always centred horizontally.
2.3.2 bigstrut
The b ig s t r u t package just defines the \ b i g s t r u t command, and can be used on its own
without the \m u ltiro w package. As mentioned before (see on page 32), it defines a box of a
specific height and depth above and below the base line, but with width zero.
\ b i g s t r u t [p o s itio n ]
The optional argument lets you restrict the invisible box to height or depth only, by specifying
t or b. In these cases, the counting for the optional argument per row has to be adjusted
as well - single instead o f double counting. In the following example, the left table with
\b i g s t r u t was typeset without optional argument ( | ), the middle one with t and the
right one with b ( , j.1
\usepackage{multirow, b ig stru t}
\b eg in {ta b u la r}{| 1 |r |c |} \h lin e
11 & 21 & \m u ltir o w {3 }[6 ]{lc m }{3 }\b ig str u t\\\c lin e{l-l}
12 & 22& \b ig s t r u t \\\c lin e { l- 2}
13 & \multirow{2}[4]{lcm }{2} & \b ig s t r u t \\\c lin e { l- l} \c lin e { 3 - 3 }
14 & & 34 \b ig s tr u t \\\h lin e
\end{tabular}\quad
\begin{tabular}{@ {}|1 |r|c|@ {}}\h lin e
11 & 21 & \m u ltiro w {3 }[3 ]{lc m }{3 }\b ig str u t[t]\\\c lin e{l-l>
12 & 22& \b ig s tr u t[ t ] \ \ \ c l i n e { l - 2>
13 & \multirow{2}[2]{lcm }{2} & \b ig s tr u t[ t ] \\\c lin e { l- l} \c lin e { 3 - 3 >
14 & & 34 \b ig s t r u t [ t ] \\\h lin e
\end{tabular}\quad
1The “frames” inside the brackets here were created with \fbox and a \fboxsep of 0 pt to make the boxes visible
and show their position relative to the base line.
34
2.3 b ig d e lim , b i g s t r u t , m u lt ir o w
| 02-03-9 | 11 21 11 21 11 21
12 22 3 12 22 3 12 22 3
13 13 13
2 2 2
14 34 14 34 14 34
You can change the spacing by redefining \bigstrut or by changing the \bigstrut jo t
length, which is used to determine the box. The default for this length is O.Opt. By increasing
it by 2 pt, the tables would look like this:
02-03-10 | 11 21
11 21
12 22 3 12 22 3
13 13
2 2
14 34 14 34
In theory you can also use \multirow and \bigstrut within the eqnarray environment.
However, its not straightforward as KflpX already inserts a space of size \jot=3.0pt before
and after each line, which may lead to small vertical shifts as \multirow can’t use this length
for vertical centring. In fact it’s best to avoid using eqnarray anyway as there can be other
problems with the vertical spacing. Use the corresponding commands from the amsmath
package in preference. [56] am sm ath
i 1 1 1 \usepackage{bigstrut.multirow}
2 2 2 2 \begin{minipage}{ 2cm}
3 3 3 3 \begin{eqnarray*}
1&1\\2&2\\3&3\\
4 4
8 \multirow{5}*{8} &4\\ &5\\ &6\ \ &7\\ &8\ \
5 5 9&9\\10&10
6 8 6 \end{eqnarray*}
\en d{m in ip age}\setlen gth \b igstru tjot{\jot}
7 7 \begin{minipage}{ 2cm}
8 8 \begin{eqnarray*}
9 9 9 9 1&1\\2&2\\3&3\\
\m ultirow{5}[20]*{ 8} &4\\ &5\\ &6\ \ &7\\ &8\ \
10 10 10 10 9&9\\10&10
\end{eqnarray*}
\end{minipage}
35
Packages
2.3.3 bigdelim
The \b ig d e lim package is a special application of the \m u ltirow command and lets you
typeset brackets across multiple rows, for tables and matrices. Its syntax is:
b ra c k e t sy m b o l Any delimiter can be used as the bracket symbol. They are also allowed
for \ le ft and \right in math mode; in principle curly, round, angled, and
square brackets.
row s Number of rows enclosed by the left or right bracket.
sp a ce Determines the space between the bracket and the table or matrix; the column
width of the bracket is set to space.
The star assumes the column type of the enclosing tabular or array envi
ronment. The number of lines is not taken into account; the height of the
symbol is only one line.
te x t Optional text, inserted outside the bracket.
0 ... \usepackage{multirow,bigdelim}
02-03-12
1 then do...
\b e g in {ta b u la r}{lll}
2 then do... & 0 & \ld o ts\\
3 then do... \ld elim \{{6 }{1 .9 cm }[if $f(n)=$]
if f ( n ) =-
& 1 & then d o \ld o ts\\
4 then do...
5 then do... & 2 & then d o \ld o ts\\
& 3 & then d o \ld o ts\\
6 ...
& 4 & then d o \ld o ts\\
7 ... & 5 & then d o \ld o ts\\
& 6 & \ld o ts\\
& 7 &\ldots
\end{tabular}
0 ... \usepackage{multirow,bigdelim}
02-03-13 ]
1 then do.. \b e g in {ta b u la r}{lllr}
2 then do.. foo & 0 & \ld o ts &\\
3 then do.. \ld e lim {\{}{6 }{1 .9 cm }[if $f(n)=$]
if f i n ) =- & 1 & then do\ldots & \rd elim {]}{3 }{lcm }[fo o ]\\
4 then do..
5 then do.. & 2 & then do\ldots &\\
& 3 & then do\ldots & \ \
6 ... ]bar
& 4 & then do\ldots &\\
& 5 & then do\ldots & \rd elim {]}{3 }{* }[b a r]\\
& 6 &\ldots &\\
\end{tabular}
These two examples show how \b ig d e lim works; the brackets including the optional
text are simply part of a \m u ltiro w command and as such part of a normal table column.
36
2 .3 b ig d e lim , b ig s t r u t , m u ltiro w
Therefore the cells before and after the \ld e lim and \r d e lim commands must remain empty.
This is especially important for the first column, otherwise the corresponding content would
appear in those cells. You must bear in mind whether you need special columns for \ld e lim
and \r d e lim when defining the columns of a table; if there are going to be three normal
columns and a right bracket, you need to define four columns in the header of ta b u la r or
array.
The second part of the example illustrates the way round this problem is to specify a
negative value for the number of rows in the \m u ltirow command. This means that they are
counted from bottom to top, rather than from top to bottom. By reversing the order, all cells
that are affected by the \m u ltirow command are already coloured before \m u ltirow inserts
the text. In principle, negative numbers could always be used, but it can be confusing, so it
only makes sense to do this if you are colouring the table cells.
13 7
Packages
2.4 b lk array
The b lk array package by David Carlisle lets you form custom blocks (blockarray) within
a ta b u la r or array environment and provides commands to define cells that span more
than one column. The package never went past the experimental stage, but has some very
interesting features that are not provided by any other package.
m ath m ode The package requires the size of the math font to be specified; this means that before using
•5- the b lock array environment for the first time, math mode must have been active at least
once. In cases where this was not taken care of by other commands already - for example the
default ta b u la r environment - it has to be done manually by the user. You can do this in the
document preamble by just inserting the following code:
\usepackage{blkarray}
\AtBeginDocument{\setboxO\hbox{$ $}}
\en d {b lo ck a rra y }
We discussed the problems that can occur when using the \m ulticolum n command and
vertical lines in Section 2.1.1 on page 26. b lk array offers a special way of defining columns
that avoids problems. You simply prefix a line definition with & in the column definition,
and then use the \BAmulticolumn command, which cannot overwrite vertical lines. The
syntax o f \BAmulticolumn is identical to the usual \m ulticolum n command in standard
EflfeX. The following example shows you the difference between using the \m ulticolum n com
mand in a ta b u la r environment and using the \BAmulticolumn command in a b lockarray
environment:
11 \usepackage{blkarray}
21 1 31 ! 02-04-1 |
12 22 32 \begin{tabular}{c|c|c}
13 23 | 33 11 & 21 & 31\\
12 & \multicolumn{l}{r}{22} & 32\\
11 21 31 13 & 23 & 33
12 22 32 \end{tabular}
13 23 33
\begin{blockarray}{cIc&|c}
11 & 21 & 31\\
12 & \BAmulticolumn{l}{r}{22} & 32\\
13 & 23 & 33
\end{blockarray}
b lk array supports nested tables through a special b lo ck environment, though this has
to refer to an entire row of the superordinate table. The syntax is:
38
2.4 blkarray
\end{block * }
\end{blockarray}
21 | 31 \usepackage{blkarray}
02-04-2 11
12 23--32 \begin{blockarray}{c|c|c}
13 23--33 11 & 21 & 31\\
14 1 24 1 34 \begin{block}{>{\itshape}c\BAmulticolumn{2}{>{\itshape}r}}
12 & 23—32\\ 13 & 23—33\\
\end{block}
14 & 24 & 34
\end{blockarray}
The above example showed how to use the b lock environment, but its advantage only
becomes apparent when using the extended column types that let you insert delimiters at
arbitrary positions, as in the following example. This can only be done in math mode though; ^ m ath m ode
you have to use \ t e x t from the amsmath package or \mbox from standard to enter text.
11 21 31 41 \usepackage{blkarray}
02-04-3
12 22 32) 42
\begin{blockarray}{cccc}
13 23 33J 43
11 & 21 & 31 & 41\\
14 24 34 44 \begin{block}{c | cc \} c}
12 & 22 & 32 & 42 \\ 13 & 23 & 33 & 43\\
\end{block}
14 & 24 & 34 & 44
\end{blockarray}
The starred version of the b lo ck environment adopts the superordinate delimiter defini
tion, which is then not interrupted by the b lo ck environment anymore.
The blockarray and block environment are particularly useful for numbering individual
rows or columns of a matrix. In contrast to the normal \borderm atrix (see [56]), you can
apply simple font changes for the numbers.
39
Packages
1 2 3 4 \usepackage{blkarray}
2 /22 32 42\ 02-04-5 j
3 23 33 43 \begin{blockarray}{>{\scriptsize}cccc}
4 \24
\begin{block}{*{4}{>{\scriptsize}c}}
34 44/
1 & 2 & 3 & 4 \\
\end{block} \begin{block}{>{\scriptsize}c(ccc)}
2 & 22 & 32 & 42\\ 3 & 23 & 33 & 43\\
4 & 24 & 34 & 44\\
\end{block}
\end{blockarray}
The following additional commands make marking blocks with text easier:
40
2.4 blkarray
\BA noalign * can be used to insert arbitrary text that spans all columns. It corresponds
to a \m u lt icolumn command defining a \parbox that spans the whole width of the specified
table. Delimiters are only not interrupted with the starred version, similar to block*.
In the following example, the ! operator in the definition of the table is used for formatting
as well as making space. \BAenum! { . \quad} means that the value of the counter BAenumi
is printed and the dot with space \quad is used as the next “column separator”. Within a
table, all cells are local; any changes that should affect subsequent rows must be done globally.
In the example, \gdef\theBAenumi{\Roman{BAenumi}} sets the counter output to Roman
numerals.
\usepackage{blkarray,ragged2e}
\begin{blockarray}{\BAenum! { .\quad}cc\Right{\}}{\texttt{block 1}}}
ccc & cc \\
c & ccccccccc \ \
\BAnoalign*{\texttt{\textbackslash BAnoalign*} typesets the text exactly in the
width of the tab le.}
\begin{block}{\BAenum! { .\quad}(rr\Right{\}}
{\parbox{3cm}{block 2, with a nested \texttt{block*}}}}
\phantom{XX}rrr & rr \ \
rrr & r \ \ % next row empty "field" for BAenum
\begin{block*}{!{\quad}ll}
& 11 & ll\phantom{XX}\\
& 1 & 1\ \
\end{block*}
r & r \ \ \end{block}
ccc \ \
\begin{block}{\BAenum! { .\quad}>{\bfseries}l \{c\R ight{\}}{\texttt{b lock 3}}}
\gdef\theBAenumi{\Roman{BAenumi}}
LLL & \BAmultirow{50pt}{\Centering All columns in one block.} \ \
LL & \\
L &\\
\end{block}
\begin{block}{\BAenum \{l\}l\R ig h t{\}}{\tex ttt{b lo c k 4}}}
11 & 1 \\ \BAnoalign{In contrast to \texttt{\textbackslash BAnoalign*},
\texttt{\textbackslash BAnoalign} interrupts a ll delimiters in the current block.}
1 & 111 \ \
\end{block}
c &c
\end{blockarray}
41
Packages
1. ccc cc
02-04-7
2. c ccccccccc
\BAnoa lig n * typesets the text -block 1
exactly in the width of the table.
3. frr rr
4. rr r
11 11 block 2, with
1 1 nested b lock *
7. \r
8. ccc j b lo c k 1
9. LLL f All columns
X. LL i in one -block 3
XI. L L block. .
Kll
11 I !} 3b lo c k 4
In contrast to \B A noalign*
\BAnoa l i g n interrupts all de
limiters in the current block.
XIII 1 I 4 b lo c k 4
XIV. b lo c k 1
2 .4.1 Footnotes
In standard filpX you can’t typeset footnotes in a table, but this is possible with blkarray.
There are two variants: specifying \B A ta b le n o testru e lets you insert footnotes within the
respective current block; specifying \B A ta b le n o testru e puts the footnotes at the bottom of
the page as usual. The following two examples illustrate the two options:
\usepackage{blkarray}
\BAtablenotestrue
\begin{blockarray}{|c||c|}
I\footnotetext[\textsc{sourceA:} ]{Chicago Manual of S tyle.}
& II\footnote{Note on II. This is a particularly long footnote to demonstrate a lin e break
in the fo o tn ote.}\\
\begin{blockarray}{(11)}
\footnotetext[\textsc{sourceB:} ] {Chicago Manual of S tyle.}
\footnotetext[\textsc{noteA:}]{The statement above is incorrect.}
le f t column—1 & l e f t —2 \ \
l e f t —3\footnote{Footnote on le f t - 3 .} & l e f t —4 \\
\end{blockarray} & \begin{blockarray}{(ll)}
\footn otetext[\textsc{sourceC:} ] {Chicago Manual of S tyle.}
\footnotetext[\textsc{noteB:}]{The statement above is incorrect.}
right column—1 & right—2 \ \
right—3\footnote{Footnote on righ t-3.} & right—4 \\
\end{blockarray}\\
42
2.4 blkarray
02-04-8 I II*
/ left column - 1 le ft- 2\
( right column - 1 right- 2\
\left-3* left—4 J
frig h t-3* right-4/
sourceB: Chicago Manual of
sourceC: Chicago Manual of Style.
Style.
noteB: The statement above is
noteA: The statement above is
incorrect.
incorrect.
* Footnote on right-3.
* Footnote on left-3.
m+ IV
2 .4 .2 Lines
Vertical lines are created similarly to standard ^IfeX; you can also use the extensions known
from the h h lin e package (cf. Section 2.10 on page 64). However, you can’t use \ h l i n e for
horizontal lines, but b lk array provides its own commands instead. There are also two further
commands for improving vertical spacing as well.
The following notation applies to vertical and horizontal lines; it is an extension of the
notation from the h h lin e package.
43
Packages
\usepackage{blkarray} ,--------- .
0 1 2 3 4 5 [ 02-04-loJ
0 1 2 3 4 5 \b e g in { b lo c k a r r a y } { ||c |I c |c c ||c c ||}
0 1 2 3 4 5
\BAhhline{|t:=:t :=|==#==:t | }
0 & 1 & 2 & 3 & 4 & 5\\\BAhline
0 1 2 3 4 5
0 & 1 & 2 & 3 & 4 & 5\\\BAhline\BAhline
0 1 2 3 4 5 0 & 1 & 2 & 3 & 4 & 5 \\\B A h h lin e { ||-||-.. | | .-}
0 & 1 & 2 & 3 & 4 & 5 \ \ \ B A h h l i n e { = : ::"=}
0 & 1 & 2 & 3 & 4 & 5\\\BAhhline{| b:=:b b | }
\end{blockarray}
The individual lines o f this example are explained in depth below; it can be difficult to
understand especially the corners and intersections.
| | c | | c | cc | | cc | | t> The default vertical Lines.
\B A h h lin e { |t := :t := | ==#==:t | }
11 : > A vertical line ( | ), the upper half of a double horizontal (t), and a vertical
line (:) which does not intersect horizontal lines: In conjunction with the
column definition this produces: [j
= > A default double horizontal line: , together with the previous lines this
produces: 11
: t : > A vertical (:), upper half of a horizontal one (t), and again a vertical line (:),
where these do not intersect the horizontal ones: Together with the previous
lines this produces: || ||
==#== > Two columns with double lines (==), a double line between two
vertical ones (#), and again two columns with double horizontal lines:
|| Together with the previous lines this produces: || || | ||
: 1 1 > A vertical fine (:), the upper half of a double horizontal one (t), and a vertical
line (t^ which intersects horizontal lines. The whole is the mirrored start of the
table: Together with the previous lines this produces:
44
2.4 blkarray
\B A hline > Creates a line across the whole width of the table:
\B A h lin e\B A h lin e > Creates a double line across the whole width of the table:
. . | | . - > Two dashed lines across the width of the column each ( ..) , followed
by two vertical lines ( | | ), a dashed line (.), and a single solid line (-), of column
width each: ___ Together with the previous lines this produces:
45
Packages
\usepackage{blkarray}
Text \begin{blockarray}[t ] { | c | } 1 \\2 \\3 \end{blockarray} text
\begin{blockarray} [c] { | c | } 1 \\2 \\3 \end{blockarray} text
\begin{blockarray}[b]{ | c | } 1 \\2 \\3 \end{blockarray} text
1 02-04-11
2
3
Text text text text
1
2
3
2.5 booktabs
The booktabs package by Simon Fear certainly belongs to the “highly recommended” category
and should always be used. It primarily refers to typographical conventions to be kept in
mind when creating tables, which are valid in general and have already been mentioned in
Chapter 1 on page 3. These specifications are applied by booktabs, especially for vertical
lines; they are not supported by the package in any special way. An example from [34, page
73] is given as starting point for a typographically bad table.
Of course the original point o f this example was to discuss applications of commands
and not typographical questions. Nevertheless this table is suitable as a starting point for a
discussion of good and less good options for a table layout. For comparison, let us take a look
at the same table without vertical lines.
46
2.5 booktabs
The text becomes easier to see, which is always a worthwhile aim. We can also omit
some of the horizontal lines, and use the \m ultirow or \ra iseb o x command to shift the one
common entry “filled” and centre it vertically.
The booktabs package offers further to improve this table. In particular, it lets you
employ different line widths more easily, several commands defined:
\to p ru le [width]
\m idrule [width]
\cm idrule [width] (horizontal trim) {from-to }
\morecmidrules
\bottom rule [width]
\add linespace [space]
\s p e c ia lr u le{width}{ space above}{space below}
The default values for the widths of the individual lines, with their associated lengths and
space above/below and for \cm idrule with the optional horizontal trim are summarized in
Table 2 .2 .
Table 2.2: Summary of the relevant lengths and their assignment to commands; the column c u rr e n t
gives the values for the class used here.
47
P a ck a g e s
\u s e p a c k a g e { e u ro sy m , a r r a y , m u ltir o w , b o o k ta b s}
m e ats ¡02-05-4
\u s e p a c k a g e { x c o lo r,b o o k ta b s }
\n e w le n g th { \b a s is } \s e tle n g th { \b a s is } { 1 0 c m } \n e w le n g th { \b a rle n g th }
\newcom m and*{\Bar}[1]{%
\s e tle n g t h { \ b a r l e n g t h } { 0 .0 1 \ b a s i s } \ s e t l e n g t h { \ b a r l e n g t h } { # l \ b a r l e n g t h } %
\ t e x t c o l o r { b l a c k !4 0 } { \ r u l e { \ b a r l e n g t h } { l . 5ex}} # 1 \ , \%}
\b e g in { ta b u la r} { @ { } ll@ { } } \to p ru le
\m u ltic o lu m n { 2 } { c } { G e n e ra l o p in io n on s o c i a l d i f f e r e n c e s i n Germany (n=509)}
\\\m id ru le
\B ar{ 5 7 } & v e ry la r g e \ \ \B ar{ 2 3 } & l a r g e \ \
\B ar{12} & l e s s l a r g e \ \ \B a r{ 8 } & s m a ll\\\b o tto m ru le
\e n d { ta b u la r }
57% v e ry large
23% large
12% less large
8% sm all
48
2.5 booktabs
You can see various differences in how the layout differs between the two tables. The
first two rows show that neighbouring \cm id ru le commands that don’t use the horizontal
alignment notation form a series of joined lines in the table. If on the other hand one or more
of the optional trim parameters 1 or r are used, the partial line is shortened by the value
\cm idrulekern. \cm id ru le doesn’t distinguish between cells in the centre of the table and
at the edge, which is why the display in the second, left-/right-aligned table is different to the
first table.
\cm id ru lek ern defaults to 0.5 em and can be changed at any time. Alternatively, a length
can be specified explicitly as a parameter to 1 and r; for example r { \ t a b c o l s e p } shortens
by \ta b c o ls e p . Negative values extend the line to the left or right.
The following example is a rather complex application of the booktabs commands. By
setting @ {\kern-30pt} (negative column spacing) in the head of the table between the first
and second column, we achieve an “attraction” of the following column. It is getting nearer to
the first column.
\usepackage{eurosym, array,booktabs}
\begin{tabular}{@{}>{\raggedright}p{4.5cm}@{\kern-30pt}*{6}{>{\small}r}@{}}\toprule
\ t e x t it {alternative 1} & time of & year\\[-2pt]
& investment & 2006 & 2007 & 2008 & 2009 & 2010 \ \
49
Packages
introductory payments 0 0 0 0 0 0
current personnel cost 0 7.187 7.187 7.187 7.187 7.187
current cost for 0 13.572 13.572 13.572 13.572 13.572
system maintenance
total payments for the 0 20.759 20.759 20.759 20.759 20.759
investment
(ail amounts in € )
As with the default KEl£X \ c l i n e command, calling \cm id ru le several times consecutively
does not draw multiple lines. However, inserting the \m orecm idrules command between
two identical \cm id ru le commands gets round this; repeating the sequence creates more
lines. The line spacing is specified by \d o u b le r u le se p = 2.0pt and can be changed as usual
through a length command.
The \ s p e c i a l r u l e command is helpful for colour tables, as it lets you create lines that
colour tables don’t have any vertical space before or after them and therefore can be placed immediately
after coloured blocks. This also makes using vertical lines possible, which would otherwise
be interrupted before and after horizontal lines because of the additional vertical spacing
associated with booktabs line types.
50
2.5 b o o ktab s
\u s e p a c k a g e { a r r a y , b o o k ta b s}
\u s e p a c k a g e [ ta b le ] { x c o lo r } \d e f i n e c o l o r { c L ig h t R e d } { r g b } { l ,.7 0 ,.7 0 }
\d e fin e c o lo r{ c L ig h tY e llo w } { r g b } { . 9 0 , . 8 5 , . 5 5 } \d e f in e c o lo r{ c L ig h tG ra y } { rg b } { . 9 0 ,. 9 0 ,. 9 0 }
\d e fin eco lo r{ cM e d iu m G ra y } { rg b } { .7 0 ,. 7 0 ,. 7 0 } \d e fin e c o lo r{ c D a rk G r a y } { r g b } { .5 0 ,.6 0 ,.7 0 }
\n e w c o m m a n d \th ic k c [l][ 0 . 5 p t ] { \ v r u l e w id th #1}
\n e w c o m m a n d \m y M id ru le { \sp e c ia lru le { 0 . 6 p t} { 0 p t} { 0 p t}}
\re n e w c o m m a n d { \a r ra y s tr e tc h } { l.35}
\ b e g i n { t a b u l a r } { |1 |c |c |m { 4 c r a } |} \s p e c i a lr u le { 2 p t} { 5 p t} { 0 p t}
\m u ltic o lu m n { 4 } { ! { \ t h i c k c [2 p t] }c ! { \ t h i c k c [2 p t ]}}{%
\ l a r g e \te x tb f { B o o t L oader H eader T a b l e } } \\ \s p e c ia lr u l e { 2 p t} { 0 p t} { 0 p t}
\ra u ltic o lu m n { 4 } { ! { \ t h i c k c [ l p t ] } > { \c o lu m n c o lo r{ c L ig h tY e llo w } } r! { \ t h i c k c [ l p t ]}}{%
\ l a r g e V e rsio n In d e p e n d e n t } \ \ \ s p e c i a l r u l e { l p t } { 0 p t } { 0 p t }
\m u ltic o lu m n { l} { !{ \th ic k c [ lp t]} > { \c o lu m n c o lo r{ c D a rk G ra y } } c |} { E n try }
& \m u ltic o lu m n { l} { |> { \c o lu ra n c o lo r{ c D a rk G ra y } } c |} { L o c a tio n }
& \m u ltic o lu m n { l} { |> { \c o lu ra n c o lo r{ c D a rk G ra y } } c |} { S iz e }
& \m u ltic o lu m n { l} { |> { \c o lu ra n c o lo r{ c D a rk G ra y } } c ! { \th ic k c [lp t]} } { C o m m e n ts} \ \
\s p e c ia lru le { lp t} { 0 p t} { 0 p t}
\rowcolor{cLightGray} JmpTrap & 0 & Word & OEBFEh (JMP \$)\\\myMidrule
\rowcolor{cMediuraGray} MagicNuraber & 2 & Word & 0AA55h \\\myMidrule
\rowcolor{cLightGray} Name & 4 & 4 B ytes & ’ EBLH’ \\\myMidrule
\rowcolor{cMediumGray} V ersion & 8 & Word & V ersion of BLH table\\\myMidrule
\rowcolor{cLightGray} S iz e & 10 & Byte & S iz e of BLH ta b le \\\myMidrule
\rowcolor{cMediumGray}SizeVDT & 11 & Byte & S iz e of fo llo w in g v ersio n
dependent table\\\myM idrule
\m u ltic o lu m n { 4 } { ! { \ t h i c k c [lp t] } > { \c o lu m n c o lo r{ c L ig h tY e llo w } } r ! { \ t h i c k c [ l p t ]}}{%
\ l a r g e V e rsio n 1 .x } \\\m y M id ru le
\ro w c o lo r{ c L ig h tG ra y } Empty & 0 & 0 & No D ata f o r l.x \\\m y M id r u le
\m u ltic o lu m n { 4 } { ! { \ t h i c k c [ 2 p t ] } c ! { \ t h i c k c [ 2 p t ]}}{%
\ l a r g e \te x tb f { E n d o f Boot L oader H eader T a b l e } } \ \ [ - 2 p t ] \ b o t t o m r u l e [ 2 p t ]
\e n d { ta b u la r }
51
P a ck a g e s
\m id ru le (h o rizo n ta l trim ) [w id th ]
T h e o p tio n a l a r g u m e n t fo r th e h o r iz o n ta l tr im is n o w p o s s ib le fo r all c o m m a n d s . T h is is
im p o r ta n t to k n o w b e c a u s e fo r e x a m p le in th e fo llo w in g co d e, th e \ r e l a x a f te r th e la s t
\ m i d r u l e is re q u ire d . O th e rw is e th e p a r e n th e s is in th e fo llo w in g lin e w o u ld c a u se a n e r ro r
m e ssa g e - \ m i d r u l e w o u ld r e g a rd it as th e s ta r t o f a n o p tio n a l a rg u m e n t.
\u s e p a c k a g e { lo n g ta b le } \u se p a c k a g e { b o o k ta b s}
\b e g in { lo n g tab le } { @ { } lrc c c c r@ { } }
\c ap tio n { S u m m a ry . } \ \ \s p e c i a l r u l e { l p t } { 5 p t } { 5 p t }
\rau ltico lu ran { l} { l} { c o ra p o u n d } & \r a u ltic o lu ra n { l} { c } { L it.}
& \m ultico lu m n { l}{ c }{ X -R ay } & \ra u ltic o lu ra n { l} { c } { L sm .}
& \m u ltic o lu m n { l} { c } { $ A{ 1 2 5 } $ T e -s h ift}
& \m u ltic o lu m n { l} { c } { $ A{ 1 9 } $ F -s h ift} \ \ \ m i d r u l e
\ a d d l i n e s p a c e [ 0 . 3em]
\e n d h e a d
%
\ a d d l i n e s p a c e [ 0 . 5em]
\e n d f o o t
%
\b o tto m r u le
\e n d la s tfo o t
%
(CF$_3$C$_6$F$_4$) $_2$Te$_2$ &— &— &— &— &— \ \ \ m i d r u l e
Ph$_2$Te &— &— &— &729&— \ \ \ m i d r u l e \ r e l a x
(C$_6$F$_4$)$_2$Te$_2$ &— & ja& — &762& $ -1 0 8 ,0 $ ; $ -1 5 2 ,0 $
\e n d { lo n g ta b le }
T a b le 1 : S u m m a ry . i------------
' | 02-05-11
P h 2T e - - - 729 -
( C e F 4 ) 2T e 2 ja 762 - 1 0 8 , 0 ; - 1 5 2 ,0
52
2.6 c e lls p a c e
2.6 c e lls p a c e
The c e lls p a c e package by Josselin Noirel automatically loads the i f then, array, and c a lc
packages and provides better line spacing for displayed equations in tables and matrices.
Otherwise, especially when using fractions, roots, or exponents in ta b u la r environments,
problems can occur such as the one in the following example:
\begin{tabular}{c}\hline
/(* > = $ f(x)=\frac{\sq rt{xA2-l}}{xA2+l}$ \\\h lin e
/(* > = $ f(x)=\frac{\sq rt{xA2-l}}{xA2+\frac{l}{xA2}}$\\\h lin e
\end{tabular}
In general, you could just use the \a r r a y s t r e tc h command to stretch the table. But
this doesn’t always lead to equal spacing across different tables, because the value for
\a r r a y s t r e t c h has to be adjusted. Furthermore a lot o f experience is required to come
up with sensible values, which nevertheless still do not always yield the expected solution.
\renewcommand\arraystretch{2.5}
02-06-2 i
— Vx2-1 \begin{tabular}{c}\hline
/(* ) - $ f(x)=\frac{\sq rt{xA2-l}}{xA2+l}$ \\\h lin e
$ f(x)=\frac{\sq rt{xA2 -l}}{x A2+\frac{l}{xA2 }}$\\\h lin e
f(x ) = \end{tabular}
J(
The c e lls p a c e package tries to determine sensible spacings above and below by calculat
ing the required height of the cell. To achieve this, a new S column type was defined through
the \newcolumntype command. It takes the actual type as a parameter; possible values are
1, c, r, p, m, and b. For the simple types, no parentheses are necessary and the following
character is automatically assumed to be the argument, i.e. SI and S{1} are identical.
\usepackage{cellspace}
02-06-3 /<*> -
\begin{tabular}{Sc}\hline
/<*> - jXg+72-
?
$ f(x)=\frac{\sqrt{xA2-l}}{xA2+l}$ \\\h lin e
$ f(x)=\frac{\sq rt{xA2-l}}{xA2+\frac{l}{xA2}}S\\\hlin e
\end{tabular}
The space above and below a tabular cell is controlled by the package-defined lengths
\c e lls p a c e t o p lim it = lp t and \c e lls p a c e b o tt o m lim it= l pt. These default values are
quite small, so we recommende you change them. You can do this by using either \s e t le n g t h
or \a d d to le n g th .
\usepackage{cellspace}\addtolength\cellspacetoplimit{3pt}
02-06-4 fix) = ^ \addtolength\cellspacebottomlimit{3pt}
\begin{tabular}{Sc}\hline
M $ f(x)=\frac{\sq rt{xA2 -l}}{xA2+l}$ \\\h lin e
$ f(x)=\frac{\sq rt{xA2 -l}}{xA2+\frac{l}{xA2}}$\\\h lin e
\end{tabular}
53
P a ck a g e s
c e l l s p a c e le ts y o u a d d f u r th e r c o lu m n ty p e s w ith th e \ a d d p a r a g r a p h c o l u m n t y p e s
c o m m a n d . T h is m o s tly r e fe rs to c u s to m ty p e s d e fin e d b y th e u se r, w h ic h a re n o t k n o w n
to c e l l s p a c e o th e rw is e . A ty p ic a l c a se is th e a d d itio n o f a X c o lu m n ty p e w h e n u s in g th e
p a c k a g e t a b u l a r x (cf. S e c tio n 2.18 o n p a g e 87).
2.7 c t a b le
T h e c t a b l e p a c k a g e b y W y b o D e k k e r c o m b in e s th e f u n c tio n a lity o f th e a r r a y , t a b u l a r x ,
a n d b o o k t a b s p ac k ag e s. A d d itio n a lly , th e r o t a t i n g , x s p a c e , c o l o r , a n d x k e y v a l p a c k a g e s
a re lo ad ed , c t a b l e d e fin e s th e c o m m a n d o f th e sa m e n a m e , w h ic h is u s e d to c h a n g e th e
la y o u t o f a table, c o n tro lle d b y k ey w o rd s. It also p ro v id e s a d d itio n a l co m m a n d s fo r fo o tn o te s
a n d lines.
54
2.7 ct able
name description
ca p tio n Table caption (above or below); m ust be enclosed in parentheses if the text
contains a comma or an equals sign.
cap Alternative short form for the list of tables ( \ l i s t o f t a b l e s ) .
ca p tio n sk ip Space between caption and table, default is 2ex.
mincapwidth Minimum width of the table caption. Useful for very narrow tables; footnotes
are always typeset with the “caption” width.
pos Float position, default is tbp.
la b e l Requires a table caption. Corresponds to the \ l a b e l command.
width If a width is specified, the ta b u la rx environment is used to typeset the
table; therefore the X column type is used for at least one column.
maxwidth If the table does not extend to the maximum width, each X column is con
verted to a normal 1 column.
ce n ter Centres the table on the current line (default).
le ft Left-aligns the table on the current line.
r ig h t Right-aligns the table on the current line.
fig u r e A fig u r e floating environment is used for the table instead of the ta b le
environment.
botcap Places the caption at the bottom.
sidew ays Rotates the table counter-clockwise (oneside) or clockwise (twoside) by 90
degrees and places it on its own page. The pos option must not be used in
this case.
nosuper Typesets the footnote symbols not in “superscript” mode.
n otesp ar Typesets all footnote texts consecutively in one paragraph.
s ta r Uses the starred versions of the floating environments; this only makes sense
in \twocolumn mode to have the table span both columns.
fram erule The table is alw ays fitted with a frame; the line width is Opt by default
though - it is invisible unless another value is specified.
framesep Corresponds to \fb o x se p and determines the spacing between frame and
table; default is Opt.
fram efg Expects three values separated by spaces (RGB), each from the range [0 ... 1]
for the frame colour; default is 0 0 0for black.
framebg Expects three values separated by spaces (RGB), each from the range [0 ... 1]
for the background colour of the frame; default is 1 1 1 for white.
Footnotes are always placed underneath the table and their width (mark and text) depends
on the table caption. If there is no caption, the width of the table itself is taken. A separating
line is drawn when using the standard \ f o o tn o te te x t command. The counting is done in the
usual m inipage form; i.e. \tm ark is to be replaced by the “real” letter and \f o o t n o t e t e x t
the corresponding number ( f - 6). If \tm ark and \t n o t e are used without optional argument,
the label a is assumed automatically. The footnote counter is not incremented automatically.
55
P a ck a g e s
JS O U R C E :
IP \u s e p a c k a g e { c ta b le }
; 02-07-2 l
left c o l-1 rig h t co l-1 \ c t a b l e [ n o t e s p a r = t r u e ] { |c [ | c | }{%
le ft-2 rig h t-2 \ t n o t e [ \ t e x t s c { s o u r c e : } ] { C h i c a g o Manual o f S t y l e . }%
le ft-3 r ig h t-3 * \tn o te { N o te on I I . T h is i s a v e ry lo n g f o o tn o te to
le ft-4 r ig h t- 4 d e m o n s tra te th e l i n e b re a k i n a f o o t n o t e . }%
IIP IV / \tn o t e [ b ] { F o o tn o te on l e f t - 3 . }%
source:Chicago Manual of Style. \tn o t e [ * ] { F o o tn o te on rig h t-3 } %
“ Note on II. This is a very long \tn o t e [ c ] { F o o t n o t e on I II .} %
footnote to demonstrate the line \f o o tn o te te x t [ 6 ] { A n o th e r ‘ ‘r e a l ’ ’ f o o tn o te on I II .} %
break in a footnote. bFootnote on
left-3. Footnote on right-3
}{%
c Footnote on III. I \ t m a r k [ \ t e x t s c { s o u r c e : }] & I I \ t m a r k \ \
l e f t c o l—1 &r i g h t c o l— 1 \\
/Another “real” footnote on l e f t —2 &r i g h t — 2 \\
III. l e f t — 3 \tm a rk [b ]& r i g h t — 3 \tm a rk [* ] \ \
l e f t —4 &r i g h t — 4 \\
I II\tm a rk [c ] & I V \tm a rk [ f] }
\u s e p a c k a g e { c ta b le }
JSOURCE: IP
left c o lu m n - 1 rig h t c o lu m n - 1 \ c t a b l e [ fra m e r u le = 0 . 5 p t , fra m e s e p = 5 p t,
le ft-2 rig h t- 2 fram eb g = 0 .8 0 .5 0 . 6 ] {@{}c||c@{}}{%
le ft— rig h t-3 * \ t n o t e [ \ t e x t s c { s o u r c e : } ] { C h i c a g o Manual o f S t y l e . }%
\tn o te { N o te on I I . T h is i s a v e ry lo n g f o o tn o te
le ft-4 rig h t- 4
t o d e m o n s tra te th e l i n e b re a k
IIP IV /
i n th e f o o t n o t e . }%
source:Chicago Manual of Style. \ t n o t e [ b ] { F o o tn o te on l e f t - 3 . }%
“ Note on II. This is a very long \tn o t e [ * ] { F o o tn o te on rig h t-3 } %
footnote to demonstrate the line \t n o t e [ c ] { F o o t n o t e on I II .} %
break in the footnote.
\ f o o t n o t e t e x t [ 6 ] {A nother ‘ ‘r e a l ’ ’ f o o tn o te on I II .} %
bFootnote on left-3.
Footnote on right-3 }{%
cFootnote on III. I\tm a rk [ \te x ts c { s o u r c e :} ] & I I \t m a r k \\
l e f t colum n— 1 & r i g h t colum n— 1 \ \
l e f t —2 &r i g h t — 2 \\
{Another “real” footnote on III. l e f t — 3 \tm ark [b ]& r i g h t — 3 \tm a rk [* ] \ \
l e f t —4 &r i g h t — 4 \\
I II\tm a rk [c ] & I V \tm a rk [f]
I n s te a d o f th e s ta n d a r d lin e b r e a k c o m m a n d s lik e \ \ o r \ t a b u l a r n e w l i n e , c t a b l e p r o
v id e s a lte r n a tiv e v a r ia n ts lik e \NN ( n o rm a l n e w lin e ); th e y a re lis te d o n p a g e 54. All lin e
56
2.7 c t a b le
commands must be within the table block. For lines, the \FL (first line), \ML (middle line),
\ FL<£\ and \LL (last line) commands refer to the booktabs versions, \to p r u le , \m id ru le, and
\b otto m ru le, with the option of specifying the width of the line.
\usepackage{ctable}
Here is some pretty useless text before the following table, which w ill appear
on i t s own page because of the \texttt{sideways} option.
\cta b le[sideways,maxwidth=\textheight,
caption=A table with \texttt{\textbackslash ctable}. ]{@{}>{\ttfamily}l X@{}
}{\tnote[*]{A demonstration with \texttt{\textbackslash cta b le}.}}%
{\FL% FirstLine with default width
sideways\tmark[*] & Rotates the table counter-clockwise (oneside) or clockwise
(twoside) by 90 degrees and places i t on it s own table. The \texttt{p os}
option must not be used in th is case.\ML[0.1pt]% MidLine
star & Uses the starred version as floating environment; this only makes
sense in \texttt{\textbackslash twocolumn} mode to have the table span both
columns.\LL[0 .5pt]% LastLine
}% end of the table argument
02-07-4 |
The maxwidth option is helpful when tables are generated by external scripts or programs
where the content of the table is not necessarily known before. The general use of a X column
in conjunction with the ta b u la r x package can be irritating if the specified width of the table
(mandatory) is larger than necessary. By specifying a maximum width through maxwidth, a X
column can be converted automatically to a 1 column if the table as a whole is narrower than
the maximum width.
57
Packages
le ft c e n tr e d r ig h t \usepackage{ctable} ,-------
L02-07'5
\ c r \ctable{@{}lcr@{}}{}{%
left c e n te r rig h t \emph{left} & \emph{centred}
& \emph{right}\\\hline
1 &c & r \\
le f t & center & right }
\ctable[left]{@{}lcr@{}}{}{%
le ft c e n tr e d r ig h t
\emph{left} & \emph{centred}
1 c r & \emph{right}\\\hline
left c e n te r rig h t 1 &c & r \\
le f t & center & right }
\ctable[right]{@{}lcr@{}}{}{%
\emph{left} & \emph{centred}
& \emph{right}\\\hline
le ft c e n tr e d r ig h t 1 &c & r \\
1 c r le f t & center & right }
left c e n te r rig h t
2.8 d a ta to o l
T h e d a t a t o o l p a c k a g e b y N ic o la T a lb o t su p e rs e d e s th e o ld c s v t o o l s p a c k a g e b y th e sam e
a u th o r, d a t a t o o l is a c tu a lly a c o lle c tio n o f se v e ra l p a c k a g e s, all o f w h ic h re a d e x te rn a l files
a n d d is p la y th e m in so m e fo r m o r a n o th e r - a s ta b le , p ie c h a rt, o r fu n c tio n g ra p h . A ll d a ta
sets a re re a d lin e b y lin e a n d m u s t h a v e a c o n s is te n t se p a ra to r, w h ic h c a n be sp ec ifie d b y th e
user.
In th e s ta n d a r d case, th e e x te r n a l file c o n ta in s a c o m m a -s e p a ra te d list. A d d itio n a lly ,
in d iv id u a l e n tr ie s c a n b e e n c lo s e d in q u o te s i f th e y c o n ta in a c o m m a th e m s e lv e s , a s c a n b e
s e e n in th e s e c o n d lin e o f th e fo llo w in g d a ta set. T h e firs t lin e o f a d a ta s e t m u s t c o n ta in
id e n tifie rs fo r th e in d iv id u a l c o lu m n s, w h ic h m a y th e n b e re fe re n c e d w ith \D T L fo r e a c h .
\D T L lo a d d b { lis t o f d a ta } { f il e n a m e }
\D T L f o r e a c h * [c o n d itio n ] { lis t o f d a ta } { id e n tif ie r lis t} { ta b l e row}
58
2.8 datatool
The starred version works faster, so is better for larger data sets, but it provides the
data read only, allowing no changes to the individual entries. The first required argument
of \DTLforeach expects the logical file name, the second one specifies the assignment of
individual columns to macro names, and the last argument specifies the formatting of an
individual row in the table. The double backslash can be inserted before or after the new
row. We can number the individual rows easily with the internal counter DTLrowi; it can be
queried in the usual way and also used for labels. This allows it to reference the individual
rows of the table.
You can then reference items in the usual way with the \ r e f command. You must
add the label before the line break \ \ to keep the reference to the internal command
\ r e f stepcounterDTLrowi; all counters are set at the beginning of the argument table row
(cf. syntax of the command). The counters are assigned to the elements of identifier list and
similar to the normal list denoted with consecutive lowercase Roman numerals. The first one
is DTLrowi, the second one DTLrowii, etc.
The optional argument of \DTLforeach can be used to specify a condition for filtering entries;
for example each person whose surname starts with “W”. The \DTLisopenbetween command
59
P a ck a g e s
defines the region for which the list of data is “open”; the start is inclusive and the end is
exclusive.
The \D TLifoddrow command helps you create a “double” table, by inserting a line break
\ \ or a column separator & depending on the row. The order is important here; first, the
missing line break for the header must be created. The counting of rows is done the same
way as the data list; the first line contains the column identifiers (cf. the data set on page 58).
\u s e p a c k a g e { d a ta to o l} \D T L lo a d d b { lis t} { d a ta 0 .c s v }
\b e g in { ta b u la r} { c llc @ { \q q u a d } c llc }
\emph{no} & \em ph{given name} & \em ph{surnam e} & \em ph{age} &
\emph{no} & \em ph{given name} & \em ph{surnam e} & \em ph{age}
\D T L fo reach { list} { \g iv e n N am e = g iv en N a m e, \su rn am e= su rn am e, \age=age}%
{\D T L ifoddrow {\\}{& } \th eD T L ro w i. & \givenN am e & \su rn am e & \a g e }
\e n d { ta b u la r }
Use \D T L iff ir s tr o w for example to insert a horizontal line after the first row.
60
2.8 datatool
Another interesting feature of the d atatool package is its ability to sort the data rows.
The optional specification of the sorting order is only interesting in the case where the actual
sorting criteria fails because there is no corresponding entry in the column of the list of data,
similar to a null entry in a SQL database. In the following example, we are sorting primarily
on age in descending order; the optional specification of descending sorts in descending order
while ascending sorts in the default ascending order, surname is given as an alternative sorting
order to the age sorting criteria.
When using \DTLsort to sort, whether text is upper- or lowercase does matter. However,
in the starred version all strings are converted to lowercase before sorting, so then case doesn’t
matter.
61
Packages
The functionality of the d a ta to o l package is much larger than what we can present here.
You can find many further examples in the documentation of the package. [53]
2.9 e a sy ta b le
The e a s y ta b le package by Enrico Bertolazzi provides a simplified method for drawing tables.
The package is part of the ea sy package series and automatically loads the main ea sy package.
The general line width is set when loading the package, but there are two package options -
t h i n l i n e s and t h ic k lin e s . The default values for these options are shown in Figure 2.4 on
the next page. If you get the KTeX error message “no room for a new dimen” when loading
etex additional packages, you need to load the e t e x package, which allows for more than the usual
dimension registers.
Figure 2.1: Specification of the line width through the package option.
62
2.9 easytable
e a s y ta b le uses different syntax for horizontal lines, so it can’t be used together with the no \hlin e
booktabs package. jl and no
\ c lin e
When you want to format columns and rows uniformly, e a s y ta b le offers clear advantages.
The following example creates a table with quadratic cells, achieved by assigning column type
with value e. Within these cells, the cells and rows are aligned according to the specifications
lr c and ctb. Not having the \ h l i n e and \ c l i n e commands available is no restriction; you
can set up the horizontal lines in the row formattin definition with the same notation as for
vertical lines in column definitions.
\usepackage[thinlines]{easytable}
1 r c i r c
AA BB tt \begin{TAB}(e){lrc}{ctb}
AA BB tt
1 & r &c \ \
AA &BB &t t \ \
1 r b i r b 1 & r &b
\end{TAB}\qquad
\begin{TAB}Ce){ | 1 | r | c | } { | c | t | b | }
1 & r & c\\AA & BB & t t \ \ l & r & b
\end{TAB}
The example above shows that the format specification for the row always applies to all
columns of a table. In the first row only the 1 can be vertically centred correctly; r and c do
not have an upper length like the 1, so are not centred vertically.
\usepackage[thinlines]{easytable}
\fbox{%
\begin{TAB}(e, 12pt,12pt) [ 5pt,2 .5cm,2 .5cm]{1:r :c }{c:t :b}
1 &r &c \ \
AA &BB &tt \ \
1 &r &b
\end{TAB}}
Horizontal and vertical lines don’t need different commands or symbols for their own
syntax anymore. The syntax provided by the TAB environment treats columns and rows the
same; all lines can, and must, be specified with the same symbols. The symbols listed in
Table 2.4 are valid for lines.
Table 2.4: Summary of
sym bol description sym bol description
the symbols for horizontal
i solid line dashed line and vertical lines.
» dash-dot line dotted line
0 like | , Vs of the width 1 like | , V4of the width
2 like | , V3of the width 3 like | , V4of the width
4 like | 5 like | , double width
6 like | , triple width 7 like | , quadruple width
8 like | , quintuple width 9 like | , sextuple width
You can’t insert partial lines in the TAB environment, but environments can be nested
arbitrarily, which can be used to achieve the same effect:
2 Packages
r \usepackage[thicklines]{easytable} r-------
| 02-09-3
1 r c
\begin{TAB}(e){ ;l r c ;}{;ctb;}
;b b ; 1 &r & c \\
AA tt AA & \begin{TAB}(e){ . r . } { .t . }BB\end{TAB} & t t \ \
1 &r &b
i r b \end{TAB}\\[\medskipamount]
\begin{TAB}(@)[10pt]{01r0}{0tt0}
\begin{TAB}(@){ : l r :}{:c t :}
1 & r \ \ AA & BB
\end{TAB} &
\begin{TAB}(@){lcl}{2bb2}
c \\tt
\end{TAB}\\
\begin{TAB}(@){lr}{c}
1 &r
\end{TAB} & \begin{TAB}(@){ . c .} { . c .} b \end{TAB}
\end{TAB}
2.10 h h lin e
The h h lin e package by David Carlisle extends the standard line commands. The blkarray
package by the same author was presented earlier in Section 2.4 on page 38; it also provides
line extensions, partly with the same syntax, h h lin e defines the command of the same name,
which expects only one parameter:
\h h l i n e {lin e definition}
The following example can be understood with the help of the very elaborate explanations
for Example 02-04-10 on page 44; no further explanations will be provided here.
64
2.11 m a k e c e ll
\usepackage{hhline}
0 1 2 3 4 5
0 1 2 3 4 5 \begin{tabular}{11 c | | c | cc 1 1 c c ||}
0 1 2 3 4 5 \h h lin e { |t:=:t :=|==#==:t | }
0 & 1 & 2 & 3 & 4 & 5 \\\h lin e
0 1 2 3 4 5
0 & 1 & 2 & 3 & 4 & 5\\\hhline{======}
0 1 2 3 4 5 0 & 1 & 2 & 3 & 4 & 5 \ \ \h h li n e { ||- |I - .. | | .-}
0 & 1 & 2 & 3 & 4 & 5\\\h h lin e{= ::=—::-=}
0 & 1 & 2 & 3 & 4 & 5 \\\h h lin e{|b := :b:=— : :— = :b | }
\end{tabular}
2.11 m akecell
The m ak ecell package by Olga Lapko is particularly suitable for formatting individual table
cells separately. In principle, the functionality of all the special commands that this package
provides can be achieved with commands from other packages as well.
The name of the command already indicates that it is designed for the formatting of an
individual cell. The parameter for the horizontal alignment may take any value allowed
by the array package: 1, c, r, p, m, and b. The last three expect a separate parameter for
the column width, so they must be enclosed in parentheses again, for example {p{4cm}}
or { > { \ t t f amily}m{4em}}. The mandatory parameter for the horizontal alignment maybe
empty ({}) but must be specified. For the vertical alignment, the usual three values b, c, and t
are allowed, \m akecell creates a cell which consists of a single-column table. If the optional
values are missing, the contents are centred horizontally and vertically. The starred version of
\m akecell adds the vertical space l\jot=3.0p t before and after the current cell. The order of
the parameter values doesn’t matter.
65
Packages
In contrast to \m a k ecell, the \th e a d command uses predefined values to format headers
of a table.
\th ead [column type] {text} \rothead {text} \th ea d f ont text
The optional parameter only affects the horizontal alignment; everything else is deter
mined by the following commands:
66
2.11 makecell
The package defines the following default values for the individual commands, but you
can of course use \renewcommand to modify them:
\newcommand\cellset{\def\arraystretch{l}\extrarowheight\z@\nomakegapedcells}
\newcommand\cellgape{}
\newcommand\cellalign{cc}
\newcommand\cellrotangle{90}
\newcommand\theadfont{\footnotesize}
\newcommand\theadset{}
\newcommand\theadgape{\gape}
\newcommand\rotheadgape{}
\newcommand\theadalign{cc}
\newcommand\bottopstrut{\gape{\strut}}
\newcommand\top stru t{\g a p e [t ] { \ s t r u t } }
\newc ommand\bot s t r u t {\g a p e[b] { \ s t r u t }}
For rotated captions, you m u s t specify the height of the text beforehand by assigning a
length to \r o th e a d s iz e . This is easy to do with the \s e tt o w id t h command, by passing it ^ l o a d
the longest line in the desired font. If \r o th e a d s iz e is not assigned a length, 0pt is assumed -5- rotating
automatically, which leads to output that makes no sense. The rotation angle is specified by PackaSe
\c e l l r o t a n g l e , which can be changed with \renewcommand. If the r o t a tin g package were
not loaded for the rotation, a warning would be written to the log file.
67
Packages
\usepackage{makecell,rotating} ,--------
[ 02-11-6
^ I \renewcommand\cellalign{lt}
+2 ^
H o column 2 \renewcommand\theadalign{lb}
\renewcommand\theadfont{\itshape\normalsize}
A \settowidth\rotheadsize{\theadfont T itle for}
■a B
\begin{tabular}{@{}ccc@{}}\hline
3<D oe gW \rothead{Title for\\column 1}
> & hJ
& \thead{column 2}
C vertical top RIGHT & \renewcommand\cellrotangle{45}
LEFT \rothead{column 3} \\\h lin e
A & \ro tc ell{v e rtic a l top\\LEFT} & B\\
C & \makecell*{vertical top \\ LEFT}
& RIGHT \\\h lin e
\end{tabular}
\g a p e [position] {te x t}
\Gape [height] [depth] {te x t}
The \g a p e command is the same as \sm ash from the amsmath package and changes the
vertical size of the box of text. Without arguments, the depth as well as the height of the
box are increased by \jot= 3.0p t. The optional argument can take the values b and t; b adds
size only to the depth of the box and likewise t adds size only to the height of the box. The
respective other length is minimized so that text just fits the box.
\usepackage{makecell}
\rule{lem}{0.5pt}\fbox{good text}\rule{lem}{0.5pt}\fbox{\gape{good text}}%
\rule{lem }{0. 5pt}\fbox{\gape[b]{good text}}\rule{lem }{0. 5pt}
\fbox{\gape[t]{good text}}\rule{lem }{0.5pt}
While \g a p e translates the box taking its current size into account, you can make individ-
iual adjustments with \Gape:
\usepackage{makecell}
\rule{lem}{0.5pt}\fbox{good text}\rule{lem}{0.5pt}\fbox{\Gape{good text}}%
\rule{lem}{0.5pt}\fbox{\Gape[5pt]{good text}}\rule{lem }{0.5pt}
\fbox{\Gape[5pt][-5pt]{good text}}\rule{lem }{0.5pt}
68
2.11 makecell
So using \g a p e and \Gape lets you change the depth and height of one cell, but the
following commands let you do this for one or all of the cells of a row or the whole of a table.
\b o t to p s tr u t
\t o p s t r u t
\b o t s t r u t
\s e t c e l l g a p e s [position] { length }
\m ak egap ed cells
\nom akegapedcells
The first three commands increase the default value for \ s t r u t by \jo t= 3 .0 p t respectively,
either for depth and height (\b o tto p s tr u t), only the depth (\b o ts tr u t), or only the height
(\to p s tr u t).
\ s e t c e l l g a p e s lets you adjust the height and/or depth of all cells of a table by a man
ually chosen length. If you don’t use an optional parameter (b or t), both the height
and depth are increased by the specified length. The two switches \m ak egap ed cells and
\nom akegapedcells activate and deactivate the additional insertion of vertical space.
\usepackage{makecell}
02-11-10 normal row
\setcellgapes{5pt}\makegapedcells
top and bottom
\begin{tabular}{@{}c@{}}\hline
top and bottom normal row\\\hline
top and bottom\\\hline
top and bottom\\\hline
normal row \end{tabular}\\[10pt]
top and bottom \nomakegapedcells
top and bottom \begin{tabular}{@{}c@{}}\hline
normal row \\\hline
top and bottom\\\hline
top and bottom\\\hline
\end{tabular}
69
Packages
2 .1 1 .2 M u l t i - l i n e c e l l s
The \m u ltirow command, already described in Section 2.3 on page 30, is reimplemented by load
the m ak ecell package through two of its own commands. It does however use other internal f m ultirow
package
commands of the m ultirow package, which therefore has to be loaded as well.
The behaviour of these two commands is similar to \m a k ece ll and \th ea d , as shown in
Example 02-11-6 on page 68.
\usepackage{multirow,makecell}
\begin{tabular}{ 1 c c } \h lin e
\multirowthead{4}{First column head}
& \multicolumn{2}{c}{\thead{Multi-column h ea d }}\\\clin e{2 -3 }
& \thead{Second and\\m ulti-line\\colum n head} & \thead{Third\\column h ea d }\\\h lin e
c e ll tex t & A &\multirowcell{4}{28—3 1 } \\ \c lin e { l- 2 }
\m akecell{m ulti-line \ \ c e ll te x t} & B & \ \ \h lin e
\m a k e c e ll[l]{le ft-a lig n e d \ \ c e ll te x t} & C
& \m u ltirow cell{4}[ . 5\norm albaselineskip][1]{37—4 3 } \\\c lin e { l-2 }
\m ak ecell[r]{righ t-align ed \ \ c e ll te x t} & D & \ \\h lin e
\m akecell[b]{bottom -aligned \ \ c e ll te x t} & E
& \m u ltirow cell{6}[\norm albaselineskip][r ]{37—43 \\52—5 8 } \\\c lin e { l-2 }
\m akecell[{{p{5cm }}}]{long long long c e ll text with fixed width} & F & \\ \c li n e { l - 2 }
\m ak ecell[{{> {\setlen gth \p arindent{lem}}p{5cm}} } ] { long long long
c e ll tex t with fixed width} & G & \ \\h lin e
\end{tabular}
Multi-column head
70
2.11 m a k e c e ll
to con vert
2 .1 1 . 3 Column numbering
You can also use the m a k e c e ll package to autom atically number columns, using the \ n l i n e
command; \ e l i n e lets you skip a specified number of columns. You can choose the numbering
format through the optional argument t y p e , w hich can make use of the common KTj?X formats:
a r a b ic (6), a lp h (f), A lp h (F), roman (vi), and Roman (VI).
\ e l i n e { c o lu m n s }
\ n l i n e [type] [start] { c o l u m n s }
\ r n l i n e [type] [start] { c o lu m n s }
\ r n l i n e is sim ilar to \ n l in e , except that the counting is done w ith C y r illic symbols.
71
Packages
1 2 4 6 8 9 10 \usepackage{makecell} ,-------
3 5 7 102-11-
2 A z \begin{tabular}{@{}c|*{9}{c}@ {}}
3 1 2 1 2 1 & \n lin e [ l] [ 2 ] { 9 } \\\h lin e
4 S4 S5 S6 S7 S8 S9 S 10 S ll S 12 2 & A & \e lin e {7 } & Z \\
5 (2) (3) (4) (5) (6) (7) 3 & \n lin e{2 } & \e lin e {5 } & \n lin e { 2 } \\
6 4 5 6 4 & \n lin e [ S l] [4]{9} \ \
5 & \n lin e [ ( a ) ] [ 2 ] { 6 } \\
6 & \e lin e {4 } & \ n l i n e [ l ] [4]{3}
\end{tabular}
2 . 12 m d w t a b
The mdwtab package by Mark Wooding is part of a whole series of mdwtools. The package is
not an extension of the standard ta b u la r and array environments as such, but reimplements
them from scratch. Therefore you might encounter problems when using mdwtab in con
junction with other packages that extend these two environments, but assume the standard
definition.
Here are the main differences in how the environments work:
> A major innovation is the way the column definitions are read and interpreted. You can
use an expression like { I@{} I } in standard IfipX, but not when using mdwtab. The “abuse”
of ©{} to avoid \d o u b le r u le se p between two vertical lines is explicitly forbidden. If you
tried to use it, you would get this error message:
On the other hand, constructs like {c@ * {4 }{{: }@ }{-}c} are allowed when using mdwtab.
This particular example expands to the expression {c@ {: }©{: }©{: }©{: }@ {-}c}.
> If a © expression follows a vertical line, it refers to the next column and not the current one.
> mdwtab defines some new column types in addition to the usual ones:
Ml, Me, Mr Mstands for Math and denotes columns with mathematical expressions;
1, c, and r have the usual meaning.
Tl, Tc, Tr The same for pure text.
# {p r e } {p o s t } User-defined column type that can be specified additionally through pre
(code before cell) and post (code after cell).
Several new commands are available in mdwtab:
\ta b p a u se provides an easy way to break a table in order to draw lines or insert text across all
columns, without having to use the \m u lticolum n command. The text is typeset in paragraph
mode, so line breaks are possible. You can use \ v l i n e with an optional argument to insert a
vertical line of specified width, \vgap inserts vertical space at any arbitrary position on a table
72
2.12 mdwtab
row, though using \ h l x is more effective; this command is discussed in more detail below.
In the following example, the column type is set to Me, which means that the mathematical
expressions don’t have to be enclosed in $ ... $. However, this has no effect on the argument
of \ta b p a u se, which is always typeset in text mode.
\usepackage{mdwtab}
e q u a tio n s
\b egin {tab u lar}!!{\vlin e[3pt]}l@ {\qu ad }|M c|}\hlx{sh v[l, 2]}
& eq u a tio n s\\\h lx {v [l][1 0 p t]h v [][5 p t]}
1st f(x) = ^ r lst& f(x )= \fr a c {\sq r t{x A2- l} } { x A2+l> \\\h lx {v h v }
2nd fix) = 2nd& f(x )= \fr a c {\sq r t{x A2- l} } { x A2+ \fr a c{l}{x A2}}\\\h lx{vh >
\tabpause{Now the same equations\\
again!}\hlx{hv}
Now the same equations 3rd& f(x )= \fr a c {\sq r t{x A2 -l} } { x A2+l> \\\h lx {v h v }
again! 4th& f(x )= \fr a c {\sq r t{x A2 -l} } { x A2 + \fra c{l}{x A2}}\\\h lx{vh >
\end{tabular}
3rd fix) - ^
4th fix) =
The special line command \ h l x (\h lin eexten d ed ) lets you manipulate the row spacing
without any additional commands. The following arguments are available for \h lx :
In Example 02-12-1, the individual arguments, which always must be interpreted one after
the other, have the following meaning:
73
Packages
When using mdwtab, the \newcolumntype command also has a different syntax. In
contrast to array, mdwtab allows an optional argument.
\usepackage{mdwtab}
arbi- arbitrary text
\newcolumntype{P}[ 1 ] [ 2cm] {%
trary again
>{\raggedright\hspace{Opt}}p{#l}}
text
\begin{tabular}{| P[lcm] | P | }\hlx{hv}
arbitrary text & arbitrary text again\\\hlx{vh}
\end{tabular}
2 .1 3 s la s h b o x
The sla sh b o x package by Koichi Yasuoka provides support for divided cells. A common use
is to specify both a column label and a row label in the upper left cell of a table:
\usepackage{slashbox}
\usepackage{pict 2e}
\b e g in {ta b u la r}{l|* {5 }{c}}
\backslashbox{holiday}{year} & 2007 & 2008 & 2009 & 2010 & 20 1 1 \\\h lin e
Easter & 08.04. & 23.03. & 12.04. & 04.04. & 2 4 .0 4 .\\
Pentecost & 27.05. & 11.05. & 31.05. & 23.05. & 12.06.
\end{tabular}
year
h o lid a y ^ \^
2007 2008 2009 2010 2011
Easter 08.04. 23.03. 12.04. 04.04. 24.04.
Pentecost 27.05. 11.05. 31.05. 23.05. 12.06.
It’s a good idea to load sla sh b o x package together with the p ic t2 e package by Hubert
Gafilein and Rolf Niepraschk to produce better lines, sla sh b o x has two commands:
74
2.13 slashbox
The only difference between the commands is where the line is drawn: \s la sh b o x draws it
from the lower left corner to the upper right corner and \b a ck sla sh b o x from the upper left
to the lower right.
\usepackage{slashbox,pict 2e}
\b eg in {ta b u la r}{r|* {5 }{c }|1}
\backslashbox{holiday}{year}& 2007& 2008& 2009& 2010& 2011&
\slash b ox{year}{h olid ay}\\\h lin e
Easter & 08.04. & 23.03. & 12.04. & 04.04. & 24.04. & E aster\\
Pentecost & 27.05. & 11.05. & 31.05. & 23.05. & 12.06. & Pentecost
\end{tabular}
year year
h o li d a y ^ - ^ ^
2007 2008 2009 2010 2011
^ ^ ^ " ^ n olid ay
Easter 08.04. 23.03. 12.04. 04.04. 24.04. Easter
Pentecost 27.05. 11.05. 31.05. 23.05. 12.06. Pentecost
The arguments o f L text and R text are typeset in paragraph mode; therefore \ \ can be
used. This automatically makes the column wider however. Using the optional argument
for the width can make sense; it only has an effect if it is larger than the width calculated
internally. In the following example the specification o f 20 mm is not taken into account
because it is smaller than the calculated width.
\usepackage{slashbox,p ic t 2e}
\b eg in {ta b u la r}{l|* {5 }{c}}
\backslashbox[20mm]{two\\ holidaysH year} & 2007 & 2008 & 2009 & 2010 & 20 1 1 \\\h lin e
Easter & 08.04. & 23.03. & 12.04. & 04.04. & 2 4 .0 4 .\\
Pentecost & 27.05. & 11.05. & 31.05. & 23.05. & 12.06.
\end{tabular}
year
two 2007 2008 2009 2010 2011
holidays
Easter 08.04. 23.03. 12.04. 04.04. 24.04.
Pentecost 27.05. 11.05. 31.05. 23.05. 12.06.
75
Packages
\usepackage{slashbox,p ic t 2e}
\begin{tab u lar}{|@ {}r|*{5}{c}|1@ {}|}\hlin e
\backslashbox[Opt] [ 1 ] {holiday}{year} & 2007 & 2008 & 2009 & 2010 & 2011
& \slash b ox[O p t][r]{year}{h olid ay}\\\h line
Easter & 08.04. & 23.03. & 12.04. & 04.04. & 24.04. & EasterW
Pentecost & 27.05. & 11.05. & 31.05. & 23.05. & 12.06. & P en teco st\\\h lin e
\end{tabular}
year year
2007 2008 2009 2010 2011
h o lid a y " ^ \^ ^ ^ ^ n o lid a y
Easter 08.04. 23.03. 12.04. 04.04. 24.04. Easter
Pentecost 27.05. 11.05. 31.05. 23.05. 12.06. Pentecost
2 .1 4 sp r e a d ta b
The spreadtab package by Christian Tellechea provides a simple spreadsheet and makes
it possible to sum numerical values in columns. The spreadtab environment replaces the
ta b u la r environment.
A table cell is uniquely identified by its row and column. The columns are designated by
[a..z] and the rows by [ 1 .]. The case is not significant for the column; more than 26 columns
are not possible. If a \m ulticolum n command is used, the combined cells are identified by
the identifier of the leftmost cell. The following diagram illustrates the structure:
You can apply the usual arithmetic operators to perform operations on the contents of
cells, as shown in the following example. Internally, the fp package is used; divisions can be
done with precision of up to 18 digits after the decimal point.
76
2.14 spreadtab
27 54 81 \usepackage{spreadtab}
58 45 13 \begin{spreadtab}{{tabular}{rr |r}}
50 25 1250 27 & 54 & al+bl \ \
60 47 1.276595744680851063 58 & 45 & a2-b2 \ \
135 146 0.924657534246575342 50 & 25 & a3*b3 \ \
60 & 47 & a4/b4 \\\h lin e
al+a2+a3 & bl+b2+b4 &a5/b5
\end{spreadtab}
However, visually it’s a good idea to use ; \STautoround command to limit the number
of digits after the decimal point, especially divisions.
27 54 81 \usepackage{spreadtab} \STautoround{3}
[()2-14-3
58 45 13 \begin{spreadtab}{{tabular}{rr |r}}
50 25 1250 27 & 54 & al+bl \ \
60 47 1.277 58 & 45 & a2-b2 \ \
135 146 281 50 & 25 & a3*b3 \ \
60 & 47 & a4/b4 \\\h lin e
al+a2+a3 & bl+b2+b4 &a5+b5
\end{spreadtab}
2 .1 4 .1 R e la t iv e r e f e r e n c e s t o t a b l e c e ll s
Starting from the current cell, relative cell addresses can be given through two numerical
values in square brackets. The specification [ - 1 ,3 ] denotes the cell that is one column to the
left and three rows down. Using this functionality means we can produce Pascal’s triangle by
specifying just one number; the m atrix math environment then determines the number of
columns automatically. In this case no column definitions are needed.
\usepackage{spreadtab, amsmath}
$\begin{spreadtab}{{m atrix}{}}
1\ \
[ 0, - 1 ] & [ - 1 , - 1 ] \ \
[ 0, - 1 ] &[ - l , - l ] + [ 0, - l ] &[ - 1 , - 1] \ \
[ 0, - 1 ] &[ - l , - l ] + [ 0, - l ] & [ - l , - l ] + [ 0, - l ] & [ - 1 , - 1 ] \ \
[ 0, - 1 ] &[ - l , - l ] + [ 0, - l ] & [ - l , - l ] + [ 0, - l ] & [ - l , - l ] + [ 0, - l ] & [ - 1 , - 1 ] \ \
[ 0, - 1 ] &[ - l , - l ] + [ 0, - l ] & [ - l , - l ] + [ 0, - l ] & [ - l , - l ] + [ 0, - l ] & [ - l , - l ] + [ 0, - l ] &
\end{spreadt ab}$
[ 02-14-4
1
1 1
1 2 i
1 3 3 1
1 4 6 4 1
1 5 10 10 5
77
Packages
2 .1 4 .2 T ext c o lu m n s
By default, the spreadtab package assumes that a table cell contains either purely numerical
contents, a command, or a relative reference. If you want a cell to contain text, you must
insert a @symbol at the beginning o f the cell.
If the @symbol can’t be used for TgXnical reasons, you can use \S T t e x t c e ll instead; it is
identical to the @symbol.
2 .1 4 .3 M ix e d c e lls
If a cell contains text as well as code specific to spreadtab, you must separate the numerical
contents from the text part by the assignment operator : =. The general syntax for mixed cells
is
The numerical content has to be enclosed in curly braces. The \ST num ericfieldm arker
command is an alternative to the assignment operator, if the : = symbol can’t be used for
TpXnical reasons (for example when activating French, where the colon is an active symbol).
2 . 1 4 .4 O m ittin g r o w s o r c o lu m n s
You can omit individual rows or columns from the output using the corresponding command
in the row or column:
\SThiderow \S T h id e co l
2.14 spreadtab
An omitted column also does not appear in the column definition of the table. In the
following example there are five columns internally, but with the spreadtab environment,
only the four “active” columns r | ccc are defined. Hiding a row may be useful if the values
need to be taken into account but shouldn’t be visible to the user.
\usepackage{spreadtab}
\begin{spreadtab}{{tabular}{r | c c c}}\h lin e
@ $x$ \emph{values} &-1 &0 \SThidecol & 2 &3 \\\h lin e
@ $f(x)= 2\cdot x -l$ &2*[ 0,-l]-l& 2*[ 0, - l ] - l & 2*[ 0, - l ] - l &2*[ 0, - l ] - l \ \
@ $g(x)=x-10$\SThiderow& [0 ,-2 ]-1 0 & [0 ,-2 ]-1 0 & [0 ,-2 ]-1 0 & [0 ,-2 ]-1 0 \ \
@ Sh(x)=l-x$ &l - [ 0 ,- 3 ] &l - [ 0 ,- 3 ] & l- [ 0 ,- 3 ] &l- [ 0 ,- 3 ] \\\h lin e
@ $j(x)=xA2$ &[0 ,-4 ]* [0 ,-4 ] & [0 ,-4 ]* [0 ,-4 ] & [0 ,-4 ]* [0 ,-4 ]
& [0 ,-4 ]* [0 ,-4 ] \ \\h lin e
\end{spreadtab}
x values -1 2 3
f ( x ) = 2- x - l -3 3 5
h(x) = 1 - x 2 -1 -2
j ( x ) = X2 1 4 9
2 .1 4 .5 S a v i n g o f c e ll c o n t e n t s
If you want to use the contents of a cell outside the current cell, you can use the \S T s a v e c e ll
command to save the contents of the cell in a macro name, which can be chosen arbitrarily. It
has to be specified in the optional argument of spreadtab.
The cell must be defined as an absolute reference, i. e. the unique combination of column and
row, for example h3.
10 20 30 60 cell cl : 30 \usepackage{spreadtab}
\begin{spreadtab}[\STsavecell\result{cl}]%
cell cl had the value 30 { { t a b u la r } ! |c |c |c |c |c |} } \h lin e
10 & a l +10 & b l +10 & al+bl+cl
& ©cell c l : \r e s u lt \\\h lin e
\end{spreadtab}\par\medskip
\medskip
c e ll c l had the value \r e su lt
There is no limit to the number of cells that can be saved in spreadtab; you just need to
list them all one after the other in the optional argument.
79
Packages
2 . 1 4 .6 M a th a n d d a te fu n c tio n s
spreadtab provides the following mathematical and date operations for manipulating cell
contents:
sum (< reg io n l> \< reg io n 2 > \. . . ) Sum the cells, starting with the first region and ending with
the nth region. A region can be
> a single cell or
> a fr o m -to region o f the form <from>:<to> ; a rectangular region that contains
several rows and columns is possible as well.
0 1 2 3 4 5 6 7 8
1 Ï 2 6 24 120 720 5040 40320
sumprod (< region l> \< region 2> \. . . ) The corresponding cells are first multiplied (first cell in
region 1 by first cell in region 2, etc.) and then the products are added. All regions
need to be the same length and correspond to the syntax given above. Cells that do not
80
2.14 spreadtab
contain a numerical value or that don’t exist because of a \m ulticolum n command are
assigned the value zero.
\usepackage{spreadtab}
\begin{spreadtab}{{tabular}{ @{} r *6c @{}}}
@age & 10 & 11 & 12 & 13 & 14 & 1 5 \\
©number & 5& 8 & 2 0 & 5 5 & 9 & 3 \\\h lin e
\multicolumn{7}{@{}l}{mean age: :={sumprod(bl:g l;b 2 :g2)/sum(b2:g2)}}
\end{spreadtab}
age 10 11 12 13 14 15
number 5 8 20 55 9 3
mean age: 12.64
rand Outputs a random number between 0 and 1. If you need to output the same random
series more than once, the internal \ST@seed command must be overwritten:
\makeatletter\renewcommand\ST@seed{}\makeatletter
Now the random number generator can be started individually with \F P seed =<number>.
If you set the number to be the same, the same series will be output.
randint( min, max) Outputs a random integer between min and max. If min is not given, an
integer between 0 and m ax is produced.
\usepackage{spreadtab} \STautoround{4}
\begin{spreadtab}{{tabular}{@{} l|c c c c ©{}}}
©random number $ \in [ 0;1 ] S &rand() &rand() &rand() &rand() \\
©random number $ \in [—5;5]S &randint(-5,5)&randint(-5,5)&randint(-5, 5)& randint(-5,5)\\
©random number $ \in [ 0; 20]$ &randint(20) &randint(20) &randint(20) &randint(20) \ \
\end{spreadtab}
81
Packages
\usepackage{spreadtab}
\begin{spreadtab}{{tabular}{cc}}
@1789/7/14 & engshortdatetonum(al)\\
2001/ 1/1 :={} & engshortdatetonum ([-l, 0] ) \ \
engshortdatetonum(0/3/l) & engshortdatetonum(\number\year/\number\month/\number\day)\\
englongdatetonum(February 13, 2005) & englongdatetonum(\today)\\
©July 1, 1970 & englongdatetonum (a5)\\\hline
@2010/11/23 & engshortdatetonum([ - 1 , 0] ) \ \
@2010/ 1/1 & engshortdatetonum ([-l, 0] ) \ \
©difference & :={[ 0, - 2] —[0, —1 ]} days
\end{spreadtab}
1789/7/14 653554
2001/1/1 730791
0 734213
732295 734213
July 1, 1970 719649
2010/11/23 734404
2010/1/1 734078
difference 326 days
2010/3/17 \usepackage{spreadtab}
02-14-15
365 2011/3/17 \begin{spreadtab}{{tabular}{cc}}\hline
365 March 17, 2011 \m ulticolum n{2}{|c|>{@2010/3/17} \\\h lin e
365 March 365 & num toengshortdate(engshortdatetonum (al)+[-l,0])\\
365 thursday 365 & numtoenglongdate(engshortdatetonum(al)+[-l,0]) \ \
-365 2009/3/17 365 & nuratoengmonth(engshortdatetonum(al)+[-l,0]) \\
-365 March 17, 2009 365 & numtoengday(engshortdatetonum(al)+[-l,0]) \\\h lin e
-365 March -365 & num toengshortdate(engshortdatetonum (al)+[-l,0])\\
-365 & numtoenglongdate(engshortdatetonum(al)+[-l,0]) \ \
-365 tuesday
-365 & numtoengmonth(engshortdatetonum(al)+[-l,0]} \\
-365 & numtoengday(engshortdatetonum(al)+[-l,0])
\end{spreadtab>
2 .1 5 ta b ls
The t a b ls package by Donald Arseneau has the sole aim of optimizing the vertical row
spacing, which is often not good with the standard KHeX tables, ta b ls defines three additional
82
2.15 tabls
lengths and modifies the \ h l i n e command to insert optioned vertical space of a chosen length
like the one for \ \ .
\t a b lin e s e p \a r r a y lin e s e p \e x tr a r u le s e p
\ h l i n e [length]
\setlength\tablinesep{O pt}
\setlength\arraylinesep{O pt}
\setlength\extrarulesep{O pt}
The following example firstly uses the default lengths in t a b ls and then repeats the table
using the standard KdpX settings for comparison.
\usepackage{tabls}
The t a b ls package works in conjunction with many packages, but you don’t necessarily
get the results that you expect. For example, for the sla sh b o x package it fails to take account f using
of any changed spacings, so the diagonals don’t end in the corners: ta b ls ai
slashbox
83
Packages
Easter & 08.04. & 23.03. & 12.04. & 04.04. & 24.04. & E aster\\
Pentecost & 27.05. & 11.05. & 31.05. & 23.05. & 12.06. & P en te co st\\\h lin e
\end{tabular}
The following table makes use of the extra space provided by the tab I s package; without
this space it would have been much harder to read.
\usepackage{tabls}
\newcommand{\T}{\textsf{T}}\newcommand{\Z}{\mathcal{Z}}\newcommand{\C}{\textsf{c}}
\begin{tabular}{@ {}c|c|ccccc@ {}}\hline
BV \rule[-0.3cm]{0cm}{0.8cm}& R & $d$ & $u_\Z$
& $u_{\ZA\C}$ & $v_\Z$ & $v_{\ZA\C }$ \\\h lin e
$u_\Z$ \r u le [ - 0 .3cm]{0cm}{0. 8cm}& $y_\Z$&$A_\Z$ & $1$ & $0$ & $-1$ & $0$ \ \
$u_{\ZA\C}$ \rule[-0.3cm]{0cm}{0.8cm}& $y_{\ZA\C}$
& SA_{\ZA\C}$&$0$ & SI$ & $0$ & $ -I $ \\\h lin e
ZF/GK & $e_mA\T
\le ft(\b e g in {a rra y }{c } y_\Z \ \ y_{\ZA\C }\end{array}\right)$
& $e_jnA\T \left(\begin{array}{c}A _\Z \\A _{\ZA\C }\end{array}\right) S
& $0$ & $0$ & $-2e_nA\T$ & S-2e_{m-n}A\T$ \\\h lin e
\end{tabular}
I02-15-3
BV R d Uz uzc Vz v zc
uz yz AZ i 0 -/ 0
UZC A zc 0 i 0 -/
2 .1 6 ta b u la r h t
The ta b u la r h t package by Heiko Oberdiek lets you specify the height of the table and
therefore a variable row height to achieve the respective height.
The package can be loaded with the option v lin e s , which offers - albeit experimental -
support for correct vertical lines if additional vertical space was inserted. This option requires
84
2.16 tabularht
E-T^X, which is standard in current TgX distributions. Additional possible options concern the
sPecify <£> output driver, e.g. d vip s, p d f te x ,__ It must only be specified however if there are problems
p s driver jl w ith the automatic detection (for example for dvips).
The package supports the following environments:
\usepackage{booktabs}
\usepackage{tabularht}
\fbox{%
\begin{tabularht*}{0.8in}{4in}{@ {} 1 @ {\e x tra co lsep {\fill}} r @{}}
top left& top r ig h t\\\in te r r o w f ill
\multicolumn{2}{@{}c@{}}{bounding b o x }\\\in te r r o w fill
bottom l e f t & bottom right
\end{tabularht*}}
85
Packages
bounding box
Vertical lines are counted starting at 1 on the left. In the following example, only the
second and third line are set to be continuous.
The last example uses a fixed \in te r r o w sp a c e and a command called in an \in te r r o w s ta r t-
\in te r r o w s to p sequence:
2 .1 7 ta b u la r k v
The tab u lark v package by Heiko Oberdiek is virtually identical to the ta b u la r h t package
(which is loaded automatically, cf. Section 2.16 on page 84), but it uses the “key-value” interface
and therefore also loads the k ey v a l package. The optional parameters are:
86
2.18 tabularx
For all options, you use a tab u lark v environment, and the package automatically selects
the table environment that corresponds to the parameters that you have assigned. The second
optional argument for the vertical position pos (t, b, c) isn’t really necessary, as you can easily
specify the vertical position through v a lig n in the options.
\usepackage{booktabs, tabularkv}
02-17-1 | top left top right
\fbox{%
bounding box \begin{tabularkv}[width=2. 25in, height=0. 75in ,
valign=center]{@ {}l@ {\extracolsep{\fill}}r@ {}
bottom left bottom right top left& top right \\\in te r r o w f ill
\multicolumn{ 2}{@{}c@{}}{bounding b ox}\\
\in te r r o w fill
bottom l e f t & bottom right
\end{tabularkv}}
2 .1 8 ta b u la r x
The ta b u la r x package by David Carlisle is used frequently, because it provides an easy way
to adapt the width o f the table to the width o f the current row. The package defines the X
column type, which stands for a p column o f variable width depending on the width o f the
table to be specified by the user. The syntax is almost identical to a normal table, though the
width of the table has to be given as well.
\en d {ta b u la r x }
You can combine the X column type arbitrarily with other standard or user-defined types. The
main difference to the ta b u la r* environment is that ta b u la rx adjusts the column width
whereas ta b u la r* adjusts the space between the columns.
87
2 Packages
All the X columns within a table have the same width, regardless o f whether they are
adjacent or separated by other column types, as shown here:
Text before the table, which spans the whole \usepackage{tabularx} r--------
02-18-2
line to show that the table is that wide as well.
Text before the tab le, which spans the whole lin e to
The width of This The width show that the table i s that wide as w ell.\p a r
this column column o f this col \begin{tabularx}{\linew idth}{|X | p{lcm} | X |}
is determined is 1 cm umn is also The width of th is column i s determined autom atically.
automatically. wide. determined & This column i s l\,cm wide.
automatically. & The width of th is column i s also determined
autom atically.
Text after the table, which spans the whole line
\end{tabularx}\par
to show that the table is that wide as well.
Text a fter the tab le, which spans the whole lin e to
show that the table is that wide as w ell.
However, you can adjust the X columns individually using \ h s i z e by specifying a decimal
fraction of the total width of the X columns. In the following example, the first X column is set
to be 0.7 times the normal width and the second one 1.3 times it.
\usepackage{tabularx}
Text before the tab le, which spans the whole lin e to show that the table is
that wide as w ell.\p a r
\b e g in {ta b u la rx }{\lin ew id th }{|> {\setlen g th \h size{ 0. 7\hsize}}X |p{lcm }|
> { \s e tle n g th \h s iz e { l. 3 \h size}}X |}
The width of th is column i s determined autom atically. & This column i s l\,cm wide.
& The width o f th is column i s determined autom atically.
\end{tabularx}\par
Text after the ta b le, which spans the whole lin e to show that the table i s
that wide as w ell.
\h size ^ With three X columns, the sum of all \ h s i z e lengths has to add up to three, and so on.
In all these examples for tab u larx, the justification of the text in narrow columns doesn’t
look good. In these situations, you should also use \r a g g e d r ig h t or \RaggedRight from the
ragged2e package by Martin Schröder; the latter saves the explicit \a rra y b a ck sla sh call.
88
2.18 tabularx
All X columns correspond to the p column type, but you can transform them into a
different type by redefining the assignment. In the following example we change from a p to
a m column and reduce the font size. The output is a bit hard to understand at first glance;
both X columns are centred vertically to each other and to the start of the middle p column.
Text before the table, which spans the whole \ u s e p a ck a g e {ta b u la r x , ragged2e}
line. \renew com m and\tabularxcolum n[l]{>{\sm all}m {#l}}
The Text before the ta b le, which spans the whole lin e .
width
of this The width o f this \begin{tabularx}{\linewidth}{@ {}
column column is deter > {\se tle n g th \h siz e{0 . 7\hsize}\RaggedRight}X |
This
is deter mined automati >{\RaggedRight}p{lcm} |
column
mined cally. >{\setlength\hsize{1.3\hsize}\RaggedRight}X@ {}}
is 1 cm
automati The width of th is column i s determined autom atically.
wide.
cally. & This column i s l\,cm wide.
& The width of th is column i s determined
Text after the table, which spans the whole
autom atically.
line. \end{tabularx}\par
Text a fter the ta b le, which spans the whole lin e .
89
Packages
2 .1 9 ta b u la r y
Text before the table, which spans the whole \usepackage{tabulary} ,--------
[ 0 2 - 19-1
line.
Text before the ta b le, which spans the whole lin e .\p a r
The height This The \begin{tabulary}{\linew idth}{|L | C | R |}
of this column height is The height of th is column i s determined
column is is of un also deter autom atically.
& This column i s of unknown width.
determined known mined
& The height i s also determined
automati width. automati
autom atically.
cally. cally. \end{tabulary}\par
Text after the table, which spans the whole Text a fter the ta b le, which spans the whole lin e .
line.
\usepackage{tabulary}
Text before the tab le, which w ill span the whole width of the lin e with an
additional linebreak but without sense.\par
\begin{tabulary}{\linewidth}{@ {}J | J | J@{}}
The height of th is column i s determined autom atically.
& This column i s ?\,cm wide, but how wide exactly i s unknown.
& The height of th is column i s determined automatically such that a ll columns
have the same height for the given width.
\end{tabulary}\par
Text after the ta b le, which w ill span the whole width of the lin e with an
additional linebreak but without sense.
Text before the table, which will span the whole width of the line [ 02-19-2
with an additional linebreak but without sense.
The height of This column The height of this column
this column is ? cm wide, is determined automatically
is determined but how wide such that all columns have
automati exactly is the same height for the given
cally. unknown. width.
Text after the table, which will span the whole width of the line
with an additional linebreak but without sense.
This package uses the two lengths \ty m in and \tym ax internally so as not to let the widths
of the columns become too small or too large. The default values are 10pt and 2\te x tw id th ,
90
2.20 threeparttable
but you can change them if appropriate. If you are using narrow columns, it is better to work
with the standard 1, r, or c column types anyway. These types can be combined arbitrarily
with the types of tab u lary.
2.20 t h r e e p a r t t a b l e
The th r e e p a r tta b le package by Donald Arseneau lets you add captions and notes to tables.
To achieve this, a standard ta b u la r environment is put into a th r e e p a r tta b le environment,
which works like t a b le environment, but does not float.
If it should float, the ta b le environment must be used additionally . The package allows the
global options summarized in Table 2.7. They can be overwritten locally in the ta b le n o te s
environment.
name description
\b e g in { th r e e p a r tt a b le } [position]
\ c a p t i o n { . .. }
\b e g in { t a b u la r } ... (or \b e g in { ta b u la r * } ... )
... \ t n o t e { number } & ...& ... \ \
\e n d { ta b u la r } (o r \e n d { ta b u la r * })
\b e g in { ta b le n o te s } [settings]
\it e m [number] text
\e n d { ta b le n o te s }
\e n d { th r e e p a r tta b le }
The optional parameter position refers to the vertical alignment and can take one of the usual
options: t (default), b, or c. For the ta b le n o te s environment, the package options described
above are possible as well. If inserted here, they override the corresponding global options.
The package does not increase the numbers of footnotes automatically; you have to take care
of this yourself.
The first of the following two examples uses the second footnote (\item ) as a caption for
the following ones. To make this caption appear in normal font size and bold, the \t n o t e
command is redefined locally with \renewcommand.
91
Packages
I 0° to 90° + + + + + +
II 90° to 180° + - - - - +
III 180° to 270° - - + + - -
IV 270° to 360° - + - - + -
\usepackage[para]{threeparttable}
\begin{threeparttable} \caption{D ifferent gas analyses.}
\begin{tabular} [ t ] { r |c |c |c } \h lin e
& PI & P2\tnote{A} & P 3 \\\h lin e
decrease in pressure & 0.149 & 0.494 & 0.199 \ \
winding & 0.146 & 0.480 & 0.240 \ \
heat extraction & 0.164\tnote{a} & 0.508 & 0.209 \\\h lin e
\end{tabular}
\b e g in {ta b len o tes}[flu sh left]
92
2.21 threeparttablex
PI P2a P3
decrease in pressure 0.149 0.494 0.199
winding 0.146 0.480 0.240
heat extraction 0.164a 0.508 0.209
A uncertain measurement
a disturbance during measurement
Further commands that are of interest in th r e e p a r tta b le are shown in Table 2.8:
Table 2.8: Summary of the most important lengths and commands for threeparttable.
name description
\TPTminimum Minimal width of \ c apt io n (default 4 em).
\TPTr la p { argument } Takes the margin o f the table into account for footnotes in
right-aligned columns.
\T P T tagStyle{ argument} Formatting of the label of \ t n o t e (default {}).
\TPTnoteLabel{ argument} Formatting of the label of \ite m (default \tn o te ).
\T P T n oteS ettin gs Sets all defaults for ta b le n o te s ( l i s t environment).
2.21 t h r e e p a r t t a b l e x
The th r e e p a r tta b le x package by Lars Madsen is an extension of the th r e e p a r tta b le pack
age, which is loaded as well by default. The aim of the package is to extend the functionality to
support tables with a page break, th r e e p a r tta b le x allows the use of ta b le n o te s together
with lo n g ta b le (cf. Section 4.1 on page 125). In addition to the functionality described in
Section 2.20 on page 91, there are the following extensions:
> The T hreePartTable environment is a container for the new TableN otes and
lo n g ta b le environments.
> The T ableN otes environment has the same functionality as the ta b le n o te s environ
ment from th r e e p a r tta b le , but must appear before the lo n g ta b le environment.
> The \in s e r tT a b le N o te s command can also be used within lo n g ta b le , unlike the
T ableN otes environment. \in se r tT a b le N o te s uses the \m ulticolum n command.
\usepackage{longtable, threeparttablex}
\begin{ThreePartTable}
\begin{TableNotes}
\item [a] A remark to the tab le.
93
Packages
page 1 page 2
You can label the remarks within the T ableN otes environment and then reference them
with the \ t n o t e x command (though to use this feature you must load the package with the
r e fe r a b le option set). If you have the h yp erref package loaded, use the starred version
\tn o te x * if you don’t want these references to be converted into links.
94
2.21 threeparttablex
\usepackage{longtable} \usepackage[referable]{threeparttablex}
\begin{ThreePartTable}
\begin{TableNotes}
\ite m [a ]\la b e l{tn :a } A remark to the tab le.
\item [b ]\la b el{tn :b } This tab le i s only a demo.
\end{TableNotes}
\begin{longtable}{@ {}l c r p{1.5cm}@{}}
L & C & R & b o x \\\h lin e
\endfirsthead
\m ulticolum n{4}{@ {}l}{\sm all\ldots\em ph{continued}}\\\hline
L & C & R & b o x \\\h lin e
\endhead
\h lin e
\multicolumn{4}{r@{}}{\small\emph{continued on next page} \ld o t s } \ \
\endfoot
\h lin e
\insertTableNotes
\en d lastfoot
1 & c & r & 1st row\\ 1 & c & r & 2nd row\\ 1 & c & r & 3rd row\\
1 & c\tn otex{tn :a} & r & 4th row\\ 1 & c & r\tn otex{tn:b} & 5th row\\
1 & c & r & 6th row\\ 1 & c & r & 7th row\\ 1 & c & r & 8th row\\
1 & c & r & 9th row\\ 1 & c & r &10th row\\ 1 & c & r &llth row\\
1 & c & r &12th row
\end{longtable}
\end{ThreePartTable}
threeparttablex d e m o threeparttablex d e m o
page 1 page 2
95
Packages
2.22 w a r p c o l
th mode The warpcol package by Wayne A. Rochester provides an alternative to the dcolumn package
(cf. Section 2.24 on page 98) to format columns of numbers. Like dcolumn, warpcol typesets
the columns in math mode by default; so when adding captions in columns, you must switch to
text mode, easily done by using the \m u lticolum n command, warpcol defines the P column
type, which expects the formatting for decimal numbers in the form S xy as a parameter,
where S stands for a negative sign, x for the number of digits of the whole number part, and
y for the number o f decimal places. This defines the basic width of the column, before any
caption is added. In Example 02- 22- 1, the first column is formatted with P {3 .1 }, i.e. with
three digits in front or the decimal point and one digit after. The second column is set to span
the width of the sign, two whole number digits, and one decimal place.
\usepackage{warpcol}
column 1 column 2 | 02-22-1 |
123.4 -1 2 .3 \begin{tabular}{P{3.1} P {-2. l} } \h lin e
12.3 12.3 \multicolumn{l}{c}{\emph{column 1 }}
1.2 1.2 & \multicolumn{l}{c}{\emph{column 2} } \\\h lin e
123.4 & -12.3W 12.3 & 12.3W 1.2 & 1 . 2\\\h lin e
\end{tabular}
It’s a good idea to format column captions correctly regardless o f their length, even if
afterwards there is only a column o f numbers. Usually, you’ll set up the definition using a
\m ulticolum n command and one o f the three standard column types: 1, c, or r. warpcol
provides further support for the formatting through the following two commands:
\p c o lb e g in { type } { argument} \p c o le n d
The first parameter of \p c o lb e g in expects one of the standard column types and the second
one the definition of the format of the column of numbers. This is only of interest for a left-
or right-aligned column, which could not be aligned correctly with the P column type. The
following example illustrates the use of these commands:
\usepackage{warpcol}\newcolum ntype{L}[l]{>{\pcolbegin{r}{#l}}l<{\pcolend}}
\newcolumntype{R}[1 ]{>{\pcolbegin{r}{#l}}r<{\pcolend}}
\begin{tabular}{@{} L{3.1}L{3.1}P{3.1}P{3.1}R{3.1}R{3.1} ©{}} \h lin e
\multicolumn{l}{l}{KT} & \m ulticolum n{l}{l}{long t i t l e }
& \multicolumn{l}{c}{KT} & \m ulticolum n{l}{c}{long t i t l e }
& \multicolumn{l}{r}{KT} & \m ulticolum n{l}{r}{long t i t l e } \ \ \h lin e
123.4 & 123.4 & 123.4 & 123.4 & 123.4 & 123.4 \ \
12.3 & 12.3 & 12.3 & 12.3 & 12.3 & 12.3 \ \
1.2 & 1.2& 1.2 & 1.2 & 1.2 & 1.2 \\\h lin e
\end{tabular}
96
2.23 widetable
With \p c o lb e g in ... \p co len d , you can left-align, right-align, or centre the columns of
numbers arbitrarily.
When formatting the columns, you can pass anything as an argument that makes sense
for a column o f numbers. In the following example, the first column is formatted with the
expression L{< 1 .3 } , which specifies a comparison operator, a space, one digit before the
decimal point, and three digits after it. The second column is formatted as P {3 \ ,3 .2 } : three
digits, a space of \ ,, a further three digits, and two decimal places.
2 .2 3 w id e ta b le
The following three examples show the main difference between the lo n g ta b le * , tab u larx,
and w id eta b le environments; only the latter distributes the required space evenly over all
columns.
\usepackage{tabularx,widetable}
\begin {tab u lar*}{\lin ew id th }{| 1 |c @ {\k e rn \ta b co lsep \v ru le\ex tra co lsep {\fill}}c|}\h lin e
column A & wider column B & lo n g ta b le * \\\h lin e
\end{tabular*}\par\bigskip
\begin {tab u larx}{\lin ew id th }{| 1 |X |X |}\h lin e
197
Packages
2 .2 4 d c o lu m n
The dcolumn package by David Carlisle provides formatting help for columns of numbers,
which can be aligned at the decimal point or decimal comma, dcolumn defines the D column
type for this:
TfX separator Corresponds to the separator within the TpX source and may only
be a single character. Will usually be a dot (3.1412) or a comma
(3,1242), but may also be a hyphen (3-1234).
output Corresponds to the character that is to appear as the decimal sepa
rator in the output. May be any arbitrary mathematical sequence
of characters, for example \c d o t; however, it will usually be a dot
or a comma.
number o f decimal places Defines the maximum number of decimal places. If the value is
negative, the output is centred at the separator; otherwise it is
right-aligned with the maximum number of decimal places.
number left.number right Defines the maximum number of decimal places left and right of
the separator. The two numbers may be separated by either a
comma or a dot.
dcolumn always operates in math mode, so bear this in mind when inputting separator
math mode characters and selecting the font. This also means that you can’t use the mathematical
operator $ in the columns of the table; if you do, the decimal separator w on’t be determined
correctly. The first example uses vertical lines to highlight the effect of the D column’s third
parameter.
98
2.24 dcolumn
\usepackage{dcolumn}
\begin{tabular}{| c | D {.}{,}{5 } | D { ,}{.}{-1 } | }
\textit{name}& \te x tit{ v a lu e } & \tex tit{sta n d ard form }\\\h lin e
e & 2.71828 & 0 ,271828\cdotlOA{ l } \ \ $\pi$ & 3.1416 & 0 ,31416\cdotlOA{ l } \ \
v & 0.21 & 0,21 \\ Q &0 &0
\end{tabular}
The centre column defines the dot as internal separator character, the comma as output
character, and the maximum number of decimal places as 5. The third column defines the
comma as internal separator, the dot as output, and a centred display in the table. However,
the combination o f centring with the standard form content of this third column is not
advantageous for its layout, as there is too much content after the separator for it to look
good to have the separator centred. Furthermore the “text” of the table caption for the two D
columns is typeset in italics; math mode applies here, too. This has fatal consequences for the
third column - the words are interpreted as a number and because there is no comma as a
separator, it is assumed that all the letters are leading digits and the words are place to end
immediately before the virtual separator character. The same applies to the centre column,
only the effect is not so visible. The same table with modified cells looks much better:
\usepackage{dcolumn}
\begin{tabular}{| c | D {.}{,}{5 } | | }
\textit{name}& \m u ltico lu m n {l}{c|}{\tex tit{v a lu e}}
& \m u lticolu m n {l}{c|}{\textit{stan d ard fo rm }}\\\h lin e
e & 2.71828 & 0,271828\cdotl0A{ l } \ \ $\pi$ & 3.1416 & 0,31416\cdotl0A{ l } \ \
v & 0.21 & 0,21 \\ Q &0 &0
\end{tabular}
Now the centre column looks much better. For the right column, the centring at the
decimal separator still makes it look bad because in the standard form content there is always
only one leading digit. In cases like this, it would look better if a D column was not used at all
but a normal left-aligned column used instead; however, an exception would be if you were
using a font where not all o f the digits had the same width. Of course, if you don’t use a D
column, you can’t modify the separator automatically.
99
2 Packages
\usepackage{dcolumn}
\begin{tabular}{| c | D {.}{,}{5 } | >{$}1<{$} | }
\textit{name}& \m u ltico lu m n {l}{c|}{\tex tit{v a lu e}}
& \m u lticolum n {l}{c|}{\textit{stan d ard form }}\\\h lin e
e & 2.71828 & 0,271828\cdotl0A{ l } \ \ $\pi$ & 3.1416 & 0, 31416\cdotlOA{l}\\
v & 0.21 & 0,21 \\ Q &0 &0
\end{tabular}
Use the left.right notation for the selection of decimal places if either the maximum number
of digits before and after the separator is approximately the same or you are getting problems
with the formatting otherwise. In principle it is best to define a custom column type that
references the D type. The following example shows several variants and their effect on the
layout; the vertical lines have only been added to make the effects clearer.
\usepackage{dcolumn}
\newcolumntype{d}[1 ]{D{. } { . }{#1}}
\newcommand\mc[l]{\multicolumn{l}{c|}{# 1 }}
\newcommand\Mc[1]{\m u ltico lu m n {l}{|c|}{# !}}
\begin{tab u lar}!| d { -l} | d { l} | d{2}| d {3.2}| d{5.2}|}
\Mc{d \{ - 1 \} }&\mc{d \{ 1 \} }&\mc{d \{ 2 \} }&\mc{d \{ 3 .2 \ } }&\mc{d \{ 5 .2 \}}\\\h lin e
-13.02 & -13.02 & -13.02 &-13.02 & -13.02 \ \
-13.02 & -13.02 & -13.02 &-13.02 & -13.02 \ \
-13.02 & -13.02 & -13.02 &-13.02 & -13.02 \ \
-13.02 & -13.02 & -13.02 &-13.02 &-13.02
\end{tabular}
2 .2 5 rcco l
100
2 .2 5 rcco l
rounding Rounds numerical values to the number of digits specified by the column
definition (default behaviour).
norounding No rounding.
comma Globally sets the comma as decimal separator (default behaviour). The option
german has the same effect.
p o in t Globally sets the dot as decimal separator. The options e n g lis h and
U S en glish have the same effect.
The package defines the R column type, which takes two mandatory parameters: one for
the number of digits left of the decimal separator and the other one for the number of decimal
places.
By default the package expects the comma as decimal separator. If no comma is present, the
formatting assumes that the entire number is an integer; dots are not recognized as separators
unless the option is changed. This case can be seen in the last column of the following
example; the “integer” is formatted according to the specification {3 } { 2 } and the dot simply
appended. This makes the number appear incorrectly and too far to the left in the column.
\usepackage{rccol}
\newcommand\mc[2]{\mult icolu m n {1 }{ # 1 } { \ ttfa m ily # 2 } }
R U M 5} R{ 1H 6> c R-C3H2}
2,71828 0,271828-101 IT 31416,00.
0,21000 0,210000-101 Q 03,00.
101
Packages
math R columns are not automatically typeset in math mode; this does not apply for the minus
mode jl though because the input is scanned for it. You must ensure that the numerical values
s ig n
are entered correctly; rcco l accepts almost any combination of alphanumerical characters.
You must also make sure that the last row ends with a \\. rccol automatically loads the
packages array and fltp o in t; both of these packages are usually contained in any current
TgX distribution.
2 .2 6 s iu n itx
The siu n itx package by Joseph Wright is primarily intended to display SI emits, but also
offers support for formatting decimal numbers in tables. It provides the S column type
to achieve this. Every entry in a cell is interpreted as a number by siunitx; captions or
comments must either appear as part of a command or be enclosed in curly braces. Table 2.9
shows a summary of the parameters that are of interest for tables. All the other ones are
described in the documentation of the package. [61]
\ s i s e t u p {list of parameters}
Table 2.9: Some of the possible parameters of the s iu n itx package, when used for a table ( litera l
stands for an arbitrary string).
continued...
102
2.26 siunitx
... continued
name type description
input-product Literal Multiplication s y m b o l for n u m b e r s .
input-signs Literal Sign s y m b o l for n u m b e r s .
add-decimal-zero List P a d n u m b e r s w i t h zeros.
explicit-sign Literal Sign s y m b o l for n u m b e r s .
table-alignment Type A l i g n m e n t of the table c o l u m n , valid values are
cent er , left, a n d right.
table-auto-round Boolean S w i t c h to r o u n d i n g n u m b e r s automatically to
achieve the number of digits specified by
table-format.
table-format Number S y m b o l i c specifier for decimal n u m b e r s in table
columns.
table-number-alignment List Alignment of S colu mn s, valid values are
center-decimal-marker, ce nt er , left, and
right.
table-parse-only Boolean D o not align S c o l u m n s at the decimal separator.
table-text-numbers Type A l i g n m e n t of text in S columns, possible values are
ce nter, left, a n d right.
table-unit-alignment Type A l i g n m e n t of unit s co lu mn s, possible values are
ce nt er , left, a n d r i g h t (cf. E x a m p l e 02-26-6 o n
p a g e 106).
tight-spacing Boolean R e d u c e spacing b y ±.
inter-unit-separator Literal Separator for units.
unit-value-separator Literal S p ac e b e t w e e n n u m b e r a n d unit.
use-xspace Boolean U s e the \ x s p a c e c o m m a n d f r o m the p a c k a g e of
the s a m e n a m e after a unit.
2 .2 6 .1 C o lu m n s o f n u m b e rs
C o l u m n s of n u m b e r s are aligned b y default at the decimal point such that all dots in a c o l u m n
are aligned a n d centred (first c o l u m n in the E x a m p l e 02-26-1). This case corresponds to the
pa r a m e t e r setting t a b l e - n u m b e r - a l i g n m e n t = c e n t e r - d e c i m a l - m a r k e r .
\u s e p a c k a g e {s iu n itx , booktabs}
103
2 Packages
v e r y la rg e va lu es v e r y la rg e v a lu e s v e r y la rg e v a lu e s v a lu e s
104
2.26 siunitx
A s w i th the d c o l u m n pack ag e (Section 2.24 o n p a ge 98), y o u can also align entries in a table
e v e n if th ey a r e n ’t purely numerical, for e x a m p l e 2 . 3 4 5 6 ± 0 . 0 2 for a n u m b e r w i t h error
margin. T o d o this, y o u n e e d to define the following options appropriately: g r o u p - s e p a r a t o r
for the spacing b e t w e e n the digits, o u t p u t - d e c i m a l - m a r k e r for the output decimal separator,
i n p u t - d i g i t s for the digits a n d s y mb ol s of the input, a n d i n p u t - d e c i m a l - m a r k e r s for the
input decimal separator. If the format b e c o m e s ve ry complex, it’s a g o o d idea to define a n e w
c o l u m n type b a se d o n S using \ n e w c o l u m n t y p e .
105
Packages
\u s e p a c k a g e {s iu n itx }
numbers \usepackage{booktabs}
2.3456 ± 0.02
\b e g in { ta b u la r } {
34.2345 ± 0.001
S [g ro u p -s e p a ra to r= {},
56.7835 ± 0 . 0 6 7 o u tp u t-d e c im a l-m a rk e r= {\, \p m \, } ,
90.473 ± 0 . 0 2 1 in p u t-d ig its = {0 1 2 3 4 5 6 7 8 9 . } ,
in p u t-d e c im a l-m a rk e rs = {+ }] } \t o p r u le
\em p h {n um bers}\\\m id ru le
2.3456 + 0 .0 2 \ \
34.2345 + 0 .0 0 1 \ \
56.7835 + 0.0 6 7 \ \
90 .473 + 0 .0 2 1 \\\b o tto m r u le
\e n d { ta b u la r }
2 .2 6 .2 C o lu m n s o f n u m b e rs w ith u n its
\u s e p a c k a g e {s iu n itx } \usepackage{booktabs}
value unit 02 -26-6 !
\b e g in { ta b u la r } {
2.16 x l O “ 5 m 2 s-1
S[ t a b le -fo r m a t= l. 2 e - l , ta b le -a lig n m e n t= c e n te r]
I—‘
1
to
CO
2.83 x 1 0 -6
s
s [ t a b le - u n it - a lig n m e n t = le f t ] } \t o p r u le
7.39 x 10 3 P a m 3 mol 1 {\e m p h {v a lu e }} & \e m p h { u n it} \\\m id r u le
1.0 xlO5 Pa 2 .1 6 e -5 & \m etre\sq u are d \p er\s eco n d \\
2 .8 3 e -6 & \m etre\sq u are d \p er\s eco n d \\
7.39e3 & \p a s c a l\c u b ic \m e tr e \p e r \m o le \\
1.0 e 5 & \p a s c a l \\\b o tto m r u le
\e n d { ta b u la r }
\u s e p a c k a g e {s iu n itx } \usepackage{booktabs}
value unit 02 - 26-7 I
\b e g in { ta b u la r } { S [ta b le -fo r m a t= l. 2 e - l ,
2.16 x 1 0 " 5 m 2 s-1
tab le-n u m b e r-alig n m e n t= ce n te r]@ {\kern 5 p t}
2.83 x 10-® m 2 s_1
s [ t a b le - u n it - a lig n m e n t = le f t ] } \t o p r u le
7.39 x 1 0 3 P a m 3 m o l -1 {\e m p h {v a lu e }} & \e m p h { u n it} \\\m id r u le
lO
t—
o
O
i—i
Pa
X
106
2.27 polytable
2 .2 7 p o ly ta b le
\begin{pboxed} \end{pboxed}
\begin{ptboxed} ... \end{ptboxed}
\begin{pmboxed} ... \end{pmboxed}
\ d e f a u l t c o l u m n { column type} \nodefaultcolumn
107
2 Packages
2 .2 8 ta b to
The tabto package by Donald Arseneau is available in two different versions, for plain
TeX and for ETeX. Usually the KT£X version is shipped with a TeX distribution like T£XLive;
therefore only the package named tabto can be found. The same package is called ta b to -ltx
on CTAN however. The package defines four new commands:
\tab \tabto * { le n g th }
\TabPositions{posl, p o s 2 ,. . . p o s n } \NumTabs{ m/mber}
The \tabto command lets you jump to a specific distance without explicitly having defined a
tab there. If the jump to the specified place is not possible, a line break is inserted automatically
to make it possible. Paragraph indents are considered accordingly.
A\tabto{3cm }jum p to 3 \ , c m . \ \
A long text at the beginning \m a k e b o x [3 c m ][r]{ $ \rig h ta rro w $ }\\
jump to 3 cm. A long t e x t a t th e beginning
\tabto{3cm }jum p to 3 \ , c m . \ \
\m a k e b o x [3 c m ][r]{$ \rig h ta rro w $ }
The starred version \tabto* places the tab regardless of the current position in the text;
the text in the second line in the following example is overwritten twice. In both cases, a
jump back to the specified position is performed, first to 3 cm, then to 1 cm.
A \tabto*{3cm }jum p to 3 \ , c m . \ \
A long l o s t at the begiimjng) 3 cm. \makebox[3 cm] [ r ] { $ \ r i g h t arrow $ } \ \
A long te x t a t th e beginning
\tab to*{3cm }ju m p to 3\,cm .%
\ t a b t o * { l c m } l \ , cm \\
\m a k e b o x [lc m ][r] {$ \rig h ta rro w $ }%
\m a k e b o x [2 c m ][r]{$ \rig h ta rro w $ }
108
2.29 Tabbing
You can place tabs using the two commands \TabPositions and \NumTabs. In the first
case, the argument is a comma-separated list of spaces; in the second case the argument is
the number of tabs, which are then distributed evenly across the whole line. The jump to the
next position is triggered through the \tab command. The spaces are always relative to the
default left text margin.
If a defined tab on the line is not possible with a \tab command because of the current
position in the text, the tab is automatically replaced by a line break; the following text then
starts at the beginning of the next line. The \NumTabs command is somewhat unclear; in
theory the specified number defines the number of the tabs, but the first tab is placed at the
beginning of the line at Opt and not reachable through \tab. Therefore \NumTabs{4} defines
tabs at Opt, 0.25\linewidth, 0.5\linewidth, and 0.75\linewidth. Thus the following
example produces a line break in the second line because a third tab within that single line
was not possible.
______ 1 2 3 end \usep ackag e{tab to}
1 02 -28-4 1
1 2
\NumTabs{4}
3 end \ t a b l\t a b 2 \t a b 3 \ h f i l l end\par
\NumTabs{3}
\ t a b l\t a b 2 \t a b 3 \ h f i l l end
2 .2 9 T a b b in g
The Tabbing package by Jean-Pierre F. Drucbert lets you use accents within the Tabbing
environment. This means that the \a workaround for the standard tabbing environment
is not necessary (cf. Example 01-02-4 on page 14), but instead you have to give each tab
command as an argument to the \TAB command. It is up to you to decide which method you
find less cumbersome.
The example line can be “killed” \usepackage{Tabbing}
first café \b eg in {T ab b in g }
second café The \TAB{=}example lin e \TAB{=}can
mâitre \TAB{=}be \T A B {= }“ k i l l e d ’ * \ \
crème brûlée \T A B { > } fir s t c a f \ ’ e \ \
\TAB{>}\TAB{>}second c a f \ ’ e \ \
\TA B {>}\TAB{>}\TAB {>}m \Aa i t r e \ \
\TA B {>}cr Verne
\TA B {> }\T A B {> }\T A B {> }b r\Au l \ ’ ee
\end{Tabbing}
109
2 Packages
110
C h a p t e r
C o lo u r in ta b le s
3.1 c o lo rtb l.......................................................................................................... 111
3.2 x c o lo r ............................................................................................................ 116
3.3 T^Xiiicalities............................................................................................................................. 122
With colour printers now widespread, using colours in tables is becoming more significant
- they are an additional stylistic device to make tables more readable. This chapter covers
the packages that support using colours in tables. If you want to use colour, always load the
xcolor package; it is loaded by the c o lo rtb l package anyway and its support for selecting
colours is much better.
3 .1 c o lo r tb l
The c o lo rtb l package by David Carlisle stands for “colour table” and lets you add colour to
tables in the form of coloured columns, rows, cells, or lines. The color package is required for
that and is loaded automatically. The xcolor package extends the capabilities of this package
by some additional commands. Further information can be found in Section 3.2 on page 116.
3 .1 .1 C o lu m n s
To colour columns, you must use the \columncolor command in the column definition of
the table. The command has the following syntax:
The c o lo u r m o d e l denotes one of the models defined by the color or xcolor packages, for
example rgb or cmyk (cf. Section 3.2 on page 116). For c o lo u r , you can use the predefined
3 Colour in tables
nam e of a colour, for example re d , or the colour m odel’s respective num erical values for a
colour. You can use the tw o optional argum ents, o v e r h a n g le f t and o v e r h a n g r ig h t, to make
the column wider - this only refers to the colour though and does not affect the actual width
of the column. If no overhang is specified, b o th values are set to \ta b c o ls e p . If only o n e
o verh a n g optional argum ent is given, it also automatically refers to both\ Specifying [O pt] is identical
to [O pt] [Opt] (cf. Example 03-01-7 on page 114).
\b e g in { ta b u la r} { > { \c o lu m n c o lo r{ g ra y 7 0 } } c
> { \c o lu m n c o lo r [ rg b ] { 1 , 0 , 0}}c
> { \c o lu m n c o lo r{ g ra y 9 0 } } c }
one & two & t h r e e \ \ A &B &C
\e n d { ta b u la r }
As can be seen from the above example, the whole w idth of the respective column is
coloured; the overhang defined internally defaults to adding \ t a b c o ls e p to the left and right
of the norm al w idth. If in fact you only w ant to colour the actual w idth of the text in the
column, set the overhangs to [O pt]. This is illustrated in the next example; the vertical lines
have only been added to make the effect clearer.
\b e g in { ta b u la r} { |> { \c o lu m n c o lo r { g r a y 7 0 } [ O p t] } c|
> { \c o lu m n c o lo r [ rg b ] { 1 ,0 , 0 } [O p t] } c |
> { \c o lu m n c o lo r{ g ra y 9 0 } [0 p t]} c | }
one & two & t h r e e \ \ A &B &C
\e n d { ta b u la r }
If a table is left- and right-aligned through @{}, you m ust take this into account for the
columns: there must be no overhang on the left in the first column, and similarly on the right
in the last column. This is show n in the following example:
\b e g in { ta b u la r} { @ { } > { \c o lu m n c o lo r{ g ra y 7 0 } [0 p t][ \ t a b c o l s e p ] }c
> { \c o lu m n c o lo r [ rg b ] { 1 , 0 , 0}}c
> { \c o lu m n c o lo r{ g ra y 9 0 } [\ta b c o ls e p ][O p t]} c @ { } }
one & two & t h r e e \ \ A &B &C
\e n d { ta b u la r }
112
3 .1 c o lo r t b l
3.1.2 Rows
Rows are always coloured after the colum ns have been coloured, i.e. the colour o f a row
overw rites the colour of the respective column. This results from the fact th at coloured
columns are specified in the header already. The \ro w c o lo r command colours a whole row
of a table, but you can also use the \ c e l l c o l o r command to colour individual cells of a row
(cf. Section 3.1.3 on the next page).
\ro w c o lo r has the same syntax as \c o lu m n c o lo r, but w ith different effects, \ro w c o lo r
must always be at the beginning of the first column of the particular row, and only affects that
row. \ro w c o lo r is in fact simply a concatenation of individual \c o lu m n c o lo r or \ c e l l c o l o r
commands.
113
Colour in tables
The optional argum ents of \ro w c o lo r d on’t refer to the left and right o f the row, but
as before to the columns, m aking them unusable for colouring row s effectively. In the first
table of example 03-01-5 on the preceding page \ro w c o lo r leads to a correct left margin, but
incorrect right one; it doesn’t take the final @operator into account, but simply takes the
internal value for the right overhang, which defaults to \ta b c o ls e p . The second table shows
that if the optional arguments of \ro w c o lo r are used, it affects the individual columns as well.
Only the third table shows the desired result - achieved by defining the third colum n w ith
colour w hile and optional argum ents [ \ t a b c o l s e p ] [O pt], and using \ro w c o lo r w ithout
an optional argum ent. The same w ould have to be done for the first colum n if it w ere not
coloured.
3.1.3 Cells
In the order of colouring, cells are last. Therefore they overw rite any colours for columns
and rows. In principle, the \ c e l l c o l o r com m and is only a shortcut for the \m u ltic o lu m n
command, which assumes the current column type and sets a colour through \ro w c o lo r.
\ c e l l c o l o r [colour model] { c o lo u r }
Unlike the colour commands for columns and rows, \ c e l l c o l o r doesn’t have any optional
argum ents for the overhang, but assumes the current values. W hen colouring the first cell in
a column, the \ c e l l c o l o r command m ust come after any \ro w c o lo r command.
114
3 .1 c o lo r t b l
3.1.4 Lines
Coloured vertical lines are the easiest ones to achieve - just replace the usual | operator with
! { \c o lo r { c o lo u r } \v lin e } , inserting an appropriate value for the c o lo u r.
If you create double lines, the space betw een them remains white. If you w ant this space
filled in, use a single thicker line of w idth 2 \a r r a y r u le w id th + \d o u b le r u le s e p instead, as
in the following example:
\ a r r a y r u l e c o l o r [colour model] { c o lo u r}
\d o u b le r u le s e p c o lo r [colour model] { c o lo u r }
These set the colours globally for all line types; they m ay therefore occur anyw here. They
only apply to lines after their declaration; if you insert them after the table header, they w on’t
affect the colour of the vertical lines, as shown here:
115
Colour in tables
\u s e p a c k a g e { c o lo r tb l}
| one | | two | ^ t h r e ^ l \s e tle n g th \a rra y ru le w id th { 2 p t}
1 A Im 1 c | \ a r r a y r u le c o lo r { r e d } \d o u b l e r u le s e p c o l o r { b lu e }
\u s e p a c k a g e { c o lo r tb l} -------
\s e tle n g t h \ a r r a y r u l e w i d t h { 2 p t } -0-3-0?"
\ a r r a y r u l e c o l o r { r e d } \d o u b l e r u le s e p c o lo r [ g r a y ] { 0 .6 }
The example above shows th at corners d on’t always look great, especially w hen using
\ c l i n e . The h h lin e package works better here.
3 .2 x c o lo r
The m ain difference betw een the x c o lo r package by Uwe Kern and the c o lo r package by
David Carlisle is that the latter always activates the option dvipsnam es if one of the drivers
dvips, oztex, or xdvi is chosen. This can cause problems if the docum ent is compiled w ith
pdftex, which will report undefined colours. This is why x c o lo r expects the user to explicitly
specify the option dvipsnam es if the corresponding predefined colours are to be used.
\u se p a c k a g e [ d v ip s n a m e s ,p ro lo g u e ] { x c o lo r }
The c o l o r t b l package, described in Section 3.1 on page 111, is loaded automatically by
x c o lo r if the package option t a b l e is given (cf. Table 3.1).
n a tu ra l (default) Uses all colours w ithin their model, except RGB (converted to
rgb), HSB (converted to hsb), and Gray (converted to gray).
rg b Converts all colours into the rgb model.
cmy Converts all colours into the cmy model.
cmyk Converts all colours into the cmyk model.
hsb Converts all colours into the hsb model.
g ra y Converts all colours into the gray model.
c o n t i n u e d ...
116
3.2 xcolor
... c o n tin u e d
RGB Converts all colours into the RGB model and then into the rgb model.
HTML Converts all colours into the HTML model and then into the rgb model.
HSB Converts all colours into the HSB model and then into the hsb model.
Gray Converts all colours into the Gray model and then into the gray model.
dvipsnames Loads the predefined DVIPS colours.
svgnames Loads the predefined SVG colours.
prologue Writes the list of colour names (dvipsnames) in the PostScript header;
this is important when creating documents through DVIPS.
tab le Loads the c o lo rtb l package to enable coloured table rows.
hyperref Support for hyperref.
showerrors (default) Outputs a message for undefined colours.
hideerrors Only outputs an error message if an undefined colour is used, and sets
it to black.
xcolor extends the functionality of c o lo rtb l especially when colouring alternate table
rows with different colours. The other advantage primarily concerns the definition of colours;
this is not specific to tables however and also applies to other uses. The colour models that
are supported by the current version of xcolor are summarized in Table 3.2.
117
Colour in tables
B c \ \u s e p a c k a g e [ ta b le ] { x c o lo r } ,---------
i 03 -02-1
( A
A = A BBB C \ [ \u n d e rlin e { A } =
V A * C ) \ l e f t (\b e g in { a rra y } { c > { \c o lu m n c o lo r{ m a g e n ta } } c c }
A & B & C \\
\ro w c o lo r{ c y a n } A & \ c e l l c o l o r { w h i t e } BBB & C \\
A &B & C
\e n d { a rr a y } \r ig h t) \ ]
The optional argum ent of \ro w c o lo r s lets you execute the usual commands th at are valid
here, for example \ h l i n e or \n o a lig n { ... }. The advantage of the optional argum ent is that
the execution of these com m ands can be suppressed for rows for w hich \ro w c o lo rs is not
active by using the starred version (cf. Example 03-02-7 on page 121). For alternating coloured
and uncoloured rows, you can leave one of the arguments for the colour of the odd and even
rows empty.
\u s e p a c k a g e [ t a b l e ] { x c o lo r }
03 -02-2
\r o w c o lo r s { l} { } { b lu e !30}
\ b e g i n { t a b u l a r } { |c c c ] } \ h l i n e
\m u ltic o lu m n { 3 } { |c |{ { ta b le l } \ \ \ h l i n e
A & BBB & C \ \ \ h l i n e A & B & C \ \ \ h l i n e
\e n d { ta b u la r } \ p a r \ b i g s k i p
\ r o w c o l o r s * [ \ h l i n e ] { l} { } { b lu e !30}
\ b e g i n { t a b u l a r } { |c c c |}
\m u ltic o lu m n { 3 } { |c |{ { ta b le 2 } \ \ \h id e r o w c o lo r s
A & BBB & C \\ A & B & C \\
\e n d { ta b u la r }
The following example shows an application of the simple colour commands for rows,
columns, and cells. As the individual cells only contain m athematical content, we have used
an a r r a y environment.
118
3 .2 x c o lo r
For an alternating colouring of the rows, you m ust call the \ro w c o lo rs command b e fo re
the table, w ith the appropriate arguments.
119
Colour in tables
The following tw o examples show again the use of the \ro w c o lo rs com m and and also
the m eaning of the starred version. They also dem onstrate the use o f the rownum counter,
w hich saves the num ber of the respective row internally. The rows 8-10 are not coloured;
\h id e r o w c o lo r s and \sh o w ro w c o lo rs w ere used here. The \m u ltic o lu m n com m and can
also be used to prevent colouring of individual cells. The \ a r r a y r u l e c o l o r command from
c o l o r t b l changes the colour of the lines at any tim e in the table. We defined the \No
com m and in the examples to save space; the first row o f the table uses the substitution
\num ber\rownum for comparison purposes.
column 1 row 1 \u s e p a c k a g e [ ta b l e ] { x c o lo r }
03 -02-5
column 1 row 2 \r o w c o lo r s [ \h lin e ] { 3 } { g r e e n ! 2 5 } { y e llo w ! 50}
column 1 row 3 \ a r r a y r u l e c o l o r { r e d !7 5 !gray}\newcommand*\No{\num ber\rownum}
column 1 row 4 \b e g i n { t a b u l a r } { l l }
column 1 row 5 column 1 & row \n u m b er\ro w n u m \\
column 1 row 6 column 1 & row \N o \\ column 1 & row \N o \\
column 1 & row \N o \\\ a r r a y r u l e c o l o r { b l a c k }
column 1 row 7
column 1 & row \N o \\ column 1 & row \N o \\
column 1 row 8
\ro w c o lo r{ b lu e !2 5 } column 1 & row \N o \\
column 1 row 9 \h id e ro w c o lo rs% p r e v e n t c o lo u rin g
column 1 row 10 column 1 & row \N o \\ column 1 & row \N o \\
column 1 row 11 column 1 & row \N o \\
column 1 row 12 \show row colors% c o lo u r in g : a c t i v a t e !
column 1 row 13 column 1 & row \N o \\ column 1 & row \N o \\
\m u ltic o lu m n { l} { > { \c o lu m n c o lo r{ re d !4 0 } } l} { c o lu m n 1}
& row \n u m b er\ro w n u m \\
\e n d { ta b u la r }
120
3 .2 x c o lo r
The use of the starred version o f \ro w c o lo rs now discards the optional argum ent if
the respective row is before the start row of \ro w c o lo rs or betw een \h id e ro w c o lo rs and
\sh o w ro w co lo rs. W ithout the starred version, the optional argument is considered for e v e ry
row.
column 1 row 1 \u s e p a c k a g e [ ta b l e ] { x c o lo r }
03 -02-6
column 1 row 2 \newcommand*\No{\nuraber\rownum}
column 1 row 3 \r o w c o lo r s * [ \h lin e ] { 3 } { g r e e n ! 2 5 } { y e llo w ! 50}
column 1 row 4 \ a r r a y r u l e c o l o r f r e d !7 5 !g ray }
column 1 row 5 \b e g i n { t a b u l a r } { l l }
column 1 row 6 colum n 1 & row \n u m b er\ro w n u m \\
column 1 row 7 colum n 1 & row \N o \\ column 1 & row \N o \\
column 1 & row \N o \\\ a r r a y r u l e c o l o r { b l a c k }
column 1 row 8
colum n 1 & row \N o \\ column 1 & row \N o \\
column 1 row 9
\r o w c o lo r { b lu e !25}
column 1 row 10
colum n 1 & row \N o \\ column 1 & row \N o \\
column 1 row 11 \h id e r o w c o lo r s
column 1 row 12 column 1 & row \N o \\ column 1 & row \N o \\
column 1 row 13 \sh o w ro w c o lo rs
colum n 1 & row \N o \\ column 1 & row \N o \\
\m u ltic o lu m n { l} { > { \c o lu m n c o lo r{ re d !4 0 } } l} { c o lu m n 1}
& row \N o \\
\e n d { ta b u la r }
For colouring rows, you can also use colour series. They can be defined through the
\ d e f i n e c o l o r s e r i e s com m and and increm ented through the \ro w c o lo rs com m and and
the argum ent { C S ! !+ } . Further inform ation can be found in the m anual of the x c o lo r
package. [29]
\u s e p a c k a g e [ t a b l e ] { x c o l o r }
\u s e p a c k a g e { a rra y }
\newcommand*\No{\makebox[lcm]{%
\te x tc o lo r { C L ! !+}{\num ber\rownum }}}
\d e fin e c o lo rs e r ie s { C S } { r g b } { la s t} { y e llo w } { b lu e }
\ d e f i n e c o l o r s e rie s !C L } { rg b } { la s t} { b lu e } { y e llo w }
\ r e s e t c o l o r s e r i e s ! 1 3 ] {CS}
\ r e s e t c o l o r s e r i e s [ 1 3 ] {CL}
\r o w c o lo r s [ \h lin e ] { 1 } { C S ! !+}{C S!!+}
\b e g in { ta b u la r } { c }
\N o \\ \N o \\ \N o \\ \N o \\ \N o \\
\N o \\ \N o \\ \N o \\ \N o \\ \N o \\
\N o \\ \N o \\ \No
\e n d { ta b u la r }
121
C o lo u r in t a b le s
3 .3 T[j;Xnicalities
The c o lo rtb l package provides the \arrayru lecolo r { c o lo u r } command; its effect is global.
Each change of the line colour therefore affects all following line commands, regardless of
whether \arrayrulecolor is called locally within a group. The second line typeset with
\hline in the following example is therefore red, as the first \Chline command changed the
colour globally.
However, we can define the new command to reset the colour to the default value (black)
so that changes are not global anymore, as in the following example:
\ b e g in { t a b u la r } { l r r } \ \ \ C h li n e { b l u e }
marching band & AN & 9 . 8 0 \ \ \ h l i n e
p re s e n ta tio n & AN & 8 . 6 6 \ \\ C c li n e { r e d } { l- 2 }
commity & AN & 1 3 .3 1 \\\C c lin e { b lu e } { 2 - 3 }
\e n d { ta b u la r }
b e a m e r <A ) When using the beamer class, you must pass the option tab le to the xcolor package,
which is loaded by beamer by default, either through the class option of the document class
or with the \PassOptionsToPackage command before loading the document class.
122
3.3 T g X n ic a lit ie s
i о з - о з -з :
Exam ple
C o lo u re d lin e s
Nam e T yp e V alue
m a r c h in g b an d AN 9 .8 0
p r e s e n ta t io n AN 8 .6 6
c o m m ity AN 13.31
foo d AN 1 1 .0 1
The following example shows the relations between the RGB and CMYK notation and the
Germ an so-called traffic colours, w hich are used for the traffic signs.
CMYK M
10 90 RAL 1023
traffic yellow
70 1 00 RAL2009
traffic orange
100 1 00 10 RAL 3 020 traffic red
1 00 0 10 RAL 400 6
traffic purple
20 5 40 RAL 501 7 traffic blue
10 80 RAL6 0 2 4 traffic green
10 20 40 RAL 7042
traffic grey A
10 20 RAL 7043
traffic grey B
0 RAL901 6 traffic white
90 100 RAL 901 7 traffic black
123
C o l o u r in t a b l e s
\ u s e p a c k a g e { a r r a y , b o o k ta b s , ra g g ed 2 e}
\u s e p a c k a g e [ta b le ]{ x c o lo r} \ d e f i n e c o l o r { g o ld } { r g b } { . 9 9 , 1 , . 9 }
\ d e f i n e c o l o r { lg r e y } { g r a y } { . 9 5 } \ d e f i n e c o l o r { l b l u e } { r g b } { . 9 2 , . 9 7 , 1 }
\n e w c o lu m n ty p e { C } [ l] { > { \c o lu m n c o lo r { # l} [ O p t][ \ta b c o ls e p ]\C e n te rin g $ } c < { $ } }
\new colum ntype{M }[ 2 ] { > { \c o lu m n c o lo r{ # l} [ 2 \ t a b c o l s e p ] [ 0 p t] \C e n te r in g $ } m { # 2 }<{$}}
CO
Ta belle 1 2 4 5 6 7 9 10 Yt zt
0 O o o o o o o * o o 1 —
1 O o o o o o o t * o 1 1
2 o o o o * * o t t o 2 2
CO
o o o o t * o t t o 1 0
4 o o o o t t o t t o 0 0
W hen using the b o o k ta b s package, it’s also easy to create coloured lines:
\u s e p a c k a g e [ t a b l e ] { x c o l o r }
\u s e p a c k a g e { b o o k ta b s } \ a r r a y r u l e c o l o r { r e d }
\b e g in { ta b u la r } { @ { } llr @ { } } \to p r u le
\m u ltic o lu m n { 2 } { c } { I t e m } \ \ \ c m i d r u l e ( r ) { l - 2 } \ m o r e c m i d r u l e s \ c m i d r u l e ( r ) { l - 2 }
A nim al & D e s c r i p t i o n & P r i c e ( \ $ ) \ \ \ a r r a y r u l e c o l o r { b l u e } \ c m i d r u l e ( r ) { l - l }
\c m id ru le [2 p t](l{ le m } r{ le m } ){ 2 - 2 } \c m id r u le (l) { 3 - 3 >
G nat & p e r gram & 1 3 .6 5 \ \ & ea c h & 0 . 0 1 \ \ \ a d d l i n e s p a c e [ 2 ex]
Gnu & s tu ffe d & 9 2 .5 0 \\\m id r u le Emu & s t u f f e d & 3 3 . 3 3 \ \ \ s p e c i a l r u l e { 2 p t} { le x } { le x }
A rm a d illo & f r o z e n & 8 . 9 9 \ \ \ a r r a y r u l e c o l o r { g r e e n } \ b o t t o m r u l e
\e n d { ta b u la r}
Item
12 4
C h a p t e r
M u lt i- p a g e ta b le s
Multi-page tables have to be handled differently. They can’t be part of a floating envi
ronment because these don’t allow page breaks but, on the other hand, multi-page tables
also contain captions that are typeset differently to the ones in the standard ETjnX table
environment. This chapter looks at some of the packages that can handle multi-page tables.
There is no single, best package for longer tables, but longtable is the most popular as it is
easy to use.
4 .1 lo n g ta b le
The longtable package offers many possibilities for creating tables spanning several pages.
The syntax corresponding to the normal tabular environment is the easiest case:
\end{longtable}
Specification of an optional argument for vertical alignment within a line doesn’t make sense
for longtable as it is a lw a y s typeset as a separate paragraph. So in contrast to the tabular
environment, only the horizontal alignment is important: the possible values for HPos are 1, c
(default), and r.
M u lt i- p a g e t a b le s
4 .1 .1 Page b reak
A page break for longtable is by definition only possible a fte r a table row (cf. Example 04-
automatic 01-2), not within a row. It is either inserted automatically or you can force one by inserting
page break x \newpage (cf. Example 04-01-5 on page 129). You can also prevent a potential page break at
the end of a row by inserting \\* or \nopagebreak.
The resulting layout can look bad, especially when you have uneven columns or rows, as
demonstrated in Example 04-01-2. This table consists of only three rows, but the height of the
third row is very large in comparison to the other two. The page break therefore has to be
inserted after just two rows because the third (last) row wouldnit fit onto the page. In such
extreme cases, only manual intervention helps. In this example, a page break after the last
but five line of te x t or thereabouts within the third ta b le row would make sense. In principle,
you could terminate the table row here and start a new one, so that a page break would be
inserted inbetween; however, then the last line of the third row would not be justified, as
shown in Example 04-01-3 on the facing page.
\usepackage{array, longtable}
\begin{longtable}{@{} 1 c r p{2.5cm} @{}}
1 & c & r & 1 st ro w \\\h lin e
1 & c & r & 2nd ro w \\\h lin e
1 & c & r & A row w ith a lo t of te x t th a t r e s u lts in a page break a f t e r ju s t the
second ta b le row because th e te x t included in the th ir d lin e i s too
high to f i t on th e f i r s t page. Pagebreaks are only p o ssib le between
ta b le lin e s and not in sid e a c e ll \ld o ts
\end{longtable}
126
4.1 longtable
1 c r 1st row
1 c r 2nd row 1 c r A row with a
lot of text that
results in a page
break after just
the second table
row because the
text included in
the third line is
too high to fit
on the first page.
Pagebreaks are
only possible
between table
lines and not
inside a cell...
page 1 page 2
\u s e p a c k a g e {a rra y , lo n g ta b le }
page 1 page 2
127
4 M u lt i- p a g e ta b le s
So the last row of text on the first page doesn’t appear to have been filled correctly before
the page break, due to the manual insertion of a new row to allow the page break. However,
there is a small trick with which we can stretch the last row so that manual breaks remain
invisible in the output.
The \NewLine command sets the \ p a rfills k ip length to Opt before the end of the row
of the table so that the final cell’s paragraph is not filled with whitespace and appears left and
right justified. There is no difference now to the table without this manual page break in the
output. The change is made within the table cell, which therefore doesn’t overwrite other
definitions; all table cells are put into a group such that all changes remain local. If two or
more columns have long text in the last row, requiring two or more cells to be split across the
page break, you must insert the \NewLine command for each column/cell that needs the last
line of its paragraph justified.
\u s e p a c k a g e {a rra y , lo n g ta b le }
\n e w c o m m a n d \N e w L in e {\s e tle n g th \p a rfills k ip {O p t}\ta b u la rn e w lin e }
page 1 page 2
128
4.1 longtable
A f te r a table row, you can use the normal \newpage command at any time to force a page \n e w p a g e
break:
\u s ep ac kag e {lo n g ta b le }
page 1 page 2
4 .1 .2 H o riz o n ta l a n d v e rtic a l s p a c in g
Table 4.1 on the next page shows a summary of the length parameters that can be used to
change the horizontal and vertical spacing of a longtable. The defaults depend both on the
package, and also on the used document class, which may define custom values. The values
given in the table are the ones that are generally valid, where \big skip amount is equal to
12. Opt plus 4. Opt minus 4. Opt and \f i l l is equal to 0. Opt plus 1. Ofi l l here. It is
important to assign a dynamic length to at least one of the horizontal or vertical spacings so
that the table can be typeset correctly within the text.
We recommend that you only set the horizontal spacings manually if none of the options
seem sensible - they are equivalent to the values shown in Table 4.2 on the following page. \ L T le f t
\ L T r ig h t
The arrangement demonstrated here only works as long as the width of the table is not
larger than the width of the current text line. For wider tables, it has to be saved first into a
129
4 M u lt i- p a g e t a b le s
box as a default tabular to get the width of the tabular with \wd\myTabBox. This length can
then be used accordingly to set the length \LTleft, defined internally by longtable. The
table is left-aligned by default, but this method makes other alignments possible as well (cf.
Example 04-01-6).
Usually, you won’t need to change the space before and after a longtable; the default
\ L T p r e of \bigskipamount should be sufficient already. Furthermore, the spacing is not defined to
\ L T p o s t be symmetrical before and after the table, as can be seen from the following example, which
means changing the spacing is not as simple as just modifying \LTpre and \LTpost by the
same amount. Different values must be chosen, depending on whether the text is typeset
with a paragraph indent (\parindent) or a paragraph space (\parskip), and whether with
or without table caption. The example shows, for one paragraph spacing, first the default
values and then modified values for \LTpre and \LTpost.
130
4 .1 lo n g t a b le
A l i n e o f t e x t b e f o r e th e t a b l e .
left centred right box
\b e g i n { l o n g t a b l e } { |1 |c | r |p { l . 5 c m } |} \ h l i n e
1 c r p{1.5cm}
l e f t & c e n tr e d & r i g h t & b o x \ \ \ h l i n e
1 & c & r & p \{ l.5 c m \} \\\h lin e
\e n d { lo n g ta b le }
A line of text after the table.
A l i n e o f t e x t a f t e r th e t a b l e . \ p a r
A l i n e o f t e x t b e f o r e th e t a b l e .
left centred right box \s e tle n g th \L T p re { O p t} %
1 c r p{1.5cm} \s e tle n g th \L T p o s t{ O p t} %
\b e g i n { l o n g t a b l e } { |1 | c | r | p { l . 5 c m } |} \h lin e
A line of text after the table. l e f t & c e n tr e d & r i g h t & b o x \ \ \ h l i n e
1 & c & r & p \{ l.5 c m \} \\\h lin e
\e n d { lo n g ta b le }
A l i n e o f t e x t a f t e r th e t a b l e .
I 13 1
4 M u lt i- p a g e t a b le s
\u s ep ac kag e {lo n g ta b le }
page 1 page 2
4 .1 .4 T a b le c a p tio n s
The syntax for the \caption was given in the longtable environment definition on page 131.
> The starred version suppresses the numbering and therefore an entry in the list of tables
(lot).
> If the optional argument is empty (\caption[ ] {...}), no entry is made into the list of
tables (lot).
132
4.1 longtable
> A single optional argument is added to the list of tables (lot). This is the normal
behaviour.
In general, using \c apt ion in conjunction with longtable is equivalent to using
\multicolumn, because the table caption is a part of the environment and not a separate
paragraph as it would be using the “normal” \caption command. Therefore the line has to
be terminated with \\ or \tabularnewline.
\u s ep ac kag e {lo n g ta b le }
page 1 page 2
133
4 Multi-page tables
As the \c apt ion command is in principle part of the table, it can also be inserted into
the header or footer, so that they appear repeatedly without incrementing the internal table
counter. In this context it is important that a \label command should only occur once,
\la b e l either in the first header, in the last footer, or alternatively somewhere within the actual table.
Otherwise you may get the error message: “multiply defined labels”.
\usepackage{longtable}
Text without sense before the now inserted \texttt{longtable}.
\begin{longtable}{@{}l c r p{1.5cm}@{}}
L & C & R & box\\\hline
\endfirsthead
\multicolumn{4}{@{}l}{\small\ldots\emph{continued}}\\\hline
L & C & R & box\\\hline
\endhead
\hline
\multicolumn{4}{r@{}}{\small\emph{continued on the next page} \ldots}\\
\caption{table caption}\\
\endfoot
\hline
\\[-2ex]
\caption{table caption}
\endlastfoot
1 & c &r & 1st row\\ 1 &c & r & 2nd row\\ 1 &c &r & 3rd row\\
1 & c &r & 4th row\\ 1 &c & r & 5th row\\ 1 &c &r & 6th row\\
1 & c &r &7th row\\ 1 &c & r & 8th row\\ 1 &c &r & 9th row\\
1 & c &r &10th row\\ 1 &c & r &llth row\\ 1 &c &r &12th row\\
\end{longtable}
page 1 page 2
134
4.1 longtable
When table captions are set below the table, you can sometimes get differing spaces
above the caption if lines are used in one place and not in the other. This was catered for
in Example 04-01-10 by inserting a new row for the last table caption and at the same time
reducing the space resulting from this by \\[-2ex]. You can alter the width of the table
caption using the \LTcapwidth length. The default is 4 inches, or the width of the enclosing \LTcapw idth
\parbox, which is part of the \multicolumn:
(n) is the automatically determined number of columns of the longtable and (text) is the
normal caption.
\usepackage{longtable} \setlength\LTcapwidth{lin}% <— change length
Text without sense before the now inserted \texttt{longtable}.
\begin{longtable}{@{}l c r p{l.5cm}@{}}
L & C & R & box\\\hline
\endfirsthead
\multicolumn{4}{@{}l}{\small\ldots\emph{continued}}\\\hline
L & C & R & box\\\hline
\endhead
\hline
\multicolumn{4}{r@{}}{\small\emph{continued on the next page} \ldots}
\endfoot
\endlastfoot% empty last footer, no line after caption
1 & c& r &lst row\\l & c & r & 2nd row\\l & c &r & 3rd row\\l & c & r & 4th row\\
1 & c& r &5th row\\l & c & r & 6th row\\l & c &r & 7th row\\l & c & r & 8th row\\
1 & c& r &9th row\\l & c & r &10th row\\l & c &r &llth row\\l & c & r &12th row\\\hline
\caption{Table caption with l\,inch width}\label{tab:14}
\end{longtable}
page 1 page 2
135
4 Multi-page tables
\usepackage{longtable}
\usepackage[labelfont=bf]{caption}
\setlength\LTcapwidth{2.75cm}% <--- change length
\begin{longtable}{@{}l c r p{1.5cm}@{}}
\caption{Table caption with 2.75\,cm width.\label{tab:14}}\\[5pt]
L & C & R & box\\\hline
1 & c& r &1st row\\ 1 & c & r & 2nd row\\ 1 &c & r & 3rd row\\
1 & c& r &4th row\\ 1 & c & r & 5th row\\ 1 &c & r & 6th row\\
1 & c& r &7th row\\ 1 & c & r & 8th row\\ 1 &c & r & 9th row\\
1 & c& r &10th row\\ 1 & c & r &llth row\\ 1 &c & r &12th row\\\hline
\end{longtable}
page 1 page 2
4 . 1 .5 F o o tn o te s
In a longtable environment, you can use the normal \footnote command. It also continues
the normal footnote counting. If you want a different counting used within the table, you
must set the counter before starting the table, for example using \set counter {footnote} {0}
to reset to zero. After the table, you must then set the counter back to the number it had
reached if the old counter will be used in the text again. As the footnotes appear at the bottom
of the page together with the normal footnotes, changing the counting is not really useful.
\ u s e p a ck a g e {lo n g ta b le }
A d em o \fo o tn o te {lin e o f t e x t } fo r fo o t n o t e s .
\ b e g in {lo n g ta b le }{@ {}l c r p{1.5cm }@ {}}
L \ fo o tn o te {c a p tio n } & C & R & b o x \\\h lin e
1 & c \ f o o t n o t e { f i r s t row, second column} & r & 1 s t row
136
4.1 longtable
1line of text
2caption 5eighth row, last column
3first row, second column 6eleventh row, first column
4second row, third column 7line of text
page 1 page 2
4 . 1 .6 T E X n ic a litie s...
To determine the width of the table, the package writes the required information about the \ L T ch u n k size
individual columns in the . aux file and therefore needs at least two WTjDi runs; an exception
is a “short” longtable without a page break. The number of table rows that T^X reads and
evaluates to determine the width of the columns at one time is determined by \LTchunksize
and defaults to 20 . If this value is larger than the number of table rows, T^X needs fewer
runs to determine the width. The default value is relatively small, which means that if you
set up a large number of individual headers or footers, T^X struggles to compute the table
sensibly. On modern computers, the value of \LTchunksize can be increased tenfold without
any problems. The following example shows two pages of a table that have been produced
after only one EH^X run. The log file contains a corresponding note:
137
Multi-page tables
The . aux file now contains the largest width of each of the individual columns and in
which chunk it was found:
\gdef \LT@i {\LT@entry
{2}{17.11958pt}\LT@entry
{2}{29.75977pt}\LT@entry
{2}{25. 31984pt}\LT@entry
{1}{48.67912pt}}
The largest width of the first three columns was in the second chunk and the width of the
fourth column was fixed anyway with p { l. 5cm} - its width was determined at the beginning
(chunk 1 ) already. In a consecutive run, K^pX reads these values and typesets the table, which
now has the correct column widths on each page. Only the result after the first run is shown
below for space reasons. \LTchunksize was deliberately set to the value 7 to illustrate the
effect. The first chunk consists of the table caption and the following six rows. The first three
columns in the second chunk are wider; but T^X only notices this after the page break. The
table would be typeset correctly after another ET^X run.
\usepackage{longtable} \setcounter{LTchunksize}{7}\setlength\LTcapwidth{2.75cm}
\begin{longtable}{@{}l c r p{1.5cm}@{}}
\caption{Table caption with 2.75\,cm width.\label{tab:14}}\\[5pt]
L & C & R & box\\\hline 1 & c & r & lst\\ 11 & c & r & 2nd\\ 1 & c & r & 3rd\\
1 & c & r & 4th\\ 111 & c & rr & 5th\\ 1 & cc & r & 6th\\ 1 &c & r & 7th\\
1111 & c & r r r & 8th row \\ 1 & ccc & r & 9th row \\ 1 & c & r &10th row\\
1111 & c & r r r r &llth row\\ 1 & cccc & r &12th row\\\hline
\end{longtable}
This example was only run once through \LaTeX. This is the reason why the
table isn ’t typeset correctly.
page 1 page 2
138
4.2 ltablex
You can’t use the \n ofiles option in conjunction with longtable, as it would prevent
the output of the auxiliary files and thus the output of the auxiliary information, which ^ . auxfile
longtable requires for calculating the width of the table. When using the \multicolumn
command, several runs may be necessary until TpX has determined the correct width, \multicolumn
Further information on this can be found in the package documentation. [17]
You can use the \ k ill command to delete an example row that has been used to determine
the table columns. Example rows, discussed in the tabbing environment (cf. Section 1.2 on
page 12 ), can sometimes be helpful when creating centred or right-aligned columns of a fixed
width.
\usepackage{longtable}
\begin{longtable}{@{}l c r p{1.5cm}@{}}
L & XXXX & right & p \kill
L & C&R & box\\\hline
1 & c&r & lst\\ 11 & c & r &2nd\\ 1 & c & r & 3rd\\
1 & c&r &4th\\ 111 & c & rr & 5th\\ 1 & cc & r & 6th\\
1 & c&r & 7th\\ 1111 & c &rr r & 8th row\\ 1 & ccc & r &9th row\\
1 & c&r &10th row\\ 1111 & c &r r rr &llth row\\ 1 & cccc & r &12th row\\\hline
\end{longtable}
page 1 page 2
4.2 lt a b le x
The lta b le x package by Anil K. Goel extends the ta b u la rx environment with possible page
breaks. In contrast to the similar ltx ta b le package (cf. Section 4.3 on page 141 ), no external
files are required; the table can be used in the usual manner. Captions are possible, too.
139
4 Mufti-page tables
...\\
\end{tabularx}
The package works similarly to the well-known longtable (cf. Section 4.1 on page 125)
package, and therefore needs at least two DIp;X runs to determine the correct width of the
columns.
\usepackage{ltablex}
\usepackage{ragged2e}
\begin{tabularx}{\linewidth}{@{}>{\ttfamily}l>{\RaggedRight}X@{}}
\caption{File extensions. }\\
aux & (auxiliary) Auxiliary file , contains links etc. \\
bbl & (bibliography) Auxiliary file , contains the entries for the bibliography.\\
bib & (bibtex) Contains the literature database.\\
big & (bibliography log) Contains the output of a Bib\TeX\ run.\\
cfg & (config) Configuration file.\\
clo & (class options) Definitions for the document class and the corresponding
class options.\\
els & (class) Document class file.\\
\end{tabularx}
page 1 page 2
The specification of headers and footers is the same as for the longtable package (cf.
Section 4.1.3 on page 131).
140
4.3 ltxtable
\usepackage{ltablex,ragged2e}
\begin{tabularx}{\linewidth}{@{}>{\ttfamily}l>{\RaggedRight}X@{}}
\caption*{File extensions. }\\
.ext & description\\\hline
\endfirsthead
\multicolumn{2}{@{}l}{\ldots\ \small continued}\\\hline
.ext & description\\\hline
\endhead
\hline
\multicolumn{2}{r@{}}{\small continued\ldots}\\
\endfoot
\hline
\endlastfoot
aux & (auxiliary) Auxiliary f ile , contains links etc. \\
bbl & (bibliography) Auxiliary f ile , contains the entries for the bibliography.\\
bib & (bibtex) Contains the literature database.\\
big & (bibliography log) Contains the output of a Bib\TeX\ run.\\
cfg & (config) Configuration file.\\
clo & (class options) Definitions for the document class and the corresponding
class options.\\
\end{tabularx}
page 1 page 2
4.3 lt x t a b l e
The ltx ta b le package by David Carlisle unites the features of tabularx and longtable,
hence the name of the package. In contrast to those packages, the table has to be saved as an
141
4 Multi-page tables
external file; the easiest way to achieve this is through the file co n te n ts environment.
\small\verbatiminput{demoFile.tex}
This is written during the Tjÿi run and can be read back in immediately afterwards. The starred
file c o n t e n t s version suppresses the output of commented lines (cf. Example 04-03-1). The file co n te n ts
environment environment may only be used in the preamble and not in the text body and never overwrites
existing files. You should also load the file co n te n ts package of the same name; this saves
having to delete the external file if the contents change.
You can’t use the file c o n te n ts environment at the current position in the text; this is a
restriction for longer documents - it is harder to keep the overview over the text. If you have
several such tables, use separate files and read them through \input{/i/e} in the preamble or
make a completely separate file without using the file c o n te n ts environment.
The syntax of a “tabularx-longtable” is also a combination of the two. The outer form
corresponds to tabularx and the inner to longtable. The file is read through the \LTXtable
command. In Example 04-03-2, the file is saved as part of the preamble and written to disk
during the E^X run.
\usepackage{ltxtable,filecontents,ragged2e}
\begin{f ilecontentsKLTXtabO. tex}
\begin{longtable}{@{}>{\ttfamily}l>{\RaggedRight}X@{}}
\caption{File extensions and their meaning.}\\
aux & (auxiliary) Auxiliary file , contains links etc. \\
bbl & (bibliography) Auxiliary file , contains the entries for the bibliography. \\
bib & (bibtex) Contains the literature database.\\
big & (bibliography log) Contains the output of a Bib\TeX\ run.\\
cfg & (config) Configuration file.\\
clo & (class options) Definitions for the document class and the corresponding
class options.\\
els & (class) Document class file.\\
\end{longtable}
\end{filecontents}
142
4.3 ltxtable
\LTXtable{\linewidth}{LTXtabO}
\LTXtable d e m o \LTXtable d e m o
page 1 page 2
The external file is identical to a longtable apart from being able to use the X column
type as well. The behaviour of footnotes is significantly different however; they are still footn ote
possible, but require special attention.
> Within the normal longtable environment, the footnote symbols must be set with
\footnotemark (cf. Example 04-03-3); they are counted as usual. If you want it to start at
one in the table, you must reset the footnote counter before the table starts.
> Outside the table, i.e. after inserting it into the text through \ltablex, the footnote counter
must be decreased by the number of inserted \f ootnotemarks; four in Example 04-03-3 -
\addtocounter { footnote} { -4 } .
> The actual footnotes are specified through
\stepcounter{footflote}\footnotetext{texi}.
The counter must be incremented manually through \stepcounter. The number of the
footnote could also be specified through the optional argument \f ootnotetext [number] { text},
but this needs to be changed manually every time a new footnote is inserted before the
table because the numbering changes.
> The footnotes always appear a fter the table, i.e. potentially several pages after the corre
sponding number.
143
4 Multi-page tables
\usepackage{ltxtable,filecontents}
\begin{filecontents}{LTXtabl.tex}
\begin{longtable}{@{}>{\ttfamily}l>{\raggedright\arraybackslash}X@{}}
aux \footnotemark& (auxiliary) Auxiliary file , contains links, refs, etc. \\
bbl \footnotemark& (bibliography) Auxiliary file , contains the
entries for the bibliography.\\
cfg & (config) Configuration file.\\
clo \footnotemark& (class options) Definition file for the document class
and the corresponding class options.\\
els \footnotemark& (class) Document class file , e.g. \texttt{book.els}.\\
\end{longtable}
\end{filecontents}
\rule{lcm}{0.5pt}\hfill text width\footnote{start}\hfill\rule{lcm}{0.5pt}
\f ootnote d e m o \f ootnote de m o
page 1 page 2
144
4.4 stabular
4.4 sta b u la r
The stabular package by Sigitas Tolusis is part of the s tto o ls and extends the internal fflgX
tabular and array environments so that they may contain a page break. Additionally, two
similar environments and two new commands are defined. The two environments have the
same syntax as the ones in standard ETeX, but are prefixed with an “s”.
\begin{st abular}
\end{stabular}
\begin{ st abular * }{ width}
\end{stabular*}
\emptyrow [length] \tabrow{ Text} [height]
The \emptyrow command creates an empty table row of height zero with optional line feed
(vertical space after the row); \tabrow creates a row of normal height of the argument, but
also with optional line feed. Both commands must be last in a table row; the argument of
\tabrow is usually only used to determine the height of the respective table row. Line breaks
with an optional \hline are of course allowed afterwards.
To make the effect of the \emptyrow and \tabrow commands obvious, both have been
used with and without optional line feed in the following example. The non-existent line feed
results in row 2 “missing”.
\usepackage{stabular}
A normal \texttt{stabular} environment, containing a page break, which cannot be
centred.
145
4 Multi-page tables
\begin{stabular}{@{}p{0.55\linewidth} r@{}}
\emph{country} & \emph{entry}\\\hline
Egypt & 30.06.1995W Albania & 08.09.2000 \\
Angola & 23.11.1996W Antigua and Barbuda& 01.01.1995 \\
Antilles & 2 1.0 1.1996\\ Arab Emirates & 10.04.1996 \\
Argentina & 01.01.1995W Armenia & 05.02.2003\\Australia & 01.01.1995W
Bahrain & 01.01.1995W Bangladesh & 01.01.1995\\Barbados& 01.01.1995W
Belgium & 01.01.1995W Belize & 01.01.1995 \\
\end{stabular}
\end{center}
page 1 page 2
The example clearly shows some advantages and disadvantages of the stabular envi
ronment. Its simplicity to use is an advantage: the only difference to the standard ETpX
environment is the “sMprefix. However, being unable to centre the environment and to define
intermediate headers and footers are disadvantages. The reason is the internal definition of
the environment; it doesn’t write its contents into a box to be able to determine the width of
the table. This can’t be rectified by using a minipage because that may not contain a page
break. Through some trial and error and an empty p column, an according left indentation
can be achieved, as can be seen in the following example. The first (empty) column is defined
by p { l. 5em}.
\usepackage{stabular}
A normal \texttt{stabular} environment, containing a page break, which cannot be
centred automatically.
146
4.4 stabular
stabular d e m o stabular d e m o
04-04-3
page 1 page 2
A table across the whole width of the page is no problem; the stabular* environment
is similar to tabular*. However, in these cases it actually makes more sense to use the
tabularx environment or the \LTXtable command, as they increase the width of the column
while the starred version of stabular just increases the space between two columns (cf.
Section 1.1 on page 5).
\usepackage{stabular}
A normal \texttt{stabular} environment, containing a page break, which w ill
extend across the whole width of the page.
147
4 Multi-page tables
page 1 page 2
If, for some reason, you can’t use either of the other packages for tables with page breaks,
but headers and footers are required on each page, you can insert them after typesetting the
table. In the example above, “Australia” was in the last row on the first page; therefore it can
be replaced by a footer.1
\usepackage{stabular}
A normal \texttt{stabular} environment, containing a page break, which w ill
extend across the whole width of the page.
148
4.5 supertabular
page 1 page 2
4.5 supertabular
The main difference between the supertabular package by Johannes Braams and Theo
Jurriens and the longtable package (cf. Section 4.1 on page 125) is the syntax; for a
supertabular, all captions, headers, and footers have to be specified outside the actual
table, supertabular can be loaded with the options listed in Table 4.3.
The new supertabular and supertabular* environments have the same syntax as the
general tabular and tabular* environments. The mpsupertabular and mpsupertabular*
environments behave similarly to the environments without the “mp” prefix, which stands for
minipage. The “mp” versions have the advantage that footnotes are definitely counted and
output page-wise; cf. Section 4.5.4 on page 155.
149
4 Multi-page tables
\begin{supertabular}{co/wmn definition }
\end{supertabular}
\begin{supertabular*}{iaWe 'width}{column definition }
\end{supert abular*}
\begin{mpsupertabular}{colum n definition}
\end{mpsupertabular}
\begin{mpsupertabular*}{table width}{column definition}
\end{mpsupertabular*}
\usepackage[pageshow]{supertabular}
\begin{center}\begin{supertabular}{@{}l r@{}}
\emph{country} & \emph{entry}\\\hline
Egypt & 30.06.1995 \\ Albania & 08.09.2000 \\
Angola & 23.11.1996 \\ Antigua and Barbuda & 01.01.1995 \\
Antilles & 21.01.1996 \\ Arab Emirates & 10.04.1996 \\
Argentina &01.01.1995 \\ Armenia & 05.02.2003 \\
Australia & 01.01.1995 \\ Bahrain & 01.01.1995 \\
Bangladesh & 01.01.1995 \\ Barbados & 01.01.1995 \\
Belgium & 01.01.1995 \\ Belize & 01.01.1995 \\
Benin & 22.02.1996 \\
\end{supertabular}\end{center}
page 1 page 2
150
4.5 supertabular
The last row of the table m ust be terminated with a line end command, either \\ or
\tabularnewline; otherwise Tj?X will give an error message. The example above already ^ last row;
shows a disadvantage of the supertabular environment; the parts of the table can have table wu
different widths on different pages. In contrast to the longtable environment, no information
is written to the . aux file that could be evaluated for the following pages. To avoid this effect,
either insert a header or footer or use the starred version. The starred version has the
advantage that the ltx ta b le package (cf. Section 4.3 on page 141) does not have to be used,
but the disadvantage that the corresponding column has to be filled manually (cf. Section 1.1
on page 3). To achieve this, the array package must be loaded in this case because otherwise
the column separator ! is unknown and the \extracolsep command can’t be used.
\usepackage{array,supertabular}
\begin{supertabular*}{\linewidth}{@{}l!{\extracolsep{\fill}} r@{}}
\emph{country} & \emph{entry}\\\hline
Egypt & 30.06.1995 \\ Albania & 08.09.2000 \\
Angola & 23.11.1996 \\ Antigua and Barbuda & 01.01.1995 \\
Antilles & 21.01.1996 \\ Arab Emirates & 10.04.1996 \\
Argentina & 01.01.1995 \\ Armenia & 05.02.2003 \\
Australia & 01.01.1995 \\ Bahrain & 01.01.1995 \\
Bangladesh & 01.01.1995 \\ Barbados & 01.01.1995 \\
Belgium & 01.01.1995 \\ Belize & 01.01.1995 w
Benin & 22.02.1996 \\
\end{supertabular*}
page 1 page 2
151
4 Multi-page tables
4 .5.1 P age b r e a k
super tabular determines the remaining space on the page after each row and inserts a
page break if required. In some cases this is not optimal, however, as shown in the previous
examples. You can use the \shrinkheight command to increase or decrease the comparison
value for the page. The command must be at the beginning of a row and may be given
arbitrary lengths and units. In the following example, the page is extended by three lines at
the beginning of the table (first row) already to achieve a better page break. If this value were
further decreased, however, an empty page would occur as TpX would move the block, which
would then be too large, to the next page. A positive value assigned to \shrinkheight would
instead shrink the page so that the page break would occur earlier.
\usepackage{array,supertabular}
\begin{supertabular*}{\linewidth}{@{}l!{\extracolsep{\fill}} r@{}}
\emph{country} & \emph{entry}\\\hline \shrinkheight{-3\normalbaselineskip}
Egypt & 30.06.1995 \\ Albania & 08.09.2000 \\
Angola & 23.11.1996 \\ Antigua and Barbuda & 01.01.1995 \\
Antilles & 21.01.1996 \\ Arab Emirates & 10.04.1996 \\
Argentina & 01.01.1995 \\ Armenia & 05.02.2003 \\
Australia & 01.01.1995 \\ Bahrain & 01.01.1995 \\
Bangladesh & 01.01.1995 \\ Barbados & 01.01.1995 \\
Belgium & 01.01.1995 \\ Belize & 01.01.1995 \\
Benin & 22.02.1996 \\
\end{supertabular*}
page 1 page 2
152
4.5 supertabular
4 .5 .2 H ea d er s a n d fo o te r s
All specifications must be done before the table itself. The following commands can be used:
All d e f in itio n s must correspond to at least one table row each and may contain a \hline
in the simplest case. If \ tab lefirsth ead or \ t a b le la s tta il are not defined, they are
automatically substituted by \tablehead and \ ta b le ta il respectively.
\usepackage{supertabular}
\tablefirsthead{\hline \emph{country} & \emph{entry}\\\hline}
\tablehead{\emph{country} & \emph{entry}\\\hline}
\tabletail{\hline \multicolumn{2}{r@{}}{continued \ldots}\\}
\tablelasttail{\hline}
\begin{center} \begin{supertabular}{@{}p{0.55\linewidth} r@{}}
Egypt & 30.06.1995 \\ A lb a n ia & 08.09.2000 \\
Angola & 23.11.1996 \\ A n tigu a and Barbuda & 01.01.1995 \\
Antilles & 21.01.1996 \\ Arab Em irates & 10.04.1996 \\
Argentina & 01.01.1995 \\ Armenia & 05.02.2003 \\
Australia & 01.01.1995 \\ Bahrain & 01.01.1995 \\
Bangladesh & 01.01.1995 \\ Barbados & 01.01.1995 \\
Belgium & 01.01.1995 \\ B e liz e & 01.01.1995 \\
Benin & 22.02.1996 \\
\end{supertabular} \end{center}
page 1 page 2
153
4 Multi-page tables
4 .5 .3 T ab le c a p tio n s
There are three different commands to add captions:
The optional argument LOT entry replaces the default entry of text into the table of contents
(.toe) if used. When using \tablecaption, the document class determines the position of
the label by specifying either \@topcaptionfalse or \@topcaptiontrue. This specification
can be overwritten at any time, however, by using one of the other two commands, which
force the caption to be above or below the table, respectively. The caption package also
supports the super tabular package.
\usepackage{supertabular} \usepackage[labelfont=bf]{caption}
\tablecaption{Demonstration of a table caption.}
\tablefirsthead{\hline \emph{country} & \emph{entry}\\\hline}
\tablehead{\emph{country} & \emph{entry}\\\hline}
\tabletail{\hline \multicolumn{2}{r@{}}{continued \ldots}\\} \tablelasttail{\hline}
\begin{center}\begin{supertabular}{@{}p{0.55\linewidth} r@{}}
Egypt & 30.06.1995W Albania & 08.09.2000\\Angola & 23.11.1996W
Antigua and Barbuda& 01.01.1995\\Antilles& 21.01.1996\\Arab Emirates & 10.04.1996W
Argentina & 01.01.1995W Armenia & 05.02.2003\\Australia &01.01.1995\\
Bahrain & 01.01.1995W Bangladesh & 01.01.1995\\Barbados &01.01.1995W
Belgium & 01.01.1995W Belize & 01.01.1995\\Benin &22.02.1996W
\end{supertabular}\end{center}
page 1 page 2
154
4.5 supertabular
4 .5 .4 F o o tn o te s
If you use footnotes within the normal supertabular environment, they appear as a sym
bol in the table, but the text of the footnote is missing. Therefore \footnotemark and
\f ootnotetext have to be used separately again, as shown in Example 04-03-3 on page 143.
\usepackage{supertabular}
\tablefirsthead{\hline \emph{country} & \emph{entry}\\\hline}
\tablehead{\emph{country} & \emph{entry}\\\hline}
\tabletail{\hline \multicolumn{2}{r@{}}{continued \ldots}\\}
\tablelasttail{\hline}
Text\footnote{before the text} and footnote.
\begin{center}\begin{supertabular}{@{}p{0. 55\linewidth} r@{}}
Egypt\footnotemark &30.06.1995 \\ Albania & 08.09.2000\\Angola & 23.11.1996W
Antigua and Barbuda &01.01.1995 \\ Antilles\footnotemark & 21.01.1996 \\
Arab Emirates &10.04.1996 \\ Argentina & 01.01.1995\\Armenia & 05.02.2003W
Australia &01.01.1995 \\ Bahrain & 01.01.1995 \\
Bangladesh &01.01.1995 \\ Barbados & 01.01.1995 \\
Belgium &01.01.1995 \\ Belize\footnotemark & 01.01.1995 \\
\end{supertabular}\addtocounter{footnote}{-3}
\stepcounter{footnote}\footnotetext{first footnote}
\stepcounter{footnote}\footnotetext{second footnote}
\stepcounter{footnote}\footnotetext{third footnote}
\end{center}
Text\footnote{after the text} and footnote.
page 1 page 2
155
4 Multi-page tables
This has the disadvantage that the footnotes all appear together after the table, which can
be bad for large tables where there are several pages between footnote mark and corresponding
text. It is better therefore to use the mpsupertabular environment as long as no other
footnotes (apart from the table footnotes) appear on the first or last page of the table. Within
the minipage, the footnotes are typeset with a footnote rule immediately after the table and
are counted with letters. As can be seen in the following example, this results in a clear
differentiation, but the appearance is unsatisfactory. The footnotes immediately before and
after the table should be removed.
\usepackage{supertabular}
\tablefirsthead{\hline \emph{country} & \emph{entry}\\\hline}
\tablehead{\emph{country} & \emph{entry}\\\hline}
\tabletail{\hline \multicolumn{2}{r@{}}{continued \ldots}\\} \tablelasttail{\hline}
Text\footnote{before the text} and footnote.\par\bigskip
\begin{mpsupertabular}{@{}p{0.55\linewidth} r@{}}
Egypt\footnote{first foonote}& 30.06.1995 \\ Albania & 08.09.2000 \\
Angola & 23.11.1996 \\ Antigua and Barbuda & 01.01.1995 \\
Antilles\footnote{second footnote}& 21.01.1996 \\ Arabian Emirates & 10.04.1996 \\
Argentina & 01.01.1995 \\ Armenia &05.02.2003 \\
Australia & 01.01.1995 \\ Bahrain &01.01.1995 \\
Bangladesh & 01.01.1995 \\ Barbados &01.01.1995 \\
Belgium & 01.01.1995 \\ Belize\footnotefthird footnote} & 01.01.1995 \\
\end{mpsupertabular}\par\bigskip
Text\footnote{after the text} and footnote.
\usepackage{supertabular}
\tablefirsthead{\hline \emph{country} & \emph{entry}\\\hline}
\tablehead{\emph{country} & \emph{entry}\\\hline}
\tabletail{\hline \multicolumn{2}{r@{}}{continued \ldots}\\}
\tablelasttail{\hline}
156
4.6 xtab
supertabular d e m o supertabular d e m o
page 1 page 2
4.6 xtab
The xtab package by Peter Wilson is an extension of the super tabular package (cf. Sec
tion 4.6). It is meant to provide better functionality especially regarding page breaks. The
syntax is in principle the same as for the environments from super tabular. The use of
the xtabular and xtabular* environments is otherwise completely identical to the usual
tabular and tabular* environments. The mpxtabular and mpxtabular* environments are
likewise similar to the environments without the mp prefix, which stands for minipage. This
has the advantage that footnotes can be counted and output per page, cf. Section 4.5.4 on
page 155.
157
4 Multi-page tables
\end{xtabular}
\begin{xtabular* }{ table width}{column definition}
\end{xtabular*}
\begin{mpxtabular}{ co/wmn definition}
\end{mpxt abular}
\begin{mpxtabular*}{taWe width}{column definition}
\end{mpxtabular*}
\usepackage{xtab}
\begin{center}\begin{xtabular}{@{}l r@{}}
\emph{country} & \emph{entry}\\\hline
Egypt & 30.06.1995W Albania & 08.09.2000\\Angola & 23.11.1996W
Antigua and Barbuda & 01.01.1995\\Antilles& 21.01.1996\\Arab Emirates & 10.04.1996W
Argentina &01.01.1995W Armenia &05.02.2003\\Australia &01.01.1995W
Bahrain &01.01.1995W Bangladesh &01.01.1995\\Barbados &01.01.1995\\
Belgium &01.01.1995W Belize &01.01.1995\\Benin &22.02.1996W
\end{xtabular}\end{center}
page 1 page 2
la s t ro w The last row of the table m ust be terminated with a line end command, either \\ or
ta b le w id th x . \tabular newline; otherwise you will get an error message. The example above already
shows one of the disadvantages of the xtab package; the parts of the table can have different
158
4.6 xtab
\usepackage{array,xtab}
\begin{xtabular*}{\linewidth}{@{}l!{\extracolsep{\fill}} r@{}}
\emph{country} & \emph{entry}\\\hline
Egypt & 30.06.1995 \\ Albania & 08.09.2000 \\
Angola & 23.11.1996 \\ Antigua and Barbuda & 01.01.1995 \\
Antilles & 21.01.1996 \\ Arab Emirates & 10.04.1996 \\
Argentina & 01.01.1995 \\ Armenia & 05.02.2003 \\
Australia & 01.01.1995 \\ Bahrain & 01.01.1995 \\
Bangladesh & 01.01.1995 \\ Barbados & 01.01.1995 \\
Belgium & 01.01.1995 \\ Belize & 01.01.1995 \\
Benin & 22.02.1996 \\
\end{xtabular*}
page 1 page 2
4 .6 .1 P age b r e a k
xtabular determines the remaining space on the page after each row and inserts a page break
if required. In some cases this is not optimal, however, as shown in the previous example. You
159
4 Multi-page tables
can use the \shrinkheight command to increase or decrease the comparison value for the
page.
\shrinkheight { length}
The command m ust be at the beginning of a row and may be given arbitrary lengths and
units. In the following example, the page is extended by three lines at the beginning of the
table (first row) already to achieve a better page break. If this value were further decreased,
however, an empty page would occur as TgX would move the block, which would then be too
large, to the next page. A positive value assigned to \shrinkheight would instead shrink
the page so that the page break would occur earlier.
\usepackage{array,xtab}
\begin{xtabular*}{\linewidth}{@{}l! {\extracolsep{\fill}} r@{}}
\emph{country} & \emph{entry}\\\hline
\shrinkheight{-3. l\normalbaselineskip}
Egypt & 30.06.1995 \\ Albania & 08.09.2000 \\
Angola & 23.11.1996 \\ Antigua and Barbuda & 01.01.1995 \\
Antilles & 21.01.1996 \\ Arab Emirates & 10.04.1996 \\
Argentina & 01.01.1995 \\ Armenia & 05.02.2003 \\
Australia & 01.01.1995 \\ Bahrain & 01.01.1995 \\
Bangladesh & 01.01.1995 \\ Barbados & 01.01.1995 \\
Belgium & 01.01.1995 \\ Belize & 01.01.1995 \\
Benin & 22.02.1996 \\
\end{xtabular*}
page 1 page 2
160
4.6 xtab
4 .6 .2 H ea d er s a n d fo o te r s
All specifications must be done before the table itself. The following commands can be used:
All definitions must correspond to at least one table row each and may contain a \hline
in the simplest case. If \ tab lefirsth ead or \ t a b le la s tta il are not defined, they are
automatically substituted by \tablehead and \ ta b le ta il respectively.
\usepackage[table]{xcolor} \usepackage{xtab}
\tablefirsthead{\hline \emph{country} & \emph{entry}\\\hline}
\tablehead{\emph{country} & \emph{entry}\\\hline}
\tabletail{\hline \multicolumn{2}{r@{}}{continued \ldots}\\}
\tablelasttail{\hline}
\begin{center}
\begin{xtabular}{@{}p{0.55\linewidth} r@{}}
Egypt & 30.06.1995 \\ Albania & 08.09.2000 \\
Angola & 23.11.1996 \\ Antigua and Barbuda & 01.01.1995 \\
Antilles & 21.01.1996 \\ Arab Emirates & 10.04.1996 \\
Argentina & 01.01.1995 \\ Armenia & 05.02.2003 \\
Australia & 01.01.1995 \\ Bahrain & 01.01.1995 \\
Bangladesh & 01.01.1995 \\ Barbados & 01.01.1995 \\
Belgium & 01.01.1995 \\ Belize & 01.01.1995 \\
Benin & 22.02.1996 \\
\end{xtabular}
\end{center}
page 1 page 2
161
Multi-page tables
4 .6 .3 T ab le c a p tio n s
The xtab package also has three different commands to set captions:
The optional argument LOT entry substitutes the default entry of text into the table of contents
if used. When using \tablecaption, the document class determines the position of the label
by specifying either \@topcaptionf alse or \@topcaptiontrue. This specification can be
overwritten at any time, however, by using one of the other two commands, which force the
caption to be above or below the table, respectively. The caption package supports the xtab
package with all its functionality.
\usepackage{xtab} \usepackage[labelfont=bf]{caption}
\tablecaption{Demonstration of a table caption.}
\tablefirsthead{\hline \emph{country} & \emph{entry}\\\hline}
\tablehead{\emph{country} & \emph{entry}\\\hline}
\tabletail{\hline \multicolumn{2}{r@{}}{continued \ldots}\\}
\tablelasttail{\hline}
\begin{xtabular}{@{}p{0.55\linewidth} r@{}}
Egypt & 30.06.1995W Albania & 08.09.2000\\Angola & 23.11.1996W
Antigua and Barbuda & 01.01.1995\\Antilles& 21.01.1996\\Arab Emirates & 10.04.1996W
Argentina & 0 1.0 1.1995\\ Armenia &05.02.2003\\Australia & 01.01.1995W
Bahrain & 0 1.0 1.1995\\ Bangladesh &01.01.1995\\Barbados & 01.01.1995W
Belgium & 01.01.1995W Belize &01.01.1995\\Benin & 22.02.1996\\
\end{xtabular}
page 1 page 2
162
4.6 xtab
4 .6 .4 F o o tn o te s
In principle, Section 4.5.4 on page 155 applies here as well. Again you have to use the footnote
commands \footnotemark and \footnotetext, as already shown in Example 04-03-3 on
page 143.
\usepackage{xtab}
\tablefirsthead{\hline \emph{country} & \emph{entry}\\\hline}
\tablehead{\emph{country} & \emph{entry}\\\hline}
\tabletail{\hline \multicolumn{2}{r@{}}{continued \ldots}\\}
\tablelasttail{\hline}
Text\footnote{before the table} and footnote.\par
\begin{xtabular}{@{}p{0.55\linewidth} r@{}}
Egypt\footnotemark & 30.06.1995 \\ Albania & 08.09.2000 \\
Angola & 23.11.1996 \\ Antigua and Barbuda & 01.01.1995 \\
Antilles\footnotemark& 21.01.1996 \\ Arab Emirates & 10.04.1996 \\
Argentina & 01.01.1995 \\ Armenia & 05.02.2003 \\
Australia & 01.01.1995 \\ Bahrain & 01.01.1995 \\
Bangladesh & 01.01.1995 \\ Barbados & 01.01.1995 \\
Belgium & 01.01.1995 \\ Belize\footnotemark & 01.01.1995 \\
\end{xtabular}
\addtocounter{footnote}{-3}
\stepcounter{footnote}\footnotetext{first footnote}
\stepcounter{footnote}\footnotetext{second footnote}
\stepcounter{footnote}\footnotetext{third footnote}
Text\footnote{after the table} and footnote.
page 1 page 2
163
Multi-page tables
This has the disadvantage that the footnotes all appear together at the end of the table -
for long tables, there can be several pages between the footnote mark and the footnote text. It
is better therefore to use the mpxtabular environment as long as no other footnotes (apart
from the table footnotes) appear on the first or last page of the table. Within the minipage,
the footnotes are typeset with their own footnote rule immediately after the table and are
counted with letters. As shown in the following example, this provides a clear distinction,
but the the appearance is unsatisfactory. The footnotes immediately before or after the table
should be omitted.
\usepackage{xtab}
\tablefirsthead{\hline \emph{country} & \emph{entry}\\\hline}
\tablehead{\emph{country} & \emph{entry}\\\hline}
\tabletail{\hline \multicolumn{2}{r@{}}{continued \ldots}\\}
\tablelasttail{\hline}
Text\footnote{before the table} and footnote.
\begin{center}
\begin{mpxtabular}{@{}p{0.55\linewidth} r@{}}
Egypt\footnote{first footnote} & 30.06.1995 \\ Albania & 08.09.2000 \\
Angola & 23.11.1996 \\ Antigua and Barbuda & 01.01.1995 \\
Antilles\footnote{second footnote}& 21.01.1996 \\ Arab Emirates & 10.04.1996 \\
Argentina & 01.01.1995 \\ Armenia & 05.02.2003 \\
Australia & 01.01.1995 \\ Bahrain & 01.01.1995 \\
Bangladesh & 01.01.1995 \\ Barbados & 01.01.1995 \\
Belgium & 01.01.1995 \\ Belize\footnote{third footnote} & 01.01.1995 \\
\end{mpxtabular}
\end{center}
Text\footnote{after the table} and footnote.
“second footnote
page 1 page 2
164
4.6 xtab
\usepackage{xtab}
\tablefirsthead{\hline \emph{country} & \emph{entry}\\\hline}
\tablehead{\emph{country} & \emph{entry}\\\hline}
\tabletail{\hline \multicolumn{2}{r@{}}{continued \ldots}\\}
\tablelasttail{\hline}
Text without footnote.
\medskip
\begin{mpxtabular*}{\linewidth}{@{}p{0.55\linewidth} @{\extracolsep{\fill}} r@{}}
EgYPt\footnote{first footnote} & 30.06.1995 \\ Albania & 08.09.2000 \\
Angola & 23.11.1996 \\ Antigua and Barbuda & 01.01.1995 \\
Antilles\footnote{second footnote}& 21.01.1996 \\ Arab Emirates & 10.04.1996 \\
Argentina & 01.01.1995 \\ Armenia &05.02.2003 \\
Australia & 01.01.1995 \\ Bahrain &01.01.1995 \\
Bangladesh & 01.01.1995 \\ Barbados &01.01.1995 \\
Belgium & 01.01.1995 \\ Belize\footnote{third footnote} & 01.01.1995 \\
\end{mpxt abular *}
\medskip
Text without footnote.
x t a b u l a r demo x t a b u l a r demo
"second footnote
page 1 page 2
4 .6 .5 T ^X nicalities
The page break can be controlled through the \shrinkheight command to achieve a better
breakdown into pages. The command must be called after the first row of the table with a
length as parameter. A positive length decreases the amount of space available on a page and a
negative value increases it. In general you should use multiples of \normalbaselineskip for
165
M ulti-page tables
the value, as within the table \b a s e lin e s k ip is set to Opt internally. The following example
is identical to Example 04-06-5 on page 162 apart from the removal of footnotes and the use
of the \s h r in k h e ig h t command.
\s h r in k h e ig h t { length}
\usepackage{xtab} \usepackage[labelfont=bf]{caption}
\tablecaption{Demonstration of a table caption.}
\ta b le fir sth e a d {\h lin e \emph{country} & \em ph{entry}\\\hline}
\tablehead{\emph{country} & \em ph{entry}\\\hline}
\ta b le t a il{ \h lin e \multicolumn{ 2}{r@{}}{continued \ld o t s } \\}
\ta b le la s t t a il{ \h lin e }
\begin{center}
\begin{xtabular}{@ {}p{0.55\linewidth} r@{}}
Egypt & 30.06.1995 \\\shrinkheight{-7\norm albaselineskip}
Albania & 08.09.2000 \ \
Angola & 23.11.1996 \ \ Antigua and Barbuda & 01.01.1995 \ \
A n tilles & 21.01.1996 \ \ Arab Emirates & 10.04.1996 \ \
Argentina & 01.01.1995 \ \ Armenia & 05.02.2003 \ \
Australia & 01.01.1995 \ \ Bahrain & 01.01.1995 \ \
Bangladesh & 01.01.1995 \ \ Barbados & 01.01.1995 \ \
Belgium & 01.01.1995 \ \ B elize & 01.01.1995 \ \
\end{xtabular}
\end{center}
page 1 page 2
The length for \s h r in k h e ig h t depends on the internal calculation of the required vertical
space. Specifying a multiple o f \n o r m a lb a se lin esk ip is not the same as saying “7 more
lines” - it is just trial and error to find the correct setting.
16 6
C h a p t e r
T ip s a n d t r ic k s
This chapter describes various tips and tricks that have not been listed so far or are not directly
supported by one package. Some of the tricks have been taken from the usual T^X mailing
lists and newsgroups. In these cases, the respective author is given.
5 .1 Tables - general
At the beginning o f a table row, Tj?X searches internally for specific primitive commands trick
that affect the formatting, for example \span , \o m it, and \n o a lig n . This can lead to error
messages if the first column’s column type is defined to change the encoding for that column.
While searching for specific commands in the row, T^X expands the commands in the first
column, and only then considers the column type, with its explicit change of encoding.
In the following example by Bernd Raichle, the \ r e la x command prevents the following
\t e x t e p s il o n from the t ip a package from being expanded.
Tips and tricks
\usepackage[T3, T l]{fontenc}
\usepackage[la t i n i ] { inputenc}
\usepackage{array, dcolumn, tabularx, textcomp,ragged2e}
\usepackage[noenc] { tipa}
\newcolumntype{C}{>{\Centering}X}
\begin{tabularx}{0. 85\linewidth}%
{ |> {\tipaencodin g}c|1 |>{\RaggedRight}X|D{. } { . } { - l} |} \h lin e
\m ulticolum n{l}{|c|}{Sound} & \multicolumn{l}{c|}{Exaraples}
& \multicolum n{l}{C|}{Place and manner of a rticu lation }
& \multicolumn{l}{C|HOccurrence frequency (\%)} \\\h lin e
\r e la x \te x tepsilon & l a i t , jou et, merci & front, half-open & 5.3 \\\h lin e
\end{tabularx}
tip If your table contains empty or not completely filled rows and makes use of vertical lines,
you must list all columns, or a vertical line will be missing:
trick At the end of a row in a table, you can insert arbitrary vertical space by using the optional
argument of \ \ . However, if a horizontal line is added as well, the processing order of T^X
“first line feed, then line” leads to an unsatisfactory result. The T^X \n o a lig n command lets
you insert vertical material at the end of a row such that the horizontal line is drawn first and
then the vertical line feed is inserted.
168
5.1 Tables - general
trick A lo n g ta b le usually requires several runs because it writes information about the current
width in the . aux file and reads it back in. To reference this width, for example to typeset the
caption or surrounding text with the same width as the table, you can use this trick by Heiko
Oberdiek. The code for setting the length \LongTableWidth is in the preamble, which is not
visible here.
If a table should be read through the \in p u t command, the entire table should be contained tip
in the external file. Otherwise, problems may occur. Here is an example:
\begin{tabular}{ c c }
\in p u t{tab le rows}
\end{tabular}
This sequence generates the following error message if the first row of the external file
table rows contains a \m ulticolum n command:
169
Tips and tricks
5 .3 Tw o-colum n mode
tip The only environment that lets you typeset tables across columns in \twocolumn mode is
su p erta b u la r from the package o f the same name (cf. Section 4.5 on page 149). When
using the m u ltic o l package, you can’t use \twocolumn mode anymore, and have to use the
tab b in g environment instead.
\usepackage{supertabular}
two column-Demo 05-03-1
twocolumn mode \twocolumn[\centering%
\texttt{twocolumn} mode\bigskip]
L Z R 1 c r \begin{supertabular}{l c r }\h lin e
i c r 1 c r L & Z & R \\\h lin e
i c r 1 c r l & c & r \ \ l & c & r \ \ l & c & r w
l & c & r \ \ l & c & r \ \ l & c & r w
i c r 1 c r
l & c & r \ \ l & c & r \ \ l & c & r \\
i c r 1 c r
l & c & r \ \ l & c & r \ \ l & c & r \\
i c r \end{supertabular}
i c r
i c r
Seite 1
17 0
5.4 Table captions
The tab b in g environment has the disadvantage that it is always left-aligned, but the tip
advantage that it can be used either in \twocolumn mode or within the m u ltic o ls environ
ment.
\twocolumn[\centering%
two column-demo
\texttt{twocolum n} mode\bigskip]
twocolumn mode \b egin {tab b in g}
L \=z \=R \ k i l l
LZR 1c r L \>Z \>R\ \
1c r 1c r 1 \>c \>r \ \ 1 \>c \>r \\ 1 \>c \>r \\
1 er 1c r 1 \>c \>r \ \ 1 \>c \>r \\ 1 \>c \>r \\
1c r 1 \>c \>r \ \ 1 \>c \>r \\ 1 \>c \>r \\
1c r 1 \>c \>r \ \ 1 \>c \>r \\ 1 \>c \>r \\
\end{tabbing}
1 CT
1 er
1c r
1c r
1c r
Seite 1
\usepackage{multicol}
two column-Demo
\su b sectio n * {\tex ttt{m u ltico ls} mode}
m u ltic o ls m ode \begin{m u lticols}{ 2}
\begin{tabbing}
LZR 1c r L \=Z \=R \ k i l l
1c r 1c r L \>Z \>R \ \
1c r 1c r 1 \>c \>r \ \ 1 \>c \>r \ \ 1 \>c \>r \ \
1c r 1c r 1 \>c \>r \ \ 1 \>c \>r \ \ 1 \>c \>r \ \
1 er 1c r 1 \>c \>r \ \ 1 \>c \>r \ \ 1 \>c \>r \ \
1c r 1c r 1 \>c \>r \ \ 1 \>c \>r \ \ 1 \>c \>r \ \
1 er \end{tabbing}
\end{m ulticols}\par
Normal one-column te x t.
Normal one-column text.
Seite 1
5 .4 Table captions
When typesetting a table that crosses a page break, it is possible that the break could be tip
inserted between the table caption and the following table. To avoid this, you must ensure
that the remaining space on the page when you start the table is sufficient for the caption
171
Tips and tricks
and at least three table rows. Donald Arseneau created the \n eed command, which checks
whether there is sufficient space left on the page and inserts a page break straightaway if not.
\n e e d {le n g th }
You could also extend the definition of the corresponding table environment to integrate the
\n e ed command. The following two examples show the first two pages of a document; in
the first example, the standard behaviour without the \n eed command is shown and in the
second one, the behaviour with the command. The choice of size for the required length takes
some experience to assess exactly, but \ n e e d { 6 \n o r m a lb a s e lin e s k ip } will usually succeed
in preventing a page break between table caption and body.
\usepackage{supertabular}
\newcommand\demoText{In theory, the d efin itio n of the table environment could be
extended to integrate the \p r o te c t\te x ttt{\te x tb a c k sla sh need} command. These two
examples show the f i r s t two pages of a document, where the f ir s t page has
(without \p r o te c t\te x ttt{\te x tb a c k sla sh need}) or does not have (with
\p r o te c t\te x ttt{\te x tb a c k sla sh need}) a page break.}
\section{A tab le}
\demoText \begin{center}
\tablecaption{C aption.}
\tab leh ead {\h lin e columnl & column2 \ \ }
\b e g in {su p e r ta b u la r }{|c l|c l|}\h lin e
yyy & xxx \ \ \h l i n e yyy & xxx \\ \h l i n e yyy & xxx \\\h lin e
\end{supertabular} \end{center}
Table 1: Caption.
page 1 page 2
172
5.5 Math mode
\usepackage{supert abular}
\m akeatletter
\newcommand\need[l]{\par \p en alty -100 \begingroup % preserve \dimen@
\dimen@\pagegoal \advance\dimen@-\pagetotal % space le f t
\ifd im #l>\dimen@ % not enough space l e f t
% only do \ v f i l i f some space l e f t on page
\ifdim\dimen@>\z@ \vskip -\pagedepth plus l f i l \ f i
\break
\ f i \endgroup}
\makeatother
\section{A table}
\demoText% see other example
\need{ 6\normalbaselineskip}
\begin{center}
\tablecaption{C aption.}
\tab leh ead {\h lin e columnl & column2 \ \ }
\b e g in {su p e r ta b u la r }{|c l|c l|}\h lin e
yyy & xxx \ \ \h l in e yyy & xxx \ \ \h l i n e yyy & xxx \\\h lin e
\end{supert abular}
\end{center}
page 1 page 2
5 .5 Math mode
The typesetting o f columns o f numbers aligned at the decimal separator is actually done trick
internally by treating the decimal separator as column separator and separating the integer
173
Tips and tricks
part and the decimal places into two columns. However, as individual table rows are always
typeset as separate groups to keep the definitions local, this means that definitions before a D
column are not known anymore when the decimal places (in the second internal column) are
typeset. The following trick enables you to typeset all digits in a different font; this example
by Heiko Oberdiek sets the digits in sans-serif.
tip If you want to display content o f D columns centred at the decimal separator through -1
and with a constant added, you can’t use the . column type or the < operator - for example
\new colum ntype{a}{ .<{+6240}} in the following example. This column type is used to
format the second column of the table; it results in +6240 being appended first and then the
number being centred on the decimal separator. The resulting space on the left of the second
column is too large.
Using the internal commands \DC@ for the beginning and \DC@end, you can first centre
the number and after that append a constant, as seen in the example for the columns 55
(column type b) and S6 (column type B).
\usepackage{dcolumn}
\m akeatletter \newcolumntype{. }{D{. } { . } { - l} } \newcolumntype{a}{.<{+6240}}
\newcolumntype{b}{>{\DC@{. } { . }{-l}}c<{\DC@end+6240}}
\newcolumntype{B}{>{\DC@{. } { . }{-l}}c<{\DC@end+25530}}
\newcoramand\interval[l]{\multicolumn{l}{c}{#l}} \makeatother
\begin{tabular}{@{}la.,bB@{}}
\interval{Sl}& \interval{S2}& \interval{S3}& \interval{S4}& \interval{S5}& \interval{S6}\\
9 9 .0 \ , \% & 14.40& 438& 5256& 375.60&182.70\\99.9 \,\% & 1.59& 44 & 526 & 37.60&18. 3 0 \\
9 9 .9 9 \, \%& 0.15& 4.4& 0.53& 3.76 & 1.83
\end{tabular}
SI S2 S3 S4 S5 S6
05-05-2 |
99.0 % 14.40 + 6240 438 5256 375.60 +6240 182.70 +25530
99.9 % 1.59 + 6240 44 526 37.60+6240 18.30+25530
99.99 % 0.15 + 6240 4.4 0.53 3.76+6240 1.83+25530
174
5.6 Excel and OpenOffice files
la tex example
exceltex example
la tex example
The Perl program exceltex requires the Perl module S p rea d sh eet: :P arseE xcel, which
is available on CPAN h ttp ://s e a r c h .c p a n .o r g /~ sz a b g a b /S p r e a d sh e e t-P a r se E x c e l-O .
3 2 /lib /S p r e a d sh e e t/P a r se E x c e l.p m . The e x c e lt e x package isn’t available in T£XLive
2007; it must be installed separately. The Perl program must be executable. The package
supports reading individual cells or several rows:
\ in c c e 11 { x/s file!sheet!cell}
\± n c ta b { x ls file!sheet!first cellllast cell}
Reading of a c e ll:
\ i n c c e l l { t e s t .x l s !Z eu g n isliste!C3}
\ i n c c e l l { t e s t .x l s !Z eu g n isliste!D3}
\usepackage{exceltex,booktabs}
Reading of a tab le:\p ar\setlen gth \tab colsep {2p t}
\begin{tabular}{@{} *{16}{1} @{}}\toprule
given name & surname & DOB & \m ulticolum n{13}{c@ {}}{subjects}\\
& & &D &U &T &E &F &L &G &K &M &P &C &B &S\\\midrule
\in c ta b { te s t.x l s !Z eu g n isliste!C2!R5}\bottomrule
\end{tabular}
175
Tips and tricks
exceltex also creates subdirectories with the file names followed by - e x c lt x . The individ
ual entries are saved into these files with, for example, the following content:
\t e x t c o lo r [ r g b ] { 0 , 0, 0}{N adine}.
Additional information can be taken from the package description, especially regarding
the further functionality of the Perl program. The documentation can’t be displayed through
texdoc (cf. Section 7 on page 213), however, because the name is not the same as the package
name.
\end{tabular}
Courses 105-06-3]
DE-1 de-1 DE-2 de-2 DE-3 de-3 DE-4 de-4
Mu-1 mu -1 Mu-2 mu -2 Mu-3 mu-3 Mu-4 mu-4
Ku-1 ku-1 Ku-2 ku -2 Ku-3 ku-3 Ku-4 ku-4
E l -1 e l -1 E l -2 e l -2 El-3 el-3 El-4 el-4
F2-1 f 2-l F2-2 f 2-2 F2-3 f2-3 F2-4 f2-4
L3-1 13-1 L3-2 13-2 L3-3 13-3 L3-4 13-4
tü-1 tü -2 tü-3 tü-4
ds-1 ds-2 ds-3 ds-4
pw -1 pw -2 pw-3 pw-4
GE-1 ge -1 GE-2 ge -2 GE-3 ge-3 GE-4 ge-4
phil-1 phil-2 phil-3 phil-4
MA-1 ma-1 MA-2 ma-2 MA-3 ma-3 MA-4 ma-4
PH -1 ph -1 PH -2 ph -2 PH-3 ph-3 PH-4 ph-4
CH-1 ch-1 CH-2 ch -2 CH-3 ch-3 CH-4 ch-4
BI-1 bi-1 BI-2 bi-2 BI-3 bi-3 BI-4 bi-4
in -1 in -2 in-3 in-4
SP-1 sp-1 SP-2 sp -2 SP-3 sp-3 SP-4 sp-4
EK-1 EK-2 EK-3 EK-4
176
C h a p t e r
E x a m p le s
author example(s)
U w e B o r ch er t 03- 03-4
J e a n -C ô m e C h a rp en tie r 06- 00- 1, 06- 00-8
C h ristia n e G eig e r 06- 00-26
M o rte n H o g h o lm 05- 05-2
S te fa n Ju n ge 06- 00- 28, 06- 00-41
K ai-M artin K n aak 06- 00-32
M ark u s K o h m 06- 00-2
R o lf N ie p r a sc h k 06- 00- 25, 06- 00- 29, 06- 00- 30, ??, 06- 00- 34, 06- 00- 42,
06- 00- 43, 06- 00-45
H e ik o O b erd iek 05- 01-4
B ern d R a ic h le 05- 01-1
A x e l R e ich er t 06- 00- 9, 06- 00- 10, 06- 00- 11, 06- 00- 12, 06- 00- 13, 06- 00- 14,
06- 00- 15, 06- 00- 14, 06- 00- 15, 06- 00- 16, 06- 00- 17, 06- 00- 18,
06- 00- 19, 06- 00- 20, 06- 00- 21, 06- 00- 22, 03- 03- 5, 06- 00- 36,
06- 00-37
C h ristia n T e lle c h e a 06- 00- 39, 06- 00-40
U w e Z ie g e n h a g e n 06- 00-46
Examples
Cas où le
Nombre de gouvernement a Cessions
Pratiques dossiers eu gain de cause ordonnées
1890-1939
Concentrations 57 46 20
Marché national 33 25 12
Marché régional ou local 24 21 9
Pratiques antitrust 97 79 8
Marché national 54 43 5
Marché régional ou local 43 36 3
Total 154 125 28
1940-1999
Concentrations 28 25 9
Marché national 14 12 4
Marché régional ou local 14 13 5
Pratiques antitrust 91 75 7
Marché national 52 42 2
Marché régional ou local 39 33 5
Total 119 100 16
Source : adapté de Posner (2001,p. 106).
178
Examples
\usepackage{tabularx, booktabs,ragged2e}
\newcomraand\raggedcolumn{\RaggedRight\hspace{Opt}}
\newcommand\centercolumn{\Centering\hspace{Opt}}
\renewcomraand*{\tabularxcolumn}[ 1 ] {b{#l}}%
\begin{tabularx}{\textwidth}{@{}*{3}{>{\raggedcolumn}X}*{3}
{>{\raggedcolumn}X}@{}}\toprule
header lin e 1 & headerlin e 2 & header lin e 3 &
header lin e 4 & headerlin e 5 & header lin e 6,
which i s a b it longer as usual \\\m id ru le
foo & bar & baz & gg & gg &gg\\\m idrule
foo & bar & baz & gg & gg &dd\\\bottom rule
\end{tabularx}
header
line 6,
which
is a bit
header header header header header longer as
line 1 line 2 line 3 line 4 line 5 usual
foo bar baz gg gg gg
foo bar baz gg gg dd
\usepackage{array,booktabs}
\newcounter{Platz}
\begin{tabular}{@{}>{\ifnum\thePlatz>0 \th e P la tz .\ f i } r
1 rrr c@{ :}c c<{\stepcounter{Platz}} @ {}}\\\toprule
\multicolumn{ 8}{c}{%
\bfseries\rule[-2ex]{0pt}{5ex}G erm an fo o tb a ll league 1986/87.} \ \ \midrule
\multicolumn{l}{@{}c}{}
& club & S & U & N &\multicolumn{2}{c}{point:
& Bayern München & 20 & 13 & 1 & 53 & 15 & championW
& Hamburger SV & 19 & 9 & 6 & 47 & 21 & cup winner\\
& Bor. M’Gladbach & 18 & 7 & 9 & 43 & 21 & s ta r te r \\
& Bor. Dortmund & 15 & 10 & 9 & 40 & 28 & in th e \\
& Werder Bremen & 17 & 6 & 11 & 40 & 28 & UEFA cup\\
& Bayer Leverkusen & 16 & 7 & 11 & 39 & 29 & cup\\\raidrule
& l.FC Kaiserslautern& 15 & 7 & 12 & 37 & 31 & \ \
& Bayer Uerdingen & 12 & 11 & 11 & 35 & 33 & \ \
& l.FC Nürnberg & 12 & 11 & 11 & 35 & 33 & \ \
& l.FC Köln & 13 & 9 & 12 & 35 & 33 & \ \
& VfL Bochum & 9 & 14 & 11 & 32 & 36 & raid f i e l d \ \
& VfB Stuttgart & 13 & 6 & 15 & 32 & 36 & \ \
& Schalke 04 & 12 & 8 & 14 & 32 & 36 & \ \
& Waldhof Mannheim & 10 & 8 & 16 & 28 & 40 & \ \
& Eintracht Frankfurts 8 & 9 & 17 & 25 & 43 & \\\m idrule
179
6 Examples
& FC Homburg & 6 & 9 & 19 & 21 & 47 &r e l. S t.Pauli\\\m idrule
& Fortuna Düsseldorf & 7 & 6 & 21 & 20 & 48 &\ \
& BW 90 Berlin & 3 & 12 & 19 & 18 &50
& \r a is e b o x { 1 .5 e x } [-l.5 e x ]{ r e le g a te d } \\\b o tto m r u le
\en d {tabular}
180
E x a m p le s
H He
Li Be |B C N o F Ne
Na Mg A1 Si P s Cl Ar
K Ca Ga Ge As Se Br Kr
Rb Sr In Sn Sb Te I Xe
Cs Ba T1 Pb Bi Po At j Rn
Fr Ra 112
J 114 r
H He
Li Be B C N 0 F Ne
Na Mg A1 Si P s Cl Ar
K Ca Ga Ge As Se Br Kr
Rb Sr In Sn Sb Te I Xe
Cs Ba T1 Pb Bi Po At Rn
Fr Ra 112 114
\usepackage{pst-node}\SpecialCoor
\setlength\tabcolsep{2mra}
\begin{tabular}{*{8}{p{4mm}}}
H & & & & &\rnode{A}{—}&& He\\ L i & Be & B & C &N &0 & F & Ne\\
181
6 Examples
¡06-00-7
text \usepackage{array}
text | 06-00-8
• tex t••• *tex t........ \parbox[0cm ][ 0 . 5ex][s]{0mm}{\makebox[42mm]{\dotfill}}%
text
text \begin{tabular}{|b{9m m }|m {9mm }|p{9mm }|}\hline
te x t te x t & te x t te x t & te x t te x t \ \ \ h l i n e
\end {tab ular}
182
Examples
Schmelzeinsätze Schalter kg €
Schmelzeinsätze Schalter kg €
Pilzdruckknopf mit Rastung rot 54 1 3 ,-
und Drehentriegelung
Pilzdruckknopf mit Rastung rot 32 21,60
und Schloss
Schlüsselantrieb mit abziehba schwarz 43 15,10
rem Schlüssel
Knebel mit 3 Schaltstellungen schwarz 23 5,40
18 3
Examples
\usepackage{array,booktabs} \newcolumntype{C}{>{\small}c}
\begin{tabular}{@ {}l *{4}{c} @{}}\toprule
\sm all month & \multicolumn{2}{C}{women} & \multicolumn{2}{C@{}}{men}\\
\cm id ru le(lr){2-3}\cm id ru le(l){4-5}
& \sm all 1967 & \sm all 1968 & \sm all 1967 & \sm all 1968\\
\cm id ru le(r){l-l}\cm id ru le(lr){2 -2 }\cm id ru le(lr){3-3}\cm id ru le(lr){4-4}\cm id ru le(l){5-5}
Septembers 2000 & 1700 & 2300 & 1900\\ October & 1500 & 1800 & 1900 & 3000\\
november & 2500 & 2800 & 4700 & 3200\\ december & 2300 & 2000 & 3600 & 2700\\\bottomrule
\end{tabular}
\usepackage{array,booktabs,multirow,ragged2e , eurosym}
\renewcommand\multirowsetup{\RaggedRight\footnotesize}
\newcolumntype{N}{>{\footnotesize}l} \newcolumntype{C}{>{\footnotesize}c}
\newcommand\mc[3]{\multicolum n{#l}{#2}{#3}}
\begin{tabular}{@{} *{5}{1} @{}}\toprule
& & \mc{2}{N}{0hne Sicherungen} & \multirow{3}{7em}{%
Höchstzulässiger Erdungswider\-stand bei Berüh\-rungsspannung}\\\cm idrule(lr){3-4}
\mc{l}{C}{Reihe} & \mc{l}{C}{Spannung} & \mc{l}{C}{Type} & \m c{l}{C}{Preis} \ \
& \mc{l}{C}{V} & & \m c{l}{C}{\euro} \\\c m id r u le (r){l-l}\cm id ru le(lr){2 -2 }
\cm id ru le(lr){3-3}\cm id ru le(lr){4-4}\cm id ru le(l){5-5} \ld o ts \\\bottom rule
\end{tabular}
18 4
o
© ©
o
©
o ©
©
Ul 4^
/ Ä SC z ßo ßo ßo ßo __ z / z
\end{tabular}
\ld o ts \\\bottom rule
\cm id ru le(lr){4-4}\cm id ru le(lr){5-5}\cm id ru le(lr){6-6}\cm id ru le(lr){7-7}\cm id ru le(l){8-8}
p ßo 3 ßo ßo 3 / er 3 3 3 3
\usepackage{array,booktabs,dcolumn,ragged2e} \newcolumntype{N}{>{\footnotesize}l}
\newcolumntype{P}[l]{>{\footnotesize\RaggedRight\hspace{Opt}}p{#l}}
\newcolumntype{d}[1 ]{D{. } { , }{#1}} \newcommand\mc[2]{\m ulticolum n{l}{#l}{#2}}
\begin{tabular}{@ {}l *{6}{d{3.0}} @{}}\toprule
\mc{@{}N}{Zeit} & \multicolumn{2}{N}{Material von Drischel}
& \multicolumn{2}{N}{Material von Bauer} & \multicolumn{2}{N@{}}{Eigenes M aterial}\\
\cm id ru le(lr){2-3}\cm id ru le(lr){4-5}\cm id ru le(l){6-7}
& \mc{P{3.5em}}{Häufigster Wert} & \mc{P{3.5em}}{Extremwert}
& \mc{P{3.5em}}{Häufigster Wert} & \mc{P{3.5em}}{Extremwert}
& \mc{P{3.5em}}{Häufigster Wert} & \mc{P{3.5em}@{}}{Extremwert}\\
\cm id ru le(r){l-l}\cm id ru le(lr){2-2}\cm id ru le(lr){3-3}\cm id ru le(lr){4-4}%
\cm id ru le(lr){5-5}\cm id ru le(lr){6-6}\cm id ru le(l){7-7}\ad d lin esp ace
Latenzzeit & 220 & 330 & 245 & 325 & 235 & 320 w
& & 150 & & 155 & & 160 \\\ad d lin esp ace
Halbwertszeit & 210 & 380 & 145 & 535 & 180 & 320 w
des Abstiegs & & 90 & & 95 & & 70 \\\ad d lin esp ace
G ip felzeit & 485 & 700 & 375 & 535 & 420 & 600 w
& & 260 & & 315 & & 290 \\\ad d lin esp ace
Halbwertszeit & 855 & 870 & 665 & 945 & 775 & 820 w
des Abstiegs & & 590 & & 575 & & 490 \\\addlinespace\bottom rule
\end{tabular}
186
Examples
187
oo
oo
X*" / z z /
\mc{@{}N}{mit Bügel-} & \mc{N}{mit Mantel-} & \mc{N}{mit Block-}
3 er 3 3 3 3 H 3
ß® 3 CD 3 3 3 3 3 CO
& & & \mc{N}{unten} & \mc{N}{oben} \\[ - 3 p t ]
1—1Oq :> s s 3 3
\cm id ru le(r){l-3}\cm id ru le(lr){6-7 } / H H- n n n n 3 T3
3 H- rS3 og o o o s 3
c n n 3
1—1 O Pt g 3 1e—1 ic—1 o ZT
1
— 1
rt H —13 3 3 g g g 3
H- 3g er 3Cb rt 3 rt 5 3 g oq
n 3 rt CD 3
O 5 M z* < •< *< 3 rS
M rs 3 3 *3 Cu Cb
C CO H n 3 3 3 o
g SH SH
5 r-S r-S
1— 1 r-S r-S rS 3 o
N) C b
1—1 SH SH SH z 3 3 M 03 tO I—l Schaltergröße
r-S © © 1—1 3
M r-S rS r-S 1— 1 r-S rS rt g
s~» V SH z V V H- -3
rS
z
Z
s-* *
3 r-S r-S r-S
3
H
/ fee o er -q co H-1 tn x*
s-; r-S r-S ö Hl SH s o
1—1 r-S CO to ox to £ 5'* H
rS tr1 CO rt o h-1 CO o CO o o N
> H- SH H- o A 3 ?r Sc ö
ft
3 CO r-S n SH rt r-S rt rt o- ^B-
CO rt Cb o r-S 3 fee 3 3 C
o CD r-S H-J - o SH *3 er a3 o* 3
3* 3 CO 3 SH rt SH rS CO n>
1—1 1 3 r-S 3 .Z <* co> to H-1 h-1 8 §’
3 z o
CO 3 s~»
3
«~s ** M H-
CO JÖ 3
3 3 to I—1 o o tr 3 &
CO S~» H SH N oq 1—1 o o o o £L 3
s-> S-» 3 oq rt
er CD Cb HS '-H 3 H-
H- H r-S =& 1—1 3- H
CO S-J N3 M SH so o
SH H- s
g ß® o r-S oq 1—l flP fi>
g
fee x^
s~» =*fc
ro
3* H
rt 3 o 03 co 1—^ £ - 8
> 3 * SH Z oq o o 03 03 5- *-
N) o H-i SH Hi oq _ Q
fee HS CO O 3
S"' Z SH O Cb £ g
s~> rS rt N3
ß° rs SH 3 3 3 9<T># 3
s
2: o SH co H-l 1—1
/ CD rt
3 3 M 3 03 00 to 03
3 3 r-S © CO
i—1 CO H-
rt H w-< N
H- H SH 3
H O z SH
O 3 rt
s-*-1 SH o to to 1—1
<
CO ß® H
*G to to t—1 to
S~» 3 o o o
r-s 1—1
CO 3 3
n to H-i t—1 t—>•
Ul r-S co co Ol to Mehrpreis für
CD Z
3 s~» abweichende
SH r-S Spannung
rS *-d
hd O
OQ f—1
N
Hi 3
3: 3 “
H 1—1
SH
>
er
CTQ
3
3
Oq
O
er
CD
3
S-» oo
oo
VO
/ ^Г-
о\
Ф и /
\newcolumntype{C}{>{\footnotesize}c}
\usepackage{dcolumn,booktabs,ragged2e ,ro ta tin g , eurosym}
Ф ß® ß® 3 СГ 3 3 3 3 3
3 ß ® о ß® ß® ß ® ß ® ß ® ф ф ф ф Ф Ф
Dj CO и г-Ч и 0Q s: s:
гЧ Ф N3 / © 03 / Н- n о о S о О
4 ГО О о 3 г-Ч гз н- 3 3 3 3 3 3 о О о о о
03 ß® ß® 3 г-Ч о Ч~/ 3 со гз гз С 3 С гЧ з з 1—1 1—1 м
cr н- ГЗ н- ф гЧ гЧ м 1—1 I—1 ч з з с с с
e N3 и Сь гз Ч -» сь СГ гз ГЗ ч г+ ч 03 оз 0J з зз 3
1—' К о и Ч-» г-Ч и о © Ч-» н- н- н- СГ 3 3 3 3
Ш о о 3 г-Ч г-" с г-Ч гЧ гЧ п о ГЗ с СЬ СЬ ч ч ч
ч м / ГО м X Ч-* / о о О м / ► < *< с
Ч-1 ßo ß® ф ф о ф 1 Чг-* Ч м м м оз ГО 3 43 43 43
03 и Г— ч с Ч г— ч ф гЧ 03 с с с ч О n ф Ф Ф
о 03 1—1 и 03 м ф Н- 3 э з ч-> ч i—i гЧ гЧ гЧ
ß® ß® и О Ч чч 3 и СО гЧ 3 гЧ 3 ¡3 гЧ Оз 1_го СЬ из Z
1Ч-i Ч-i Ч-i
Ч-* Ф Чг-* 03 ф гЧ © ч
и г-*“* г-Ч г-Ч гЧ н- СГ го го ф гЧ ф гЧ 1—1г—1 гЧ
(X> 03 ф СО ю со о Ч-» Ч-» Ч г-» Ч-» 1—1 И И V
ß® ß® 1 ГЗ 1 ГО ф X гЧ гЧ гЧ Di н 3 гЧ гЧ гЧ
ro Ч
Ф гз ¡3- со о СГ г-Ч гЧ
~ > Ч-1
•-о 1J ч->
гЧ Z гЧ гЧ С
оз Ч о 1 М гЧ V HD
ro го _" н- 1—1 _■ 03 X ф 4J 41 гЧ И
3 ч СЗ гЧ О
о ф о Qj Ч о Ч гЧ ф ф ф 14 b СГ н- о
ß° ß° 3 Ч Ф 3 гЧ ф 1 3 3 3 ф ч~> ф о Чг-* HD ч
н- С И н- ф ч~* Ч-» ч~* н- «• ста о гЧ О 3
и и Oj м ста сь 03 ф гЧ Ч -* Ч-» со гЧ н- 1£—1 - О о
CO 143 и /— ф\ ч и СГ 3 / гЧ г-Ч ч слз 3 Ч-* ч ч
с О: с S Ч-1 го 3 X- с Ч-» гЧ з гЧ 3 ф
ь*з Ь-1 __'ч Е7ч> м ф гЧ о 3 с 3 гЧ ч 3 Чк о со
1 1 /— Ф Ф ф н- / н- гз Ч CTQ Di с гЧ И ч н-
1 1 "Чг-Ч Ч-» ГЧ п го РЗ гг N со гЧ ч И ч-> ф N
1 1 М И Ч-» 1—1 гг о г+ N D со 3 ч-» Чг* со Ч-i Ф
V» И 1 ßo ч_г ч ф г+ ф сь ф с Ч г* гЧ н-
г"" / W и гз D гЧ ф Н- Ч) ь гЧ N 1—1
/ гЧ ч-> 3 г-Ч Di г+ со 3 ч 3 Ч-» со И /Ф Ч-i
СП п ф ф ф 43 н- 03 Ч-' о Ч— ’
03 N5 1 гз г-Ч 1 Чг* гЧ 03 а 0Q 3 “ гЧ D. Ч-» гЧ ГО
ß° ßo СП 3 о СП ч~* 3 3 3 / =«: D
Ч-i н- Ч-» Ч~> / ф 3 со СГ ф N3 Ч ГО СО
4| И сь г-Ч £Г 3 п Ф Ч-» м Ч-> ста
CO СП о и < и Ч 3 3* Н- b D ч-> ф
CO О 3 3 > 03 43 0Q оз 3 ß® ч-/ 43 Di
ß® ßo н- м Ч-/ н- Ч Ч-* м Di rS го
Oj фч ßo со Ф Ч-» rt м гЧ
ß® слз =«: н-
CO И ч г— ф Н- Ч-* ф н* к 0Q
N) о с М 3 СГ СО 3 3Z Чг-* гг
О о м V Ч-/ гз о ь / ч
ß® ßo Ф г-Ч г-Ч X Нэ н- г / Чг* Ф
Г“\ ГЗ гЧ С: 3 г п гЧ Di 3 гг
И 1—1 N3 Ч~» 1 ч с 3 С Ь со
О СО И 1 г-Ч ф Чг* Di 3 н- N3 гЧ 43
О 03 N3 s: ф Чг* Н- Di Di ч 03
ß® ßo гЧ /Ч-* Ч-» 3
Ч-'
Ф ч N)
c=¡ С ч— * с n
03 ч ф
СО и 1 о /ß® гЧ а со 3 м гЧ © 3 гЧ
03 N3 03 3 3 __ ч ф Ч— ' о
ß® ß® Ч-* н- г-Ч гз го ф о ГЧ Ч-» ч-* 43
сь о н- гг М Ч-» ч
ГО И гз ч О г+ ф D ч / Чг-*
N) и 3 с Ч-' оз о 1—1 N — г ч Ч-i
О о н- м г-Ч г+ X* ч гЧ о 43
гЧ
ß® ßo сь ГЧ ф < ф со ф го »3
и >-* гЧ с+ 3 1 ч
N) и с 1—1Ч со С Ч-» ч-> СП 3 И
СО СП i—1 чг и ßo 4d м Ч-i
ф 0 3 Ф ф Чг-*
сл /Ч гЧ 3 э ч~*
1 1 b"1 СО о D
1 1 чг 1 г-Ч с
1 1 гЧ СО ГЗ
сл 4J ч-> Ч— 1 с3та
1 г-Ч Ч-'
“vj s: ч-*
Ч— ’ Ч~» Ч-'
СГ ß®
О
р+ 3
Ч гз
О
3 гз
3
3 гЧ
м <
ф >’
Ч—
Examples
189
Examples
Heilanstalten Ärzte
insgesamt davon
in
c
Ö
o 'S
0)
«3
03
b fl Ober Assistenz
X%
w
3 ju C ärzte ärzte
190
E x a m p le s
2 Tu \ u se p a c k a g e { ta b u la rx ,lo n g ta b le , amsmath}
06-00-25 !
______ I 3 We \usepackage[ta b le ]{ x c o lo r}
-Seminar \newcommand*\RMarker{.}
4 Th
\newcommand*\SeminarOn[l][Weekend]{%
5 Fr
\def\RMarker{ \ rb race\ tex t{#1}}}
6 Sa round table
Weekend \newcommand*\SeminarOff{\def\RMarker{.}}
7 So \newcommand*\SA{\rowcolor{black!20}}
8 Mo \newcommand*\SO{\rowcolor{black!30}}
9 Tu
\ b egin { lo n gtab le} { > { $ \ left. }l<{\right\RMarker$}}
\SeminarOn[Sem inar]
\ b egin { tab u larx} { . 6\linew idth}{rlX }
2 & Tu & \\ 3 & We & \\
4 & Th & \\ 5 & Fr & \\
\end{tabularx} \\\SeminarOn
\ b egin { tab u larx} { . 6\linew idth}{rlX }
\SA 6 & Sa & round tab le\ \
\S0 7 & So & \\
\end{tabularx} \\\SeminarOff
\b egin { tab ularx}{ .6\lin ew idth }{ rlX }
8 & Mo &\\ 9 & Tu &
\end{tabularx}
\end{longtable}
The following two figures show two floating environments, which appear on pages that
face each other. To make the two tables start at the same height, a \phantom instruction
is used for the right table. They can also be moved towards the centre to emphasize their
connection.
19 1
Examples
The source code for this example was omitted for space reasons; it can be found as
0 6 -0 0 -2 6 . l t x on CTAN.
1 D O U B LE P A G E 1 D O U B LE P A G E
1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988
Zeile 1 1 3 1 1 1 0 1 1 0 ZI 0 0 0 20 0 2 2 2
Zeile2 1 1 3 1 0 0 0 0 0 Z2 0 2 1 3 4 4 6 4
Zeile3 2 1 2 1 0 0 0 0 0 Z3 0 0 1 5 3 1 7 7
Zeile4 1 0 5 1 2 0 0 0 0 Z4 2 1 0 1 0 3 7 2
Zeile6 2 1 1 0 0 0 0 0 0 Z6 1 2 0 5 2 2 5 4
Zeile5 0 0 4 2 1 2 2 1 0 Z5 0 0 1 1 0 2 5 4
Zeile8 0 1 1 0 0 0 1 1 0 Z8 3 2 1 2 1 3 5 3
Zeile9 0 0 0 0 0 1 2 1 0 Z9 0 0 0 4 2 1 4 5
Zeile10 0 1 3 0 1 0 1 0 0 Z10 1 1 0 1 1 1 4 4
Zeilell 0 2 2 1 1 0 1 0 0 Zll 0 0 2 6 1 0 2 1
Zeile12 2 0 2 4 1 0 4 0 0 Zl2 0 0 0 0 0 0 1 0
Lärm 2 3 0 0 0 0 0 0 0 Lärm 0 1 0 2 0 0 2 2
Zeile13 0 1 0 0 1 0 3 0 0 Z13 0 0 0 2 0 1 3 0
Zeile14 0 1 0 0 0 0 0 0 0 Z14 0 0 0 3 3 2 1 1
Zeile15 0 0 0 0 0 0 0 0 0 Z15 1 0 0 4 0 0 3 1
Zeile16 0 0 0 0 0 1 0 0 0 Z16 0 0 0 0 0 3 5 0
Artikel gesamt 2 6 13 8 4 3 5 4 0 Artikel gesamt 6 3 5 23 10 8 15 13
Table1:Tablecapiton,partI.*
& Table1:Tablecaption,partII.
\usepackage{tabularx}
\begin{tabularx}{\linewidth}{@ {}X|p{ 2mm}@{}|}\cline{ 2- 2}
DANTE, Deutschsprachige Anwendervereinigung \TeX\ e . \ , V . , has been founded on April 14,
1989 in Heidelberg, Germany. The principal aim of the association i s to encourage advice
and cooperation among German language TeX users. This includes consulting via WWW,
electro n ic mail, and usual le t t e r mail concerning purchase, implementation, and \ld o ts
& \r u le { 2mm}{0p t } \ \\ c li n e { 2- 2}
\end{tabularx}
192
Autor Fläche Airgap Empfindl.
mm2 pm mV/Pa
Schellin 1 0,3
van der Donk
Bernstein 0,57 2,2 10,77
Chen - 2 40
Dehé 0 1 .2 1 3,2
Hsu 2 4 -
Kronast 2 1,3 11
Li 1 - 9,6
Pedersen 4,84 3,6 -
Rombach 1 0,9 14
Kovacs 0,25 1,5 -
Torkkeli 1 1,3 2
Bay 4 0,4 27
Füldner
Tajima 4 15 7
Kressmann 1 1 2,9
Thielemann
Hsieh 64 4,5 40
Murphy - - 8
Zou 1 2,6 14,2
o
O'
oo
[26,27,28,30]
-2 Chip
75-24 - Oxid, Mono-Si [29] J
\usepackage{tabularx}
\makeatletter\newcolumntype{M}{>{\@minipagetrue}X}\makeatother
\begin{tab u larx}{\lin ew id th }{|X |M |}\h lin e
l e f t & r ig h t\\\h lin e
The righ t l i s t now sta r ts at the same height as th is column.
& \begin{item ize} \item a \item b \item c \en d {ite m ize}\\\h lin e
\begin{item ize} \item a \item b \item c \end{item ize}
& The l e f t column i s not an M-column now and therefore has v e r tic a l space at the
beginning. \ \ \h l i n e
\end{tabularx}
left right
The right list now • a
starts at the same
height as this column. • b
• c
\usepackage{array} ,—
Table 1: Automatic counting of lines \newcounter{tabline} I— -
in a table. \newcolumntype{n}{>{%
\refstep cou n ter{tab lin e}\th etab lin e\en sp ace}l}
No. anim al
1 gelse \b egin{table}
\centering
2 chamois
\caption{Automatic counting of lin e s
3 skunk
in a table.}\label{BA Z}
4 anteater \begin{tabular}{n}\hline
5 armadillo \multicolumn{l}{l}{\emph{No. a n im al}}\\\h lin e
g else \\
chamois \label{FOO} \\
See line 2 or alternatively line 5 in Ta skunk \\
ble 1 on page 1. anteater \\
armadillo \label{BAR} \\\h lin e
\end{tabular}
\end{table}
\medskip
See line~\ref{FOO} or a ltern a tiv ely
line~\ref{BAR} in Table~\ref{BAZ}
on page~\pageref{BAR}.
194
Examples
06-00-31
Tipo de Capacidad Número de Número de viajes diarios en
avión (pasajeros) aviones la ruta
1 2 3 4
1 50 5 3 2 2 1
2 30 8 4 3 3 2
3 20 10 5 5 4 2
4 10 18 3 1 - 1
5 5 8 2 1 - 6
6 1 80 6 5 12 4
Número de clientes diarios 1000 2000 900 1200
The following example shows how to add columns automatically with intermediate sums.
For space reasons, the whole preamble was moved into the non-visible part here.
\usepackage{longtable}
\resetintsum
\begin{longtable}{p{ 0. 7\linew idth}r}
l e f t & right
\endfirsthead
carry & \ \
\endhead
intermediate sum: & \MarkIntSumPos \ \
\endfoot
sum: &\MarkIntSumPos \ \
\en d lastfoot
195
E x a m p le s
An a r b it r a r y in t r o d u c t o r y t e x t a t th e s t a r t o f th e c o lu ra n \ld o ts .
& \ V a l{ l,0 0 > \ \
b & \ V a l{ 2 , l } \\
c & \ V a l{ 3 ,4 } \\
d & \ V a l{ 4 , 5} \ \
e & \ V a l{ 5 ,6 } \\
f & \ V a l{ 6 ,7 } \\
g & \ V a l{ 7 ,8} \ \
h & \ V a l{ 8 ,9 } \ \
i & \ V a l{ 9 ,4 2 } \ \
j & \ V a l{ 1 0 ,8 8 } \ \
k & \ V a l{ 1 5 ,7 6 }
\ e n d { lo n g ta b le }
[06-00-32
\u se p a ck a g e { ra g g e d 2 e , a r r a y , g ra p h ic x }
196
E x a m p le s
\ e n d { ta b u la r}
& % r i g h t colum n f o r th e image
\ r a is e b o x { - 0 . 5 \h e ig h t} { \in c lu d e g ra p h ic s [w id th = 3 c m ]{ im a g e s / d in 8 } }
\ e n d { ta b u la r}
\ u s e p a c k a g e { a rra y ,b o o k ta b s , a r y d s h ln , eu rosym , g ra p h ic x }
\ u s e p a c k a g e [ t a b le ] { x c o lo r }
197
E x a m p le s
\ r o w c o lo r [ g r a y ] { 0 .8 8 } [ \ ta b c o ls e p ]
E in sp a ru n g e n & & 3 .2 2 2 & 38.660 & 2 .4 2 2 & 29.060 \ \
\ r o w c o lo r [ g r a y ] { 0 .9 9 } \ m u ltic o lu m n { 4 } { c I } { A b z ü g lic h z u s ä t z lic h e K o s te n :} \\
M ie te & &200 & 2 .4 0 0 & 200 & 2 .4 0 0 \ \
I n s t a l l a t i o n und Wartung& &142 & 1 .7 0 0 & 42 & 500 \\
S o n s tig e K o ste n & &83 & 1 .0 0 0 & 83 & 1 .0 0 0 \ \
\ r o w c o lo r [ g r a y ] { 0 .8 8 } [ \ t a b c o ls e p ] T a t s ä c h lic h e E in spa run ge n & & 2 . 797&33. 560&2. 097&25. 1 6 0 \\
& & \m u ltico lu m n { 2 } { cI} { S \s ta ck re l{ \w e d g e } { = } 3 5 \% $ }
& \m u ltico lu m n { 2 } { c@ { } } { $ \s ta ck re l{ \w e d g e } { = } 26\% $}\\
\c m id ru le { 3 -6 } \ m o re c m id ru le s \ c m id ru le { 3 -6 }
\ e n d { ta b u la r} }
198
E x a m p le s
You can control the row spacing in a table relatively easily, by using either the ta b ls
package or altering the value of \a rra y s tre tc h , which defaults to 1 . Alternatively, you can
insert an invisible line (\ru le) with a depth and height. This example also shows how to use
nested tables.
text in a m-column
D e fa u lt b a s e lin e h e ig h t \ \ [ 2 p t ]
^ An extremely long line of \b e g in { ta b u la r} { @ { } c
text in a m-column > {\R ag g e d R ig h t}m{4cm}@{} } \ h lin e
2 An extremely long line of 1 & An e x tre m e ly lo n g l i n e o f t e x t
text in a m-column i n a m -c o lu m n \\\ h lin e
2 & An e x tre m e ly lo n g l i n e o f t e x t
\renewcommand\arraystrech{l.5} i n a m -c o lu m n \\\ h lin e
3 & An e x tre m e ly lo n g l i n e o f t e x t
j An extremely long line of i n a m -c o lu m n \\\ h lin e
text in a m-column \e n d { ta b u la r}
199
6 E x a m p le s
\ u s e p a c k a g e { a rra y ,b o o k ta b s , r o t a t i n g ,u n it s }
\ n e w c o lu m n ty p e { N } { > { \s c rip ts iz e } l}
\ b e g in { s id e w a y s ta b le }
\c a p tio n { T h e f o llo w in g t a b le has been r o t a t e d a u t o m a t ic a lly w ith \ t e x t t t { s id e w a y s t a b le } . }
\ b e g in { c e n te r}
\b e g in { ta b u la r} { @ { } N N * { 5 } { l} @ { } } \to p ru le
c a p a c it y & $ \u n it{ c m A3}$ & 1288 & 1488 & 1688 & 1985 & 2274 \ \ \ m id r u le
power & \u n it{k W } & 37 & 44 & 55 & 66 & 80 \ \ \ m id r u le
a c c e le r a t io n \ u n itfr a c [ 0 ] { k m } { h } to \ u n itfra c [1 0 0 ]{ k m } { h } & \ u n it { s } & 2 2 ,7
& 1 8 ,8 & 1 3 ,7 & 1 1 ,7 & 9 ,8 \ \ \ ir iid r u le
\ t e x t b f {maximum speed}
& \ t e x t b f { \ u n it fr a c { k m } { h } }
& \ t e x tb f{ 1 3 3 } & \ t e x tb f{ 1 4 0 } & \t e x tb f{ 1 5 5 }
& \ t e x tb f{ 1 6 5 } & \ t e x tb f{ 1 7 8 } \ \ \ m id r u le
f u e l co nsu m ptio n p e r \ u n it [ 1 0 0 ] {km} & \ u n i t { l } & 8 ,6 & 8 ,7 & 9 ,4 (s u p e r)
& 9 ,9 (s u p e r) & 1 0 ,1 (s u p e r) \ \ \ b o t t o m r u le
\ e n d { ta b u la r}
\e n d { c e n te r}
\ e n d { s id e w a y s ta b le }
06-00-36 j
200
E x a m p le s
\u s e p a c k a g e { a rra y , t a b u la r x , b o o k ta b s , r o t a t i n g , u n i t s , c a p tio n }
\ n e w c o lu m n ty p e { N } { > { \s c rip ts iz e } l}
\news avebox\TBox
\s a v e b o x \T B o x { \p a rb o x { \lin e w id th } { %
\ c a p tio n o f { ta b le } { T h e f o llo w in g t a b le was r o t a t e d w it h \ t e x t t t { r o t a t e b o x } . }
\b e g in { ta b u la r} { @ { } N N * { 5 } { l} @ { } } \to p ru le
c a p a c it y & $ \u n it{ c m A3}$ & 1288 & 1488 & 1688 & 1985 & 2274 \ \ \ m id r u le
power & \u n it{k W } & 37 & 44 & 55 & 66 & 80 \ \ \ m id r u le
a c c e le r a t io n \ u n itfr a c [ 0 ] { k m } { h } to \u n itfra c [ 1 0 0 ] { k m } { h }
& \ u n it { s } & 2 2 ,7 & 1 8 ,8 & 1 3 ,7 & 1 1 ,7 & 9 ,8 \ \ \ m id r u le
\textbf{m axim um speed} & \ t e x t b f { \ u n it fr a c { k m } { h } } & \ t e x tb f{ 1 3 3 }
& \ t e x tb f{ 1 4 0 } & \ te x tb f{ 1 5 5 } & \ t e x tb f{ 1 6 5 } & \ t e x tb f{ 1 7 8 } \ \ \ m id r u le
f u e l consu m ption p e r \ u n it [ 1 0 0 ] {km}
& \ u n i t { l } & 8 ,6 & 8 ,7 & 9 ,4 ( s u p e r)& 9 ,9 (su p e r)& 1 0 ,1 (s u p e r) \ \ \ b o t to m r u le
\e n d { ta b u la r} } }
\ b e g in { ta b u la r x } \ lin e w id th { @ { } 1 X @{}}
\ r a is e b o x { - l.3 \ h e ig h t} { \ r o ta te b o x { 9 0 } { \ u s e b o x \ T B o x } } & \ b lin d t e x t
\e n d { ta b u la rx }
06-00-37 ]
Hello, here is some text without a
meaning. Thistextshouldshow,howa
printedtextwill looklikeatthisplace.
Ifyoureadthistext,youwill getnoin
Q formation. Really?Istherenoinforma
3h tion?Isthereadifferencebetweenthis
textandsomenonsenselike»Huardest
1 § On g i gefburn«. Kjift - Never mind! A
blindtext likethisgivesyouinforma
tionabout the selectedfont, howthe
1 lettersarewrittenandtheimpression
§ s 5 s O'. of thelook. Thistext shouldcontain
all lettersofthealphabetanditshould
S' bewritteninoftheoriginal language.
Thereisnoneedforaspecial contents,
1 E 3 3 !<> but thelengthofwordsshouldmatch
tothelanguage.
1 3 2£
1 £ 3 S 5
! 1 « î _
1 I
i
1 l
1 a 1
i
I t 1 1 1
201
E x a m p le s
\p s s e t{ n o d e s e p = 2 p t, arrows=->}
\ r e s iz e b o x { ! } { 0 . 5 \te x th e ig h t} { %
\b e g in {ta b u la r}{@ {}l* 4 {p {2 cm }}@ {}}
& 5 y e a r & 10 y e a r & 15 y e a r & 20 y e a r \ \
\G ra p h T a b L in e { P ro s ta te } ( 9 9 ,9 5 ,8 7 ,8 1 ) \ \
\G ra p h T a b L in e { T h y ro id } ( 9 6 ,9 6 ,9 4 ,9 5 ) \ \
\G ra p h T a b L in e { T e s tis } ( 9 5 ,9 4 ,9 1 ,8 8 ) \ \ [ - 1 5 p t ]
\G raph TabLin e{M elan om as} ( 8 9 ,8 7 ,8 4 ,8 2 ) \ \ [- 1 5 p t ]
\G ra p h T a b L in e { B re a s t} ( 8 6 ,7 8 ,7 1 ,6 5 ) \ \ [ - 4 5 p t ]
\G ra p h T a b L in e { H o d g k in ’ s d is e a s e } ( 8 5 ,8 0 ,7 4 ,6 7 ) \ \ [ - 1 0 p t ]
\G ra p h T a b L in e {C o rp u s u t e r i , u te ru s } ( 8 4 ,8 3 ,8 1 ,7 9 ) \ \ [ - 1 0 p t ]
\G ra p h T a b L in e { U rin a r b la d d e r} ( 8 2 ,7 6 ,7 0 ,6 7 ) \ \ [ - 2 7 p t ]
\G ra p h T a b L in e { C e rv ix u t e r i} ( 7 1 , 6 4 , 6 3 ,6 0 ) \ \ [ - 2 5 p t ]
\G ra p h T a b L in e {L a ry n x } ( 6 9 , 5 7 , 4 6 ,3 7 ) \ \ [ - 3 5 p t ]
\G raphTabLine{R ectum } ( 6 3 , 5 5 ,5 2 ,4 9 ) \ \ [ - 3 5 p t]
\G ra p h T a b L in e { K id n e y , r e n a l p e lv is } ( 6 2 , 5 4 ,5 0 ,4 7 ) \ \ [ - 2 5 p t]
\G ra p h T a b L in e {C o lo n } ( 6 2 , 5 5 , 5 4 ,5 2 ) \ \ [ - 2 0 p t ]
\G ra p h T a b L in e {N o n -H o d g k in ’ s} ( 5 8 ,4 6 ,3 8 ,3 4 ) \ \ [- 6 3 p t ]
\G ra p h T a b L in e { O ra l c a v it y , ph aryn x} ( 5 7 , 4 4 , 3 8 ,3 3 ) \ \ [ - 1 0 p t ]
\G ra p h T a b L in e {O vary} ( 5 5 , 4 9 , 5 0 ,5 0 ) \ \ [ - 1 0 p t ]
\G rap h T a b Lin e {Le u kae m ias} ( 4 3 ,3 2 ,2 9 ,2 6 ) \ \ [ - 1 0 p t ]
\G ra p h T a b L in e { B ra in , n e rvo u s s y s te m } ( 3 2 ,2 9 ,2 7 ,2 6 ) \ \ [ - 1 0 p t]
\G r a p h T a b L in e { M u ltip le myeloma} (3 0 ,1 3 , 7, 5 ) \ \ [ - 1 5 p t ]
\G raph TabLin e{Stom ach} ( 2 4 ,1 9 ,1 9 ,1 5 ) \ \ [ - 2 0 p t ]
\G rap h T a b Lin e {Lu n g and b ro n ch u s} (1 5 ,1 1 , 8, 6 ) \ \ [ - 2 0 p t ]
\G rap h T a bLin e {Esoph agu s} (1 4 , 8, 8, 5 ) \ \ [ 30pt]
\ G r a p h T a b L in e { L iv e r , b i l e d u c t} ( 8, 6, 6, 8 ) \ \
\G ra p h T a b L in e {P a n cre a s} ( 4, 3, 3, 3)
\e n d { ta b u la r} }
202
E x a m p le s
Thyroid
Testis
Melanomas
Breast
Hodgkin’s disease
Cervix uteri
Larynx
Rectum
Kidney, renal pelvis
Colon
Non-Hodgkin’s
Oral cavity, pharynx
Ovary
Leukaemias
Stomach
Lung and bronchus
Esophagus
203
E x a m p le s
\u s e p a c k a g e { n u m p rin t, s p re a d ta b }
\ b e g in { m in ip a g e } [ t] { 0 . 4 5 \ lin e w id th } \ v s p a c e { 0 p t }
\ [ \ f o r a l l x \ in \m ath bf{R }\qqu ad e Ax=\sum_{k=0}A\ i n f t y \ f r a c { x Ak } { k ! } \ ]
The a d ja c e n t t a b le shows th e co nve rge n ce f o r $x= 0.5$.
\ e n d { m in ip a g e } \ h f ill
\ b e g in { m in ip a g e } [ t] { 0 . 4 5 \ lin e w id th } \ v s p a c e { 0 p t}
\S T au to rou nd{1 5 }
\ b e g in { s p r e a d ta b } [ \ S T s a v e c e ll\ x v a lu e { a l} ] { { ta b u la r } { c N { 2 } { 1 5 } } }
\m u ltic o lu m n { 2 } { c } { c o n v e rg e n c e f o r $ x = { \n u m p rin t{ := { 0 .5 } } } $ } \\[1 .5 e x ]
@$n$ & e Aa l\ S T h id e c o l & {@
$ \ d is p la y s t y le e A{\n u m p rin t\x v a lu e } -\s u m _ { k = 0 } An
\ f r a c { \ n u m p r in t \ x v a lu e Ak } { k ! } $ } \ \ [ 3 e x ]\ h li n e
0 & a l A [ - l, 0 ] / f a c t ( [-1 ,0 ] ) & b 2 -[- 1 , 0 ] \\
[ 0 , - l ] + l & a l A [ - 1 , 0 ] / f a c t ( [ - 1 , 0 ] ) + [ 0 , - 1 ] & b 2 -[- 1 , 0 ] \\
[ 0 , - l ] + l & a l A [ - 1 , 0 ] / f a c t ( [ - 1 , 0 ] ) + [ 0 , - l] & b 2 -[- 1 , 0 ] \\
[ 0 , - l ] + l & a l A [ - 1 , 0 ] / f a c t ( [ - 1 , 0 ] ) + [ 0 , - l] & b 2 -[- 1 , 0 ] \\
[ 0 , - l ] + l & a l A [ - 1 , 0 ] / f a c t ( [ - 1 , 0 ] ) + [ 0 , - 1 ] & b 2 -[- 1 , 0 ] \\
[ 0 , - l ] + l & a l A [ - 1 , 0 ] / f a c t ( [ - 1 , 0 ] ) + [ 0 , - 1 ] & b 2 -[- 1 , 0 ] \\
[ 0 , - l ] + l & a l A [ - 1 , 0 ] / f a c t ( [ - 1 , 0 ] ) + [ 0 , - l] & b 2 - [ - l, 0 ] w
[ 0 , - l ] + l & a l A [ - 1 , 0 ] / f a c t ( [ - 1 , 0 ] ) + [ 0 , - l] & b 2 - [ - l, 0 ] w
[ 0 , - l ] + l & a l A [ - 1 , 0 ] / f a c t ( [ - 1 , 0 ] ) + [ 0 , - 1 ] & b 2 - [ - l, 0 ] w
[ 0 , - l ] + l & a l A [ - 1 , 0 ] / f a c t ( [ - 1 , 0 ] ) + [ 0 , - 1 ] & b 2 - [ - l, 0 ] \ \ \ h l i n e
\e n d { s p re a d ta b }
\e n d {m in ip a g e }
The adjacent table shows the convergence 0 0,648 721 270 700 128
for x = 0.5. 1 0,148 721 270 700 128
2 0,023 721 270 700 128
3 0,002 887 937 366 795
4 0,000 283 770 700 128
5 0,000 023 354 033 461
6 0,000 001 652 644 572
7 0,000 000 102 545 366
8 0,000 000 005 664 166
9 0,000 000 000 281 877
\ u s e p a c k a g e { ta b u la rx ,n u m p rin t, sp re a d ta b }
\ n p r o u n d d ig its 2
\ b e g in { s p r e a d ta b } { { ta b u la r x } { 0 . 8 \ lin e w id t h } { |
> { \ ru le [ -1 .2 e x ] { 0 p t} { 4 e x } } X > { { \ b fs e rie s } } N 4 2
> { \ b f s e r ie s } c N42 > { \ b f s e r ie s } c N 4 2 | } } \ h lin e
@Pos. & @ \ m u ltic o lu m n { l} { c } { p r ic e / u n it } & @ \m u ltico lu m n {l}{c}{n u m b e r} &
204
E x a m p le s
\u s e p a c k a g e { b o o k ta b s , p a r a l i s t , d co lum n , ragged2e}
\n e w e n v iro n m e n t{ V o rte ile }
{ \h b o x { } \ v s p a c e { - \ b a s e lin e s k ip } \ b e g in { c o m p a c tite m } [ $ \ o p lu s $ ] }
{ \h b o x { } \v s p a c e { -\ b a s e lin e s k ip } \ e n d { c o m p a c tite m } }
\n ew en viron m en t{ N a c h te ile }
{ \ h b o x { } \v s p a c e { -\ b a s e lin e s k ip } \ b e g in { c o m p a c tite m } [ $ \o m in u s $ ]}
{ \h b o x { } \v s p a c e { -\ b a s e lin e s k ip } \ e n d { c o m p a c tite m } }
\n e w co lu m n typ e {v}[ 1 ] {> {\R ag g e d R igh t\h sp a ce {O p t}}p {# l}}
\ s f f a m ily \ f o o t n o t e s iz e
\b e g in { ta b u la r} { @ { } v { 1 .4 cm } * { 2 } { v { 6 .9 c m } } @ { } } \to p ru le
M a t e r ia l & V o r t e il e & N a c h t e ile \ \ \ c m id r u le ( r ) { l- l} \ c m id r u le ( r l) { 2 - 2 } \ c m id r u le ( l) { 3 - 3 }
E d e ls t a h l
& \ b e g in { V o r t e ile }
\ ite m ro b u s t \ ite m p r e is g ü n s t ig \ ite m l e i c h t zu v e r a r b e it e n
\ ite m u n t e r s c h ie d lic h e D urchm esser und Längen im H andel e r h ä l t l i c h
\ e n d { V o r t e ile }
& \ b e g in { N a c h te ile }
\ ite m n u r in e r t b e i g e rin g e n Tem peraturen i n V erbin d u n g m it bestim m ten S u bsta n ze n
\ ite m O x id a tio n e n d e r O b e rflä c h e fü h re n zu unsym m etrischen Peaks
205
6 E x a m p le s
\ ite m Z e rs e tz u n g du rch V e ru n re in ig u n g e n d e r L e g ie ru n g s fo rm
\ e n d { N a c h te ile } \ t a b u la r n e w lin e \ c m id r u le ( r ) { l- l} \ c m id r u le ( r l) { 2 - 2 } \ c m id r u le ( l) { 3 - 3 }
G la s
& \ b e g in { V o rte ile } %
\ ite m f a s t v o ll s t ä n d ig in e r t
\ ite m d u r c h s ic h t ig , b e s s e re K o n t r o lle d e r Packung a u f G le ic h m ä ß ig k e it
\e n d { V o rte ile } %
& \b e g in { N a c h te ile } %
\ ite m aufw en dige R e in ig u n g d e r S ä u le
\ ite m k e in e A n a ly s e von a g g r e s s iv e r F lu o r id e m ö g lic h
\ ite m l e i c h t z e r b r e c h lic h
\ ite m K n a llg a s e x p lo s io n beim Z e rb re ch e n b e i e r h i t z t e r K a p ill a r e und
W a s s e r s to ff a ls T rä g e rg a s
\ e n d { N a c h te ile } \ t a b u la r n e w lin e \ c m id r u le ( r ) { l- l} \ c m id r u le ( r l) { 2 - 2 } \ c m id r u le ( l) { 3 - 3 }
N ic k e l
& \ b e g in { V o rte ile } %
\ ite m s t a b i l
\ ite m A n a ly s e von e m p fin d lic h e n S ub sta n ze n m ö g lic h , z \ , . B . S t e r o id e , A n a lg e t ic a
und B a r b it u r a t e
\e n d { V o rte ile } %
& \b e g in { N a c h te ile } %
\ ite m n ic h t so in e r t w ie G la s s ä u le n
\ e n d { N a c h te ile } \ t a b u la r n e w lin e \ c m id r u le ( r ) { l- l} \ c m id r u le ( r l) { 2 - 2 } \ c m id r u le ( l) { 3 - 3 }
K u p fe r
& \ b e g in { V o rte ile } %
\ ite m l e i c h t zu v e r a r b e it e n
\e n d { V o rte ile } %
& \ b e g in { N a c h te ile }
\ ite m O b e rflä c h e i s t a u to x y d a b e l
\ ite m K u p fe r o x id o x id ie r t o rg a n is c h e S t o f f e
\ ite m u n g e e ig n e t wenn S a u e r s t o f f im T rä g e rg a s vorhanden i s t
\ ite m a u fw e n d ig e s H e r s t e llu n g s v e r f a h r e n
\ e n d { N a c h te ile } \ t a b u la r n e w lin e \ c m id r u le ( r ) { l- l} \ c m id r u le ( r l) { 2 - 2 } \ c m id r u le ( l) { 3 - 3 }
T e flo n
& \ b e g in { V o r t e ile }
\ ite m v o ll s t ä n d ig in e r t
\ ite m A n a ly s e von a g g re s s iv e n S u b sta n ze n m ö g lic h
\ e n d { V o r t e ile }
& \ b e g in { N a c h te ile }
\ ite m M a t e r ia l kann m ik ro p o rö s s e in , Spu ren elem en te d e r A u ß e n lu ft r u fe n n e g a tiv e
E f f e k t e b e i d e r A n a ly s e h e rv o r
\ e n d { N a c h te ile } \ t a b u la r n e w lin e \ c m id r u le ( r ) { l- l} \ c m id r u le ( r l) { 2 - 2 } \ c m id r u le ( l) { 3 - 3 }
S iliz iu m
& \ b e g in { V o r t e ile }
\ ite m f a s t v o ll s t ä n d ig in e r t
\ ite m nahezu u n b e g re n zte R o h s to ffr e s e r v e n
\ ite m a u to x y d a b le B ild u n g von n a t iv e n S iliz iu m d io x id e n
\ e n d { V o r t e ile }
& \ b e g in { N a c h te ile }
\ ite m z e r b r e c h lic h e r a ls M e t a lle
206
Material Vorteile
Edelstahl © robust
© preisgünstig
© leicht zu verarbeiten
© unterschiedliche Durchmesser und Längen im Handel
erhältlich
Cías © fast vollständig inert
© durchsichtig, bessere Kontrolle der Packung auf Gleich
mäßigkeit
Nickel © stabil
© Analyse von empfindlichen Substanzen möglich, z.B.
Steroide, Analgetica und Barbiturate
Kupfer © leicht zu verarbeiten
The solution shown below lets us format the content of the table cell almost arbitrarily. It
is based on a special environment that can be defined with the help of the environ package
by Will Robertson. In contrast to the usual KH^Xenvironments, the text between \begin{. . . }
and \end{. . . } is not output immediately, but saved in a command. Afterwards, the content
of the command can be processed in many ways before actually outputting it. In the following
example, the mentioned environment is used to define a new column modificator C. In
addition to centring, the content is mirrored vertically.
u A W \ u s e p a c k a g e { a rra y , e n v ir o n , g ra p h ic x }
06-00-42
\N e w E n v iro n { co lle ctC } { %
KTEX R iX etex
\ m b o x { } \s c a le b o x { l} [- l]{ %
X A Z
\ra is e b o x { -\ h e ig h t} { \B O D Y } } }
\n e w c o lu m n ty p e { C } { > { \b e g in { c o lle c tC } } c
< { \ e n d { c o lle c tC } } }
\ b e g in { t a b u la r } { | 1 C r | } \ h li n e
U & V &W \\
\LaTeX & \LaTeX & \LaTeX \ \
X & Y &Z \ \ \ h lin e
\e n d { ta b u la r}
Creating tables with a loop command is not always easy - creating a table in EfipX can be
a somewhat complex process.
\ u s e p a c k a g e { lt a b le x , ragged2e}
\keepXColum ns
\n e w co lu m n typ e {C }{> {\C e n te rin g }X }
\n e w co lu m n typ e {P }[ 1 ] { > { \C e n te rin g } p { # l} }
%------------------- A f t e r a s u g g e s tio n by D a v id K a s tru p -------------------
\n e w co m m a n d \re p lica te [2 ]{\ifn u m # l> 0 #2%
\e x p a n d a fte r \ r e p lic a te \ e x p a n d a fte r { \ n u m b e r \ n u m e x p r # l- l} { # 2 } \ fi}
\newcommand*\NumberLines{79} \new counter{N }
\new com m and*\Space{\rule[ - 1 . 8mm]{Opt}{6mm}}
\ b e g in { ta b u la r x } { \ lin e w id th } { | r | c | P { 3 c m } | C | P { 3 c m } | } \ h li n e
\t e x tb f{ N o } & \ t e x t b f { f i r s t name} & \ t e x t b f { la s t name}
& \ t e x t b f { a d d r e s s } & \ t e x t b f { s ig n a t u r e } \S pa ce \ \ \ h li n e
\endhead
%
\re p lic a te { \ N u m b e rL in e s } { \ s te p c o u n te r{ N } \ th e N &&&& \S pace \ \ \ h lin e }
°/o
\e n d { ta b u la rx }
208
E x a m p le s
A survey A survey
| 06-00-43
No first name last name address signature No first name last name address signature
1 27
2 28
3 29
4 30
5 31
6 32
7 33
8 34
9 35
10 36
11 37
12 38
13 39
14 40
15 41
16 42
17 43
18 44
19 45
20 46
21 47
22 48
23 49
24 50
25 51
26 52
\u se p a cka g e {b o o k t a b s}
\usepackage{dcolu m n}
\new com m and\m c[l]{\m u lticolum n {l}{@ {}c@ {}}{# l}}
\n e w co lu m n typ e {x}{D {. } { . } { 3 . 2 } @ { \k e rn lp t\% \k e rn l0 p t} }
\n e w co lu m ntype {y}{D {. } { . } { 3 . l}@ {\% \k e rn lO p t}}
\b e g in { ta b u la r} { @ { } r @ {\kern2pt} y y y x y x y yy @ { } } \to p ru le
&\mc{CSY} & \m c{Eza ki} &\mc{Holz}&\mc{Maddison}&\mc{W ong} &\mc{Chow} &\mc{Wang}
&\m c{Scheibe}&\rac{IMF} \ \
&\mc{} &\mc{and Sun}&\mc{} &\mc{} &\mc{and Chan}&\mc{and Li}& \m c{and Yao}
&\mc{} & \m c {}\\
&\mc{2006}&\mc{1999} &\mc{2005}&\mc{2007} &\mc{2003} &\mc{2002} &\mc{2003}
&\mc{2003} & \m c { } \ \ \ m id ru le
1978 & 1 1 .7 &\mc{} & 11 .7 & 7 .7 1 &\mc{} & 7 .6 0 & 7 .6 & 7 .6 &\mc{} w
1979 & 7 .6 &\mc{} & 7 .6 & 3 .3 7 &\mc{} & 7 .8 1 & 7 .8 & 7 .6 &\mc{} w
1980 & 7 .8 &\rac{} & 7 .8 & 5 .98 &\mc{} & 5.2 6 & 5 .2 & 5 .2 & 7 .9 w
1981 & 5 .2 & 5 .2 & 5.2 & 7 .5 2 & 5 .3 & 9 .0 1 & 9 .1 & 9 .1 & 4 .7 w
1982 & 9 .1 & 9 .3 & 9 .1 & 8 .4 8 & 1 2 .1 & 1 0.89 & 1 0 .9 & 1 0 .9 & 9 .1 w
1983 & 1 0 .9 & 1 1 .2 & 1 0 .9 & 1 2 .4 5 & 9 .6 & 1 5.18 & 1 5 .2 & 1 5 .2 & 1 0 .9 \ \ \ b o t t o m r u le
% \mc{} i n empty c e l l s to p re v e n t o u tp u t o f th e % c h a r a c te r
\ e n d { ta b u la r}
209
E x a m p le s
CSY Ezaki Holz Maddison Wong Chow Wang Scheibe IMF | 06-00-44 |
and Sun and Chan and Li and Yao
2006 1999 2005 2007 2003 2002 2003 2003
1978 11 .7 % 11.7% 7.71% 7.60% 7.6% 7.6%
1979 7. 6% 7.6% 3.37% 7.81% 7.8% 7.6%
1980 7. 8% 7.8% 5.98% 5.26% 5.2% 5. 2% 7.9%
1981 5.2% 5. 2% 5.2% 7.52% 5. 3% 9.01% 9.1% 9.1% 4. 7%
1982 9. 1% 9. 3% 9.1% 8.48% 12.1% 10.89% 10.9% 10.9% 9.1%
1983 10.9 % 11.2% 10 .9 % 12.45% 9. 6% 15.18% 15.2% 15.2% 10.9%
\u s e p a c k a g e { ta b to }
\ b ig s k ip
\ b e g in { te s tA r e a }
\ T a b P o s it io n s { l. 5cm, 5cm, 8cm}
duck \ t a b goose \ t a b t u r k e y \ t a b c o o t \p a r
\ta b \ta b \ t a b g ro u se
\e n d { te s tA re a }
\ b ig s k ip
\ b e g in { te s tA r e a }
duck \ t a b to { l.5 c m } goose \ta b to {5 cm } tu r k e y \tab to {8 cm }
c o o t \ p a r \ta b to {8 cm } gro u se \tab to * {4 cm } p e lic a n
\ e n d { te s tA re a }
0 1 2 3 4 5 6 7 8 9 10 11 12 13
210
E x a m p le s
f ir s t n a m e ;la s tn a m e ;s t r e e t ; c i t y ;to p a y ;p a id
N i c o l e ;M ü ll e r ;S c h i l l e r p l a t z 61;18419 V o g e lo w ;1 0 0 ,0 ;1 0 0 ,0
Tom;Lehmann;N a c h t ig a llg a s s e 11;29098 A lt a u e ; 1 0 0 ,0 ;1 0 0 ,0
T im ;W agner;A m s e lp la tz 92;46917 Langenhausen;1 0 0 ,0 ;0 ,0
M o r it z ;M ü ll e r ;W a ld a lle e 71;55348 K ir c h s t e i n ; 1 0 0 ,0 ;0 ,0
S u s i;M a y e r;Sonnenweg 2 7 a ;83675 H e id e h a u se n ;1 0 0 ,0 ;1 0 0 ,0
I n e s ;M a y e r;W a s s e ra lle e 8 3 a ;26118 K i r c h f u r t ;1 0 0 ,0 ;1 0 0 ,0
U w e ;M e ie r;S o n n e n p la tz 7;07514 V o g e lb u rg ;1 0 0 ,0 ;0 ,0
M andy;B e r g e r ;Goetheweg 25;03783 W o lf e n t a l; 1 0 0 ,0 ;1 0 0 ,0
T im ;G rö n w a ld ;W ie s e n p la tz 9 a ;90778 Moosow;1 0 0 ,0 ;5 0 ,0
Je n n y ;K ö s t e r ;F in k e n a lle e 2 9 c ; 53522 W iesenow ;1 0 0 ,0 ;1 0 0 ,0
M a rk o ;M a y e r;Amselweg 1 1 c ;32108 G r ü n s t e in ;1 0 0 ,0 ;1 0 0 ,0
J e n n y ;B e r g e r ;W ie s e n a lle e 82;72044 M o o s a u e ;0 ,0 ;0 ,0
\u s e p a c k a g e { d a ta to o l}
\u se p a cka g e {e u ro sy m , b o o k tab s}
\ D T L s e ts e p a r a to r { ;}
\D T L se tn u m b e rch a rs{ } { ,}
\ D T L s e td e fa u ltc u rre n c y { \ te x te u ro ~ }
\ D T L lo a d d b { lis t} { d a ta / d a ta 2 d .c s v }
\D T L s o rt{ la s tn a m e , f ir s t n a m e } { lis t }
\ D T L s u m fo r k e y s { lis t} { to p a y } { \ d e b it}
\ D T L s u m f o r k e y s { lis t } { p a id } { \ c r e d it }
\ s m a ll\ a d d t o le n g t h \ t a b c o ls e p { - lp t }
\b e g in { ta b u la r} { @ { } r 1111 r r @ { } } \to p ru le
ID & f i r s t name & l a s t name & s t r e e t & c i t y & to pay & p a id \ \ \ m id r u le
\ D T L fo re a c h { lis t} { % d e fin e d l i s t e le m e n ts
\ f ir s t = f i r s t n a m e , \ la s t= la s tn a m e , \ a d d r e s s = s t r e e t ,
\ t o w n = c ity , \fe e = to p a y , \paid= paid}{%
\ \ \th e D T L ro w i & \ f i r s t & \ l a s t & \a d d re s s & \tow n & \ e u r o \ , %
\ D T L if c u rre n c y { \ fe e } % i f \ f e e i s a c u rre n c y
{ \ D T L c o n v e rtto d e c im a l{ \ fe e } { \ fe e } % th e n c o n v e rt to d e c im a l
% and save th e c o n v e rte d v a lu e i n
% \fe e
{ \ fe e } } % o u tp u t th e v a lu e o f \ f e e
{ \ fe e } % i f no c u rre n c y , th e n o n ly o u tp u t
& \ e u r o \ , \D T L ifc u rre n c y { \p a id } % i f \ p a id i s a c u rre n c y
{ \D T L c o n v e rt to d e c im a l{ \ p a id } { \ p a id } { \ p a id } } % th e n c o n v e rt
{ \ p a id } } \ \ \ m id r u le % e ls e o u tp u t \ p a id
& & & & & \ D T L d e c im a lt o c u r r e n c y { \ d e b it } { \ d e b it } \ e u r o \ ,\ d e b it & %
\ D T L d e c im a lt o c u r r e n c y { \ c r e d it } { \ c r e d it } \ e u r o \ , \ c r e d it \ \ \ b o t to m r u le
\ e n d { ta b u la r}
211
E x a m p le s
€ 1100,00 € 750,00
212
C h a p t e r
Q u e s t io n s a n d a n s w e r s
7.1 D o c u m e n ta tio n
Apart from a few exceptions, each package comes with its own documentation, which is part
of the TgX distribution just like the style or class file. You can consult this docum entation at
any tim e using the texdoc command. D epending on the operating system, the appropriate
program is started to show the file. Figure 7.2 on the next page shows the result of the
com m and “te x d o c t a b u l a r x ” in Linux. A lternatively, you can use the graphical texdoctk
environm ent (Figure 7.1), though the list of packages available in it is som ew hat dated. An
example of the output is shown in Figure 7.3 on the next page.
Some authors don’t provide self-contained documentation, but give hints in the package
file itself, for example the t h r e e p a r t t a b l e package. If there is an appropriate link to the
Q u e s t io n s a n d a n s w e rs
package, texdoc will show this file as well. The location o f a package can be found through
the com m and kpsewhich < file > , w hich yields the result in Figure 7.4 on the facing page
for the W indows com m and line. Now the file can be loaded and the description read w ith a
2T4
7.2 T a b le s as f lo a tin g o b je c ts
norm al editor. If there is no output, the package is either not installed or you have spelt the
name of the package incorrectly.
Figure 7.4: Use of the program kpsewhich on the Windows command line.
Very often, the TgX sources of the docum entation can be of help, letting you see at once 3gk sources
how certain things were achieved. All source files for TpX Live can be found at $TEXMF/texmf-
d i s t / s o u r c e / l a t e x / and for MiKTgX in the directory . . .\MiKTeX Z .SX source.1
\u se p a c k a g e {lo n g ta b le }
\c a p tio n demo
\ b e g in { lo n g t a b le } { | c | } \ h lin e
A \ t e x t t t { l o n g t a b l e } w ithout
Table 2: A table caption with \ t e x t t t { \ t e x t b a c k s la s h c a p t io n } . \ \ \ h lin e
the wrong number. \e n d {lo n g ta b le }
A normal table. \ b e g in {t a b le }
\c e n te rin g
\ca p tio n {A ta b le cap tio n w ith
th e wrong number. }
A l o n g t a b l e without \c a p tio n . \ b e g in { t a b u la r } { | c | } \ h lin e
A normal t a b l e . \ \ \ h lin e
\e n d {ta b u la r}
\e n d {ta b le }
page 1
'Adapt this path accordingly for versions of MiKTjrX other than 2.8.
215
Q u e s tio n s a n d a n s w e r s
The problem can be fixed by decrementing the table counter tab le after a longtable
without caption.
\caption demo \ u s e p a c k a g e { lo n g ta b le }
\ b e g in { lo n g t a b le } { | c | } \ h lin e
A \ t e x t t t { lo n g t a b le } w ith o u t
Table 1 : A table caption with \ t e x t t t { \ t e x t b a c k s la s h c a p t io n } . \ \ \ h lin e
the correct number. \ e n d { lo n g ta b le }
\addtocounter{table}{-l}% % % % %
A normal table.
\ b e g in { t a b le }
\ c e n t e r in g
\ c a p tio n { A t a b le c a p tio n w ith th e c o r r e c t num ber.}
A longtable without \caption. \ b e g in { t a b u la r } { | c | } \ h lin e
A norm al t a b l e . \ \ \ h l i n e
\ e n d { ta b u la r}
\e n d { ta b le }
pagel
216
Bibliography
[1 ] Paul W. Abrahams, Karl Berry und Kathryn Hargreaves. TgK for the Impatient,
2003. ctan: /in fo /im p a tie n t/b o o k .p d f
[3] Hendri Adriaens und Uwe Kern, »xkeyval - new developments and mechanism in key
handling«. TUGboat, 25(2): 194-198, 2004.
[4] Donald Arseneau. The th re e p a rtta b le package, 2003. Version 3.0.
ctan : / m a c r o s / la te x / c o n tr ib / ltx m is c /
[2 1 ] Michael Downes. Short Math Guide for Щ[?Х. American Mathematical Society,
2002. h t t p : / / w w w .a m s . o r g / t e x / s h o r t - m a t h - g u i d e . h t m l
[26] Michel Goossens, Frank Mittelbach, Sebastian Rahtz, Denis Roegel und Herbert Vofi.
The ETeX Graphics Companion: Illustrating Documents with TgX and PostScript, Second
Edition. Tools and Techniques for Computer Typesetting. Addison-Wesley, Reading,
MA, 2007.
[27] Eckhart Guthohrlein. The rc co l package, 2005. Version 1 .2 c.
ctan:/macros/latex/contrib/rccol/
[28] Alan Hoenig. TpX Unbound: ETjX & T^X Strategies, Fonts, Graphics, and More. Oxford
University Press, London, 1998.
[29] Uwe Kern. Color extensions with the xcolor package, 2007. Version 2 .1 1 .
ctan: / m a c r o s / l a t e x / c o n t r i b / x c o l o r /
218
B IB L IO G R A P H Y
[30] Donald E. Knuth. The TpXbook. Addison Wesley Professional, 2 1 . Auflage, 1986.
[31] Markus Kohm. »Satzspiegelkonstruktionen im Vergleich«. Die T on isch e Komödie,
14(4):28-48, 2002. h t t p ://www.da nt e.de/dante/DTK/PDF/komoedie_2002_4.pdf
[36] Jerry Leichter und Piet van Oostrum. The bigdelim package, 1994. Version 1 .
ctan:/macros/latex/contrib/multirow/
[37] Jerry Leichter und Piet van Oostrum. The b ig stru t package, 1994. Version 1 .
ctan: /macros/latex/contrib/multirow/
[38] Jerry Leichter und Piet van Oostrum. The multirow package, 2004. Version 1 .6 .
ctan:/macros/latex/contrib/multirow/
[39] Hubert Gäßlein und Rolf Niepraschk. The pict2e package, 2004.
ctan:/macros/latex/contrib/pict2e/
[41] Frank Mittelbach und David Carlisle. The array package, 2008. Version 2.4c.
ctan:/macros/latex/contrib/tools/
[42] Frank Mittelbach, Michel Goosens, David Carlisle und Johannes Brahms. The EüpX
Companion. Pearson Education, Reading, MA, 2 . Auflage, 2004. The general book to
etex .
[43] Lapo Filippo Mori. »Tables in ET]pX 2 £: Packages and Methods«. The PracT^C Journal,
(1):1—38, 2007.
[44] Hiroshi Nakashima. The arydshln package, 2004. Version 1.71.
ctan:/macros/latex/contrib/arydshln/
219
B IB L IO G R A P H Y
[48] Scott Pakin. The Comprehensive ШрХ Symbol List. CTAN, 2009.
ctan: /info/symbols/comprehensive/symbol-a4 .pdf
[53] Nicola Talbot. Databases and data manipulation, 2009. Version 2.03.
ctan:/ macros/latex/contrib/datatool/
[54] The ЩеХ team, clsguide - documentation pf íflpX class and package writing,
2003. ctan: /macros/latex/base/clsguide.pdf
[55] Herbert Voß. PSTricks - Grafik mit PostScript für TjX und fflpX.
DANTE/LOB-media.de, Berlin, 5. Auflage, 2008.
[56] Herbert Voß. Mathematiksatz mit Щ^Х. DANTE/LOB-media.de, Berlin, Heidelberg,
2009.
[57] Herbert Voß. ВДеХ Referenz. DANTE/LOB-media.de, Berlin, Heidelberg, 2 . Auflage,
2010 .
[58] Michael Wiedmann. References for ТрХ and Friends, 2005.
http ://www.miwie.org/tex-refs/
[61] Joseph Wright. The siu n itx package, 2009. Version 1.3c.
ctan:/ macros/latex/contrib/siunitx/
220
Index of commands and
concepts
To make it easier to use a command or concept, the entries are distinguished by their “type”
and this is often indicated by one of the following “type words” at the beginning of an entry:
boolean, counter, document class, env., file, file extension, font, font encoding,
key value, keyword, length, option, package, program, rigid length, or syntax.
The absence of an explicit “type word” means that the “type” is either a TgX or KT£X
“command” or simply a “concept”.
Use by, or in connection with, a particular package is indicated by adding the package
name (in parentheses) to an entry.
An italic page number indicates that the command is demonstrated in a source code
snippet or in an example on that page.
When there are several page numbers listed, bold face indicates a page containing impor
tant information about an entry.
(S y m b o ls -B ) In d e x o f c o m m a n d s a n d c o n c e p ts
222
In d e x o f c o m m a n d s a n d c o n c e p ts (C )
223
(D-G) In d e x o f c o m m a n d s a n d c o n c e p ts
224
In d e x o f c o m m a n d s a n d c o n c e p ts (H -L )
H K
h notation (mdwtab), 73 keyval package, 86
\hdashline \kill, 13, 14, 16, 139
(arydshln), 28, 29 (longtable), 139
(celIspace), 53, 54 kpsewhich program, 214
(datatool), 59
(dcolumn), 99 L
(tabularht), 85, 86
L notation (tabulary), 90
header, 24, 137,140, 148
1 notation, 4, 5, 53, 55, 57, 65, 91, 96,107, 124, 184-191
\heavyrulewidth rigid length (booktabs), 47
(booktabs), 48, 49
\height, 30
(easytable), 62, 63
height Option (tabularkv), 86, 87
(longtable), 125,130
\hhline (hhline), 64, 65 (makecell), 66
hhline package, 43, 64, 116 (mdwtab), 72
\hiderowcolors (xcolor), 118, 120, 121 (slashbox), 75
\hline, 6, 7, 8, 9, 46, 47, 49, 50, 83, 118, 122, 126, 153, 161 label, 59
(stabular), 145 \label, 134
(tabls), 83 label Option (ctable), 55
\hlx (mdwtab), 72, 73 last notation (xcolor), 121
\hrulefill, 170, 194 \lasthdashline (arydshln), 28, 29
HSB notation (xcolor), 117 \lasthline (array), 27, 28
hsb notation (xcolor), 117 \ldelim (bigdelim), 36, 37
\hsize, 88, 89 \Left (blkarray), 40
\hsize rigid length, 88 \left, 36, 118
\hspace, 15, 24, 126 left Option (ctable), 55, 58
HTML notation (xcolor), 117 left value (siunitx), 103
hyperref package, 117 left-aligned, 25
hyphenation, 24, 25 \lightrulewidth rigid length (booktabs), 47
line, 21, 43
I coloured, 7
ifthen package, 53 counter, 40
\inccell, 175 depth, 21
\includegraphics, 196 feed, 32
\inctab, 175 height, 21
inline mode, 22 horizontal, 7, 43
\input,142, 169 spacing, 7, 53
vertical, 6, 26, 43
input env., 169
\linewidth rigid length, 87-89 ,109
input-decimal-markers Option (siunitx), 102, 105, 106
list of tables, 132, 133
input-digits Option (siunitx), 102, 105, 106
listings package, 14,107
input-exponent-markers Option (siunitx), 102
\LL (ctable), 54, 57
input-ignore Option (siunitx), 102
load-configuration Option (siunitx), 102
input-product Option (siunitx), 103
log file, 25
input-quotient Option (siunitx), 102
longtable
input-signs Option (siunitx), 103
table caption, 135
\insertTableNotes (threeparttablex), 93, 94
longtable env.
inter-unit-separator Option (siunitx), 103
(longtable), 52, 73, 125, 126-139, 142, 143, 151, 159,
\interrowfill (tabularht), 85
169, 215
\interrowspace (tabularht), 85, 86
(Itxtable), 143
\interrowstart (tabularht), 85, 86
longtable package, 52,125-139, 140,141
\interrowstop (tabularht), 85, 86
longtable* env., 20
\item, 91
\LongTableWidth rigid length (demo), 169
(threeparttable), 93
lot, 132, 133
lr notation (slashbox), 75
J \ltablex
J notation (tabulary), 90 (Itablex), 140, 141
\jot rigid length, 35, 68, 69 (Itxtable), 143
225
(M-P) In d e x o f c o m m a n d s a n d c o n c e p ts
226
Index of commands and concepts (Q-R)
227
(S-T) Index of commands and concepts
s T
S notation t notation, 27, 65, 66, 68, 69
(cellspace), 53 (array), 26
(siunitx), 102, 103, 105, 106 (arydshln), 29
s notation (bigstrut), 32, 34
(mdwtab), 73 (blkarray), 44
(siunitx), 103, 106 (easytable), 62
sans-serif, 174 (hhline), 64
separator, 22 (tabularkv), 87
\setbox, 30 (threeparttable), 91
\s e tc e llg a p e s (makecell), 69 TAB env. (easytable), 62, 63, 64
\se tc o u n te r, 136 \TAB (Tabbing), 109
\s e tle n g th , 53 tab, 13, 17, 107, 108, 170
\setto w id th , 67 Xtab (tabto), 108, 109
\showcols (array), 25, 26 Tabbing env. (Tabbing), 109
\showrowcolors (xcolor), 118, 120, 121 Tabbing package, 14,109
\sh rin k h eig h t tabbing env., 12, 13-17, 107, 108, 109, 170, 171, 173
(supertabular), 152 (longtable), 139
(xtab), 160, 166 \tab b in g sep rigid length, 15
sideways Option (ctable), 55, 56, 57 \ta b c o lse p rigid length, 4-6, 10, 11, 30, 49, 75, 101, 112,
sidew aystable env. (rotating), 200, 201 113, 114, 115
\s is e tu p (siunitx), 102 (tabto), 108
siunitx package, 102 table, 117
\slashbox (slashbox), 75 colour, 37
slashbox package, 74, 83 framed, 26
\sm all, 23 head, 23
\smash (amsmath), 68 height, 84
sort, 61 nested, 9, 30
\span, 167 width, 4, 5, 7, 87
\s p e c ia lru le (booktabs), 47, 50, 51, 52 ta b le counter, 215, 216
\sp read rigid length (tabularht), 85 ta b le env., 125, 215
228
Index of commands and concepts (T)
229
(U-X) Index of commands and concepts
(ctable), 55 w
\tymax rigid length (tabulary), 90 warpcol package, 96
\tym in rigid length (tabulary), 90 wave notation (xcolor), 117
typography, 3 w idetable env. (widetable), 97
widetable package, 97, 98
u \width, 30
u n it-v a lu e -se p a ra to r Option (siunitx), 103 width Option
units package, 200, 201 (ctable), 55
use-xspace Option (siunitx), 103 (tabularkv), 86, 87
\usepackage, 116
V X
v notation (mdwtab), 73 X notation
valign Option (tabularkv), 86, 87 (Itxtable), 143
varwidth package, 24 (tabularx), 54, 55, 57, 87-89
\verb, 89 x Option (tabularkv), 86
\verb*, 89 X column, 88
version-1 value (siunitx), 102 xcolor package, 37, 56, 111, 116-121, 122
vertical line, 26 xdvi program, 116
\ v f i l l , 85 xkeyval package, 54
\vgap (mdwtab), 72 xspace package, 54
\v lin e , 23, 115 xtab env. (xtab), 158
(mdwtab), 72 xtab package, 157, 162
\v ru le, 26, 30, 87 x tab u lar env. (xtab), 157, 158,159, 161-166
\vspace, 85 xtabular* env. (xtab), 157, 158, 159, 160
230
P e o p le
Arseneau, Donald, 24, 82, 91, Ihlenburg, Lutz, 2 Oberdiek, Heiko, 84, 86, 169,
108, 172 170,174, 177
Jagger, Catherine, 2 Oostrum, Piet van, 30
Beccari, Claudio, 97 Junge, Stefan, 177
Bertolazzi, Enrico, 62 Jurriens, Theo, 149 Pearson, George, 175
Bordiert, Uwe, 177
Braams, Johannes, 149 Raichle, Bernd, 167,177
Kaeder, Christoph, 2 Reichert, Axel, 1,177
Carlisle, David, 21, 38, 64, 87, Kern, Uwe, 116 Robertson, Will, 208
90, 98, 111, 116,141 Knaak, Kai-Martin, 177 Rochester, Wayne A., 96
Charpentier, Jean-Côme, 177 Kohm, Markus, 177
Kotthoff, Lars, 2 Schaa, Volker RW, 2
Dekker, Wybo, 54 Schröder, Martin, 25, 88
Doerr, Hans-Peter, 175 Löh, Andres, 107
Drucbert, Jean-Pierre F., 109 Lapko, Olga, 65 Talbot, Nicola, 1, 58
Leichter, Jerry, 30 Tellechea, Christian, 76,177
Fear, Simon, 46 Tolusis, Sigitas, 145
Madsen, Lars, 93
Geiger, Christiane, 177 Wilson, Peter, 157
Marder, Joachim, 175
Goel, Anil K., 139 Wooding, Mark, 72
Guthöhrlein, Eckhart, 100 Mittelbach, Frank, 21
Wright, Joseph, 102
Gäßlein, Hubert, 74
N akashim a, H iroshi, 27 Yasuoka, Koichi, 74
Hogholm, Morten, 177 N iepraschk, Rolf, 2, 74, 177
Höppner, Klaus, 2 N oirel, Josselin, 53 Ziegenhagen, Uwe, 2,177
ALSO PUBLISHED BY UIT
From a simple equation to a mathematical treatise, this practical guide offers an in-depth
review of the mathematics typesetting aspects of the industry-leading typesetting software,
EQpX. Among the topics discussed in this manual are mathematics in line with normal text,
the software’s special mathematics mode, color in math expressions, and fonts and math.
Handy features include a list of mathematical symbols for quick-reference, a survey of a
wide range of additional mathematics packages—with a particular emphasis on the American
Mathematical Society package—and ready-to-run examples to enable users to get going
quickly.
This book will:
> Save you time by quickly giving you the detailed command syntax you require.
> Improve your mathematical typesetting by providing a reference to all the available com
mands.
> Showing the advantages of the packages from the American MAthematical Society
> Show you how to choose suitable math fonts, using the convenient samples of font output.
C o n te n ts
1. Introduction
2. Math in inline mode with standard
3. Math in display mode with standard I$IeX
4. Math elements from standard ET^X
5. Colour in math expressions
6. AMS packages
7. Symbols
8. TpX and math
9. Other packages
10. Examples
11. Fonts and math
12. Bibliography
ISBN: 9781906860172
290 pages
A L SO PUBLISH ED BY U IT
This book lists all ETgX macros and environments in a comprehensive reference format. (The
packages array and graphicx are included even though they are not part of standard ET^X,
because they are so widely used.) The book also lists examples of fonts for both plain text and
math, making it a convenient graphical resource.
This book will:
• Save you time by quickly giving you the detailed command syntax you require.
• Improve your ETgX by providing a quick-reference to all the available command options.
• Show you how to choose suitable fonts, using the convenient samples of font output.
C o n te n ts
1. The Standard Programs
2. Document Structure
3. Commands for Fine-Tuning your Typography
4. Command List
5. Lengths and Counters
6. Fonts
7. Packages
8. Bibliography
P r a is e fo r t h e G e r m a n E d itio n
ISBN: 9781906860219
160 pages
A L SO PU BLISH E D BY U IT
PSTricks
Graphics and PostScript for
Herbert Voss
A comprehensive guide to creating and including graphics in TeX and ETgX documents. It is
both a reference work and a tutorial guide.
PSTricks lets you produce very high-quality PostScript graphics, by programming rather
than interactive drawing. For designers, data publishers, scientists and engineers, generating
graphics from data or formulas instead of having to draw manually allows large data collections
or complex graphics to be created consistently and reliably with the minimum of effort.
There are many special-purpose extensions, for visualizing data, and for drawing circuit
diagrams, barcodes, graphs, trees, chemistry diagrams, etc.
Numerous examples with source code (freely downloadable) make it easy to create your own
images and get you up to speed quickly.
C o n te n ts
1. Introduction 2. Getting Started 3. The Coordinate System 4. Lines and Polygons 5.
Circles, Ellipses and Curves 6. Points 7. Filling 8. Arrows 9. Labels 10. Boxes 11. Custom styles
and objects 12. Coordinates 13. Overlays 14. Basics 15. Plotting of Functions and Data 16.
Nodes and Connections 17. Trees 18. Manipulating Text and Characters 19. Filling and Tiling
20. Coils, Springs and Zigzag Lines 21. Exporting PSTricks Environments 22. Color Gradients
and Shadows 23. Three-Dimensional Figures 24. Creating Circuit Diagrams 25. Geographic
Projections 26. Barcodes 27. Bar Charts 28. Gantt Charts 29. Mathematical Functions 30.
Euclidean Geometry 31. Additional Features 32. Chemistry Diagrams 33. UML Diagrams 34.
Additional PSTricks Packages 35. Specials 36. PSTricks in Presentations 37. Examples
P r a is e fo r t h e G e r m a n E d itio n
ISBN: 9781906860134
900 pages
Example illustrations from PSTricks
A L SO PU B LISH E D BY U IT
Practical TCP/IP
Designing, using, and troubleshooting
TCP/IP networks on Linux and W indow s
Niall Mansfield
R e p r in te d f i r s t e d itio n
K e y b e n e f it s
1. Explore, hands-on, how your network really works. Build small test networks in a few
minutes, so you can try anything out without affecting your live network and servers.
2. Learn how to troubleshoot network problems, and how to use free packet sniffers to see
what’s happening.
3. Understand how the TCP/IP protocols map onto your day-to-day network operation - learn
both theory and practice.
W h a t r e a d e r s h a v e s a id a b o u t t h is b o o k
"A c c u ra c y is su p e r b - w r itte n b y so m e o n e o b v io u s ly k n o w le d g a b le in th e su b je c t, a n d a b le
to c o m m u n ic a te th is k n o w le d g e e x tr e m e ly e ffe c tiv e ly ."
"It's a n id e a l b o o k f o r b e g in n e r s, p r o b a b ly th e o n ly o n e n e e d e d f o r th e f i r s t a n d se c o n d
s e m e ste r s o f a u n iv e r s ity n e tw o r k in g course. ... (B u t it is n o t a b o o k j u s t f o r b eg in n ers. ...)"
ISBN: 9781906860363
880 pages
A L SO PU BLISH ED BY U IT
Philip Hazel
S e c o n d e d itio n
Email is one of the most widely used applications, and Exim is one of the most widely used mail
servers, handling mail for tens of millions of users daily.
Exim is free software. It’s easy to configure. It’s scalable, running on single-user desktop
systems as well as on ISP servers handling millions of users. (It’s the default server on many
Linux systems, and it’s available for countless versions of UNIX.)
Exim is fast, flexible, and reliable. It is designed not to lose messages even if your server
machine crashes. It can be used as a secure Internet-facing front-end to other, proprietary, mail
systems used internally in your organization.
Exim supports lookups from LDAP servers, SQL databases, and other data sources, letting
you automate maintenance and configuration. It can work in conjunction with other tools for
virus-checking and spam-blocking, to reject unwanted emails before they even enter your site.
This book will help you deploy Exim as your SMTP email server throughout your organiza
tion, and to configure, tune, and secure your Exim systems.
P r a is e fo r t h e F ir st E d itio n
“I f th e r e ’s e v e n a w h if f o f a c h a n c e o f y o u h a v in g to c o m e in to c o n ta c t w ith E x im o r its
r u n tim e c o n fig u ra tio n , th e n I c a n d o n o th in g else b u t s tr o n g ly r e c o m m e n d th is book. T he
d e ta il’s th ere in sp a d e s, it rea d s v e ry well, a n d is a fin e c o m p le m e n t to th e referen ce m a n u a l.”
“W ell p r e s e n te d a n d e a s y to f o l lo w ”
“A n e x c e lle n t b o o k th a t is v e r y w e ll w r itte n ”
ISBN: 9780954452971
xviii + 622 pages
A L SO PU BLISH E D BY U IT
The Joy o f X
The architecture o f the X w indow system
N iall M ansfield
This is a reprint of the 1993 classic, describing the architecture of the X window system - the
de facto standard windowing system for Linux, UNIX and many other operating systems. The
book has three sections:
1. X in a nutshell - a quick overview.
2. How X works, in detail, and how the user sees it.
3. Using the system, system administration, performance and programming.
The book is written in a clear, uncomplicated style, with over 200 illustrations. For maximum
accessibility, it has a flexibile, modular structure that makes it easy to skip to the sections that
interest you. The book has been widely recommended as a course text.
Niall Mansfield founded the European X window system User Group. He also wrote T he X
w in d o w sy s te m : a u ser's g u id e , and the widely-acclaimed P ra c tic a l TCP/IP.
P r a is e f o r T h is B o o k
“I f y o u a re n e w to th e X W in d o w S y s te m e n v ir o n m e n t, w e s tr o n g ly s u g g e s t p ic k i n g u p a
b o o k su ch a s The J o y o f X " Eric Raymond, in the L i n u x X F r e e 8 6 H O W T O
ISBN: 9781906860004
xii + 372 pages
A L SO PUBLISH ED BY U IT
Jan-Piet Mens
This book examines many of the best DNS servers available. It covers each server’s benefits
and disadvantages, as well as how to configure and deploy it, and integrate it into your network
infrastructure. It describes the different scenarios where each server is particularly useful, so
you can choose the most suitable server for your site. A unique feature of the book is that it
explains how DNS data can be stored in LDAP directories and SQL databases, often required for
integrating DNS into large-organization infrastructures.
Other important topics covered include: performance, security issues, integration with DHCP,
DNSSEC, internationalization, and specialized DNS servers designed for some unusual purposes.
P r a is e fo r T h is B o o k
“A n in fo rm a tiv e a c c u ra te g u id e f o r a n y o n e in te r e s te d in le a r n in g m o re a b o u t D N S .”
Sam Trenholme, MaraDNS author
“J a n -P ie t h as d o n e a g r e a t j o b d e sc r ib in g P ow erD N S. ”
Bert Hubert, principal author o f PowerDNS
ISBN: 9780954452995
xxxvi + 694 pages
A L SO PU BLISH E D BY U IT
OpenStreetMap
Using and enhancing the free map o f the w orld
OpenStreetMap is a map of the whole world that can be used and edited freely by everyone. In
a Wikipedia-like open community process, thousands of contributors world-wide survey the
planet and upload their results to the OpenStreetMap database. Unlike some other mapping
systems on the Web, the tools and the data are free and open. You can use them and modify
them as you require; you can even download all the map data and run your own private map
server if you need to.
This book introduces you to the OpenStreetMap community, its data model, and the software
used in the project. It shows you how to use the constantly-growing OSM data set and maps in
your own projects.
The book also explains in detail how you can contribute to the project, collecting and
processing data for OpenStreetMap. If you want to become an OpenStreetMap “mapper” then
this is the book for you.
About the authors: Frederik Ramm and Jochen Topf both joined the OpenStreetMap project
in 2006, when they were freelance developers. Since then they have made their hobby their
profession - by founding Geofabrik, a company that provides services relating to OpenStreetMap
and open geodata.
P r a is e fo r t h e F ir st (G e r m a n ) E d itio n
“T he b o o k is v e r y w e ll w ritte n . I t is o b v io u s th a t th e a u th o r s h a v e a lo t o f k n o w le d g e a n d
e x p e r ie n c e ... ”
ISBN: 9781906860110
352 pages + 32 pages of color plates
I
<f* V P U b X - - I * ; »1“ 3 V U
Download Download more Select Move Rotate Node to ad Area
Layers
5 f~ Map • None
- ■» Dirty layer
* Uploaded layer
Email: inquiries@uit.co.uk
Phone: +44 1223 302 041
D u rr
C A M B R I D GH
T y p e s e t t in g ta b le s
w ith L y J ’f X
Herbert Voss studied electrical The LaTeX typesetting system is free, and runs on just about
engineering in Hanover and any operating system. It produces book-quality output, and
Berlin, and has a Doctorate of is widely used for typesetting articles, books, mathematical works
Engineering in Power Electronics. (at which it excels), directories, dictionaries, and other publications
He has been a high-school generated from databases.
teacher of mathematics, physics
and computer science, and a This book shows you how to:
lecturer at the Free University of • Create just about any kind of table in LaTeX, from
Berlin. For several years he has simple to extremely complex.
been heavily involved in • Use color In tables.
maintaining the PSTricks suite of • Produce multi-page tables.
tools for producing very high • Use available LaTeX packages to simplify your work,
quality PostScript graphics within with ready-to-run examples for each package.
LaTeX. • Present your data in the most effective way.
Intended audience
• Authors, especially in the fields of mathematics,
engineering, sciences, statistics and economics, where
LaTeX is widely used.
• College staff and students.
• Database publishers, where precise table layout is
ISBN 9 7 8 1 9 0 6 8 6 0 2 5 7 important for effective data presentation.
• Book and journal publishers.
Categories:
Computer: Graphic Design
Computer: Applications and Software
w w w .u it.c o .u k