Get a table and figure on the same page with captions & labels
To guarantee that they will remain together, use either one minipage
(if the object doesn't have to be treated as floating) or just one floating environment for both the figure and the table; the right type of caption can then be obtained, in both cases, using \captionof
from the capt-of
(or caption
) packages; the example below shows both possibilities:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{capt-of}
\begin{document}
\noindent\begin{minipage}{\linewidth}
\centering
\includegraphics[width=6cm]{examplefigure}
\captionof{figure}{Example figure caption (non-floating)}
\label{fig:examplenf}
\captionof{table}{Example Table (non-floating)}
\begin{tabular}{ll}
\hline
column1a & column2a \\
column1b & column2b \\
column1c & column2c \\
\hline
\end{tabular}
\label{tab:examplenf}
\end{minipage}
\begin{figure}
\centering
\includegraphics[width=6cm]{examplefigure}
\caption{Example figure caption (floating)}
\label{fig:examplefl}
\captionof{table}{Example Table (floating)}
\begin{tabular}{ll}
\hline
column1a & column2a \\
column1b & column2b \\
column1c & column2c \\
\hline
\end{tabular}
\label{tab:examplefl}
\end{figure}
\end{document}