<< . . . 10( : 23) . . >>
Venus 109.0 107.6
Earth 152.6 147.4
Mars 249.2 207.3
Jupiter 817.4 741.6
Saturn 1512.0 1346.0
Uranus 3011.0 2740.0
Neptune 4543.0 4466.0
Pluto 7346.0 4461.0

Note that even though \centering is used in the last column of the ¬rst row, no \tabularnewline
is required to terminate this row, since the scope of the \centering is limited by the
\multicolumn.
69
TABLES
VII.2.

By the way, do you feel that the tables we™ve been produced look a bit cramped? A
bit crowded vertically? Well, you can create a bit more room between rows by rede¬ning
the value of \arraystretch. By default, it™s value is 1 and if you set it to a number k,
then the interrow space is increased k-fold. Thus the input of the last example with the
command
\renewcommand{\arraystretch}{1.2}

after the \begin{center} produces

Distance from sun
(million km)
Planet Maximum Minimum
Mercury 69.4 46.8
Venus 109.0 107.6
Earth 152.6 147.4
Mars 249.2 207.3
Jupiter 817.4 741.6
Saturn 1512.0 1346.0
Uranus 3011.0 2740.0
Neptune 4543.0 4466.0
Pluto 7346.0 4461.0

Next let™s see how we produce a table like the one below

Height Ideal weight
(cm) (kg)
155 53.5“64
160 56“67
165 59“71
170 62.5“75.5
175 66“79
180 70“83.5
185 71.5“86.5
190 78“92.5

Here we want all the dashes in the second column to be vertically aligned, so that we must
set them in a separate column; but then there should be no space between the numbers
and the dashes connecting them. In such cases we can use the @ command in the column
speci¬cation as below
\begin{center}
\begin{tabular}{|c|r@{--}l|}
\hline
Height & \multicolumn{2}{c|}{Ideal weight}\\
(cm) & \multicolumn{2}{c|}{(kg)}\\
\hline
155 & 53.5 & 64\\
160 & 56 & 67\\
...............
190 & 78 & 92.5\\
70 ROWS COLUMNS
VII. AND

\hline
\end{tabular}
\end{center}

Here the speci¬cation r@{--}l indicates that there should be a right aligned column and
a left aligned column with a “ in between each pair of entries in these columns without
the intercolumn space the tabular environment leaves by default between every pair of
columns. Note that this incidently saves us the trouble of repeatedly typing --. You
can also add some space producing commands within the braces after the @ command to
produce that much space between the columns on either side of it.

Enhancements to the tabular
VII.2.1.

There are many packages which provide further facilities in forming tables. We™ll discuss
a couple of such packages here.

The array package
VII.2.2.

Look at the tables below

Planet Mean distance Mean distance
Planet
from sun from sun
( km) (km)
Mercury Mercury
58100000 58100000
Venus Venus
108300000 108300000
Earth Earth
150000000 150000000
Mars Mars
228250000 228250000
Jupiter Jupiter
779500000 779500000
Saturn Saturn
1429000000 1429000000
Uranus Uranus
2439000000 2439000000
Neptune Neptune
4504500000 4504500000
Pluto Pluto
5903500000 5903500000

The one on the right looks nicer, doesn™t it? It was produced using the column speci¬er m
available in the array package. To produce this table, we must ¬rst load the array package
by the ususl \usepackage{array} in the preamble and then type
\begin{tabular}{|l|r|}
\hline
\multicolumn{1}{|m{1.5cm}|}{\centering Planet}
&\multicolumn{1}{m{2.3cm}|}%
{\centering Mean distance from sun \\ (km)}\\
\hline
Mercury & 58100000\\
...................
Pluto & 5903500000\\
\hline
\end{tabular}

