cmhughes answer made me realise that any form of "automatic" table size recognition is just overkill. First, my tables are usually textwidth-wide, hence there is not a massive variation in size. Second, even if the size is a few cm's longer or shorter it does not really matter. So my strategy is as follows:
- Create a new
ifnotables conditional that can be activated by the
documentclass via notables
- Create a few predefined empty tables:
\fulltable is on a extra page float, \halftable is half the size...\thirdtable, \quartertable etc.
The table can then be set by \ifnotables{\halftable}{\begin{tabular}...\end{tabular}. The advantage is that, when set in a table float, captions, labels etc. remain the same which allows for a decent layout: only the actual table is missing.
\documentclass[%
notables
]{article}
\usepackage{tikz}
\usepackage{booktabs,lmodern}
\makeatletter
% Provide new conditionals
\newif\if@notables
\DeclareOption{notables}{%
\@notablestrue
}
\ProcessOptions*\relax
\newcommand*{\ifnotables}{%
\if@notables
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
\makeatother
% create dummy tables
\newcommand{\fulltable}{%
\begin{tabular*}{\textwidth}{c@{\extracolsep{\fill}}l}
\hspace{-.5em}\pgfpicture\pgfpathrectanglecorners{\pgfpointorigin}{\pgfpoint{\textwidth}{23cm}}%
\pgfusepath{stroke}\endpgfpicture%
\end{tabular*}
}
\newcommand{\halftable}{%
\begin{tabular*}{\textwidth}{c@{\extracolsep{\fill}}l}
\hspace{-.5em}\pgfpicture\pgfpathrectanglecorners{\pgfpointorigin}{\pgfpoint{\textwidth}{11.5cm}}%
\pgfusepath{stroke}\endpgfpicture%
\end{tabular*}
}
\newcommand{\thirdtable}{%
\begin{tabular*}{\textwidth}{c@{\extracolsep{\fill}}l}
\hspace{-.5em}\pgfpicture\pgfpathrectanglecorners{\pgfpointorigin}{\pgfpoint{\textwidth}{7cm}}%
\pgfusepath{stroke}\endpgfpicture%
\end{tabular*}
}
\newcommand{\quartertable}{%
\begin{tabular*}{\textwidth}{c@{\extracolsep{\fill}}l}
\hspace{-.5em}\pgfpicture\pgfpathrectanglecorners{\pgfpointorigin}{\pgfpoint{\textwidth}{5cm}}%
\pgfusepath{stroke}\endpgfpicture%
\end{tabular*}
}
\begin{document}
\begin{table}[!htb]
\centering
\caption{First table}
\label{tab:first}
\ifnotables{\thirdtable}{%
\begin{tabular*}{\textwidth}{c@{\extracolsep{\fill}}ccc}
\toprule
right & center & left \\
right & center & left \\
right & center & left \\
right & center & left \\
right & center & left \\
right & center & left \\
right & center & left \\
right & center & left \\
right & center & left \\
right & center & left \\
right & center & left \\
right & center & left \\
\bottomrule
\end{tabular*}
}
\end{table}
\begin{table}[!b]
\centering
\caption{Second table}
\label{tab:second}
\ifnotables{\quartertable}{%
\begin{tabular*}{\textwidth}{c@{\extracolsep{\fill}}ccc}
\toprule
right & center & left \\
right & center & left \\
right & center & left \\
right & center & left \\
\bottomrule
\end{tabular*}
}
\end{table}
\end{document}

The size of the dummies can of course be fine tuned. I usually have my tables stored in separate tex files, hence by creating a command such as:
\usepackage{etoolbox}
\newcommand{\mytable}[2][]{%
\ifstrempty{#1}{%
\input{#2}
}{%
\ifnotables{#1}{\input{#2}}%
}
}
I can make the code in the float tidier and the specification of a dummy table is optional:
\begin{table}[!htb]
\centering
\caption{First table}
\label{tab:first}
\mytable[\halftable]{table2}
\end{table}
ifdraftpackage, e.g. wrap the whole float in\ifdraft{\relax}{\begin{table}...but that would be really annoying for the layout. The tables won't change, so taking the dimensions values from the aux file after an initial compile sounds like a good idea. – Jörg Oct 30 '12 at 13:35