# [OS X TeX] Spacing of first two rows in tabular environment

Alain Matthes alain.matthes at mac.com
Sat Oct 3 02:29:02 EDT 2009

Le 2 oct. 2009 à 16:09, Berend Hasselman a écrit :

>
> On 01-10-2009, at 16:19, Chris Goedde wrote:
>
>> Hi,
>>
>> This isn't Mac specific, but it's something that's bugged me for a
>> LONG time, and maybe someone can help me out. I've always felt that
>> the second row of a table is too close to the horizontal rule (if
>> any) that separates it from the top row. For example, when I
>> typeset the table below in 11pt Lucida, the exponents touch the
>> horizontal rule. Is there a simple, non-kludgy fix or adjustment
>> for this? I don't want to increase all the linespacing, just the
>> spacing between the first and second row. Thanks.
>>
>> Chris
>>
>> The table:
>>
>> \begin{center}
>> \begin{tabular}{lccc}
>> Planet & Mass (kg) & Distance from Sun (km) & Period of Orbit
>> (years) \\\hline
>> Earth & $5.98\times10^{24}$ & $1.50\times10^8$ & 1.00 \\
>> Venus & $4.87\times10^{24}$ & $1.08\times10^8$ & 0.615 \\
>> Mars & $6.40\times10^{23}$ & $2.28\times10^8$ & 1.88
>> \end{tabular}
>> \end{center}
>
> I find this on the FAQ:  http://www.tex.ac.uk/cgi-bin/texfaq2html?label=struttab
>
> Place \usepackage{bigstrut} in your preamble
> look better.
> bigstrut also seems not to interfere with array.

Hi

You have two solutions to get a fine layout.

The best layout is obtained with the package "booktabs" and
the use of \toprule instead of \hline. The result is fine.
booktabs" is a very good package.

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{booktabs}
\begin{document}

\begin{center}
\begin{tabular}{l c c c}
Planet & Mass (kg) & Distance from Sun (km) & Period of Orbit (years) \\
\toprule
Earth & $5.98\times10^{24}$ & $1.50\times10^8$ & 1.00 \\
Venus & $4.87\times10^{24}$ & $1.08\times10^8$ & 0.615 \\
Mars & $6.40\times10^{23}$ & $2.28\times10^8$ & 1.88
\end{tabular}
\end{center}

\end{document}

If you prefer to use \hline or if you don't want to use "booktabs"
for a compatibility problem, then you need to use "cellspace". This is
a magic package.

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{cellspace}
\begin{document}

\begin{center}
\begin{tabular}{Sl Sc Sc Sc}
Planet & Mass (kg) & Distance from Sun (km) & Period of Orbit (years) \\
\hline
Earth & $5.98\times10^{24}$ & $1.50\times10^8$ & 1.00 \\
Venus & $4.87\times10^{24}$ & $1.08\times10^8$ & 0.615 \\
Mars & $6.40\times10^{23}$ & $2.28\times10^8$ & 1.88
\end{tabular}
\end{center}

\end{document}

You need to load "cellspace" this is a CTAN package and you change
\begin{tabular}{l c c c} with \begin{tabular}{Sl Sc Sc Sc}

That's all. By default, table  uses a setting of 2 pt for both top and
bottom space
limits but you can change these settings easily. For example
\setlength{\cellspacebottomlimit}{4pt}, but 3pts only are used if
3pts are necessary
and not 4.

The documentation is very clear.
"The cellspace has two parameters governing the spacing of the cells.
The dimension \cellspacetoplimit is the minimal spacing required
between the actual text the cell is made up of and the top of the cell
(where \hlines may appear), if the spacing is less than this
threshold, a space of \cellspacetoplimit is added, otherwise nothing
is done. Conversely, at the bottom the dimension \cellspacebottomlimit
is the minimal space required between the bottom of the cell and the
text itself. This parameters can be changed in the document preamble
using \setlength."

Best Regards

Alain Matthes