The m{wd} speci¬er produces a column of width wd just like the p speci¬er, but with the
text aligned vertically in the middle unlike the p speci¬er which aligns the text with the
topline. (The table on the left, incidently, was produced by the same input as above but
71
TABLES
VII.2.

Another interesting feature of the array package is the >{decl} command which can
be used before a column speci¬er. It inserts decl directly in front of the column. For
example look at the input below

\begin{center}
\begin{tabular}{|>{\bfseries}l|r|}
\hline
\multicolumn{1}{|m{1.5cm}|}{\centering Planet}
&\multicolumn{1}{m{2.3cm}|}%
{\centering Mean distance from sun \\ (km)}\\
\hline
Mercury & 58100000\\
Venus & 108300000\\
Earth & 150000000\\
Mars & 228250000\\
Jupiter & 779500000\\
Saturn & 1429000000\\
Uranus & 2439000000\\
Neptune & 4504500000\\
Pluto & 5903500000\\
\hline
\end{tabular}
\end{center}

which produces the output

Mean distance
Planet from sun
(km)
Mercury 58100000
Venus 108300000
Earth 150000000
Mars 228250000
Jupiter 779500000
Saturn 1429000000
Uranus 2439000000
Neptune 4504500000
Pluto 5903500000

The array package also has a ! command which works just like the @ command, but
whch does not suppress the intercolumn space.

The multirow package
VII.2.3.

Look again at the table in 68. Wouldn™t it be nice if the entry “Planet” in the ¬rst column
is vertically aligned with the center of the two rows in the next column as below?
72 ROWS COLUMNS
VII. AND

Distance from sun
Planet (million km)
Maximum Minimum
Mercury 69.4 46.8
Venus 109.0 107.6
Earth 152.6 147.4
Mars 249.2 207.3
Jupiter 817.4 741.6
Saturn 1512.0 1346.0
Uranus 3011.0 2740.0
Neptune 4543.0 4466.0
Pluto 7346.0 4461.0

The package multirow is what we need to do this painlessly. It has a command

\multirow{num}{wd}{item}

where num is the number of rows to be spanned, wd is the width of this column and item
is the text of the item in this column. This can be used as in the following example

\begin{center}
\begin{tabular}{|l|r|r|}
\hline
\multirow{3}{1.5cm}{Planet}
& \multicolumn{2}{p{3.5cm}|}%
{\centering Distance from sun \\ (million km)}\\
\cline{2-3}
& \multicolumn{1}{c|}{Maximum}
& \multicolumn{1}{c|}{Minimum}\\
\hline
Mercury & 69.4 & 46.8\\
Venus & 109.0 & 107.6\\
Earth & 152.6 & 147.4\\
Mars & 249.2 & 207.3\\
Jupiter & 817.4 & 741.6\\
Saturn & 1512.0 & 1346.0\\
Uranus & 3011.0 & 2740.0\\
Neptune & 4543.0 & 4466.0\\
Pluto & 7346.0 & 4461.0\\
\hline
\end{tabular}
\end{center}

But this code does not produce the table above, but only
73
TABLES
VII.2.

Distance from sun
Planet (million km)
Maximum Minimum
Mercury 69.4 46.8
Venus 109.0 107.6
Earth 152.6 147.4
Mars 249.2 207.3
Jupiter 817.4 741.6
Saturn 1512.0 1346.0
Uranus 3011.0 2740.0
Neptune 4543.0 4466.0
Pluto 7346.0 4461.0

The trouble is that though the entry “Planet” is vertically centered in its column, it
is not horizontally centered. The horizontal alignment is controlled by the command
\multirowsetup and this is by default st to \raggedright. So all that is needed to get the
beautiful table seen at the beginning of this section is to add the line
\renewcommand{\multirowsetup}{\centering}

at the beginning of the code above.

vs. tabular
VII.2.4. tabbing

Let™s take a quick look at the pros and cons of the tabbing and tabular environments.

• The tabbing environment can be typeset only as a separate paragraph, while the
tabular environment can be placed anywhere in text, even inside Mathematics.

• The tabbing environment can span multiple pages, but the tabular environment
cannot.

• tabbing environments cannot be nested, while tabular environments can be nested
to any number of levels.

Multipage tables”The package longtable
VII.2.5.

As we have noted, we cannot create table spanning more than one page using the tabular
environment. But the package longtable by David Carlisle can do this and it has quite a
few other tricks also. To use this package, load it as usual with the command \usepackage{longtable}
in the preamble and then to produce a no-frills “longtable” just use the commands
\begin{longtable} ... \end{longtable} instead of the \begin{tabular} ... \end{tabular}
commands. We can use footnotes and the \newpage commands inside the longtable en-
vironment. If the package array is also loaded, its extra features can be used.
Apart from this, this package has provisions to specify at the start of the input the
following items

• the rows that should appear at the top of the table; the input for these to be termi-

• the rows that should appear in every page after the ¬rst, such input terminated by

• those at the bottom of every page, the input terminated by \endfoot
74 ROWS COLUMNS
VII. AND

• those rows at the very end of the table, terminated by \endlastfoot
These are illustrated in the (long!) table below.

Science and Technology in the Twentieth Century

Year Event
Max Planck proposes quantum theory
1900
Publication of Sigmund Freud™s The Interpretation of Dreams
Discovery of principal blood groups
1901
Guglielmo Marconi transmits wireless signals across the atlantic
Wright brothers make their ¬rst ¬‚ight
1903
Albert Einstein presents Special Theory of Relativity
1905
Ernest Rutherford proposes theory of atomic structure
1911
Victor Hess discovers cosmic rays
1912
Albert Einstein presents general Theory of Relativity
1916
1920
John Logie Baird demonstrates television
1926
Alexander Fleming discovers penicillin
1928
Discovery of polythene
1933
Discovery of nuclear ¬ssion
1934
Discovery of nylon
1938
Plutonium obtained by bombardment of uranium
1940
Construction of ¬rst nuclear reactor
1942
Construction of ¬rst electronic digital computer
1946
First supersonic ¬‚ight
1947
Invention of the transistor
Nuclear power stations introduced
1951
James Watson and Francis Crick show DNS molecule structure
1953
Contraceptive pill introduced
1956
Launch of the ¬rst space satellite (Sputnik 1)
1957
First photograph of the dark side of the moon (Luna 3)
1959
··· ·········
··· ·········
··· ·········
··· ·········
··· ·········
··· ·········
··· ·········
··· ·········
··· ·········
··· ·········
··· ·········
··· ·········
Yuri Gagarin becomes ¬rst man in space (Vostok 1)
1961
First lunar soft landing (Luna 9)
1966
Discovery of pulsars
1967
First manned lunar orbit (Apollo 8)
1968
First man on moon (Neil Armstrong)
1969
Pocket calculator introduced
1972
continued on the next page
75
TABLES
VII.2.

Science and Technology in the Twentieth Century (continued)

Year Event
First ˜test-tube babies™
 << . . . 10( : 23) . . >>