# figure and table kept together

I have a table and a figure, both with captions, that I want to keep together, problem is that when

\begin{figure}[htbp]
...figure code, graphics, plot, whatever
\caption[small caption]{figure caption}\label{fig:figlabel}
\end{figure}
\begin{table}[htbp]
\caption[small caption]{table caption}\label{tab:tablabel}
...table code, numbers, etc.
\end{table}


is used, latex has a tendency to split them up sometimes, I really want them kept together on a dedicated page, there is plenty of room on a single page, for both.

Anyone know a simple solution?

• I think the problem is here that figures as floats and tables as floats both get a counter. I guess, the best soltion is to define a new float environment, where you put in \includegraphics (or whatever) and begin{tabular}, and also set the counters. Yet the captions might be difficult then... (Edit: see answer of Gonzalo Medina for that) – jjdb Apr 19 '13 at 15:10
• @jjdb it is not the floating environment that increments the counters and write to teh list of.. files, but the caption command, so what you describe is pretty much what happens anyway. – David Carlisle Apr 19 '13 at 15:47

You can use only one float environment and \captionf from the capt-of (or caption) package:

\documentclass{article}
\usepackage{capt-of}

\begin{document}

\begin{figure}[htbp]
...figure code, graphics, plot, whatever
\caption[small caption]{figure caption}\label{fig:figlabel}
\captionof{table}[small caption]{table caption}\label{tab:tablabel}
...table code, numbers, etc.
\end{figure}

\end{document}


• Does this give the right counters? Will the table show up in the List of Tables? – jjdb Apr 19 '13 at 15:11
• Gives the right counters, however, now I have table 1.2 appearing in the typeset document before an unrelated table 1.1 (and also in the list of tables). Maybe a float barrier before and after will enforce numeric consistency. – Nicholas Hamilton Apr 19 '13 at 15:18
• \FloatBarrier before and after fixed the numbering, not sure if this is the most sensible solution. – Nicholas Hamilton Apr 19 '13 at 15:20
• @jjdb of course. Why wouldn't it? – Gonzalo Medina Apr 19 '13 at 15:43
• @ADP yes, that might happen, as you now have a bigger floating object, so the positioning algorithm will place it in the best location according to the rules for positioning. Once your document is finished, if necessary, you can make some manual adjustment for the positioning. – Gonzalo Medina Apr 19 '13 at 15:48