[Tex/LaTex] Grouping two tables, one above the other

floatstables

I'd like to group two tables, one below the other, so they don't show separated ie. one in each page. What's the best way to achieve that? I've read about positioning them side by side, but not this.

Probably, I could create a custom float with \usepackage{float}, but I bet there is a simpler way (other than playing around with [htpb]).

Best Answer

Any number of tables can go in a single table environment, along with their captions, so long as they fit in a page.

The entries in the list of tables are generated by the \caption command, so there will be two entries even if two tables are in the same table environment.

However, there will be a problem when the caption package is loaded together with hyperref, because the link in the list of tables or the ones made by \ref might bring to the first of the two tables. The hypcap package fixes it.

Here's an example.

\documentclass{article}
\usepackage{kantlipsum} % just to produce nonsense text

\usepackage{caption} % for better vertical separation
\usepackage{hyperref}
\usepackage{hypcap} % fix the links

\begin{document}
\title{A title}
\author{A. Uthor}

\maketitle

\listoftables

\section{A section}

A reference to the first table~\ref{tab:first} and one to the
second table~\ref{tab:second}, followed by nonsense text.

\kant

\begin{table}[htp]

\centering
\caption{First table}\label{tab:first}

\begin{tabular}{ll}
\hline
ab & cd \\
ab & cd \\
ab & cd \\
\hline
\end{tabular}

\bigskip

\caption{Second table}\label{tab:second}

\begin{tabular}{ll}
\hline
ab & cd \\
ab & cd \\
ab & cd \\
\hline
\end{tabular}

\end{table}

\kant

\end{document}