# [OS X TeX] OT: peculiar table formatting

Bruno Voisin bvoisin at mac.com
Wed May 3 11:15:12 EDT 2006

Given table column issues seem all the hype on this list these days,
here's a little puzzle I've found myself confronted with.

The problem was, inside a tabular environment:

- To get a horizontal rule spanning several columns, but without the
rule extending onto the intercolumn space before the leftmost column
and after the rightmost column. In particular, there were two
consecutive such rules, and there needed to be some horizontal space
between them, corresponding to the intercolumn space. The problem is
that LaTeX considers half the intercolumn space before and after a
column as part of the column itself, and any horizontal rule inserted
through \cline spans this space as well. What I've come up with is
suppressing the intercolumn space using @{} in the preamble, and
inserting a fake empty column containing only \hspace{2\tabcolsep}.

- To get columns in which all rows (containing formulae) were left-
aligned while the heading was centred. The normal way to do this is
use l as the column specifier, and \multicolumn{1}{c} for the
heading. However, in case the heading is longer than the rows
themslves, the l alignment seems to take precedence and the heading
turns out left-aligned as well. What I've come up with is using c as
the column specifier, then storing the length of the longer row as a
\tempdim length then inserting the rows through \makebox[\tempdim][l].

Both solutions, though working ones, look like dirty hacks. I was
wondering whether anyone here would know about more elegant solutions
to the same problems.

The code for the whole table follows.

Bruno Voisin

\documentclass[a4paper]{article}
\newcommand{\fno}{\ensuremath{\mathit{F}}}
\begin{document}
\newlength{\tempdima}\settowidth{\tempdima}{$O(\fno^2)$}
\newlength{\tempdimb}\settowidth{\tempdimb}{$O(\fno^{1/2})$}
\newlength{\tempdimc}\settowidth{\tempdimc}{$O(1/\fno^2)$}
\begin{tabular}{@{}c@{}c@{}cc@{}c@{}cccc@{}}
& \hspace{2\tabcolsep} &
\multicolumn{2}{c}{$\fno \gg 1$} & \hspace{2\tabcolsep} &
\multicolumn{4}{c}{$\fno \ll 1$} \\
\noalign{\vspace{\smallskipamount}}
\cline{3-4}\cline{6-9}
\noalign{\vspace{\smallskipamount}}
Region & &
Inner & Outer & &
Middle & Top \& Bottom & Shear & Upper \& Lower \\
Vertical distance & &
$O(1)$ &
\makebox[\tempdimc][l]{$O(\fno)$} & &
\makebox[\tempdima][l]{$O(1)$} &
\makebox[\tempdimb][l]{$O(\fno)$} &
\makebox[\tempdima][l]{$O(\fno)$} &
\makebox[\tempdima][l]{$O(1)$} \\
Horizontal distance & &
$O(1)$ &
\makebox[\tempdimc][l]{$O(\fno)$} & &
\makebox[\tempdima][l]{$O(1)$} &
\makebox[\tempdimb][l]{$O(\fno^{1/2})$} &
\makebox[\tempdima][l]{$O(1)$} &
\makebox[\tempdima][l]{$O(1)$} \\
Perturbation velocity & &
$O(1)$ &
\makebox[\tempdimc][l]{$O(1/\fno^2)$} & &
\makebox[\tempdima][l]{$O(1)$} &
\makebox[\tempdimb][l]{$O(1)$} &
\makebox[\tempdima][l]{$O(\fno)$} &
\makebox[\tempdima][l]{$O(\fno)$} \\
Vertical displacement & &
$O(1)$ &
\makebox[\tempdimc][l]{$O(1/\fno)$} & &
\makebox[\tempdima][l]{$O(\fno^2)$} &
\makebox[\tempdimb][l]{$O(\fno)$} &
\makebox[\tempdima][l]{$O(\fno^2)$} &
\makebox[\tempdima][l]{$O(\fno^2)$}
\end{tabular}
\end{document}

------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
& FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/