[Tex/LaTex] Join figure and table on the same page

floatstables

I have a figure and and a table and I want to make sure they both appear on the same page. I want both objects to keep their natural numbering and captioning: The Figure should be captioned Figure 1.2.3: Text and the Table should be captioned Table 1.2.3: Text 2. Currently, I specified [pt] as placement for both, but this (of course) does not what I need.

I know the following two solutions:

  1. Use \subfloat
  2. Use a single figure and put both, the table and the figure in this figure and using \caption twice.

Both solution do not lead to the captioning I need: The first solution generates a single figure and the second one creates two figures. I need a Figure and a Table for the captions.

Best Answer

I gather that the figure should be at the very top of a page, to be followed immediately by the table environment. (Moreover, I'm taking for granted that the two environments will actually fit on a single page, right?)

You could achieve these objectives by loading the afterpage package and "encasing" the figure and table environments in an \afterpage{...} statement, as is shown in the following code fragment:

\afterpage{%    % defer execution until the next page break occurs anyway
   \begin{figure}[t!] % not "pt"
      \centering
      % remaining contents of figure environment
   \end{figure}
   \begin{table}[h!] % not t or b or p
      \centering
      % remaining contents of table environment
   \end{table}
} % end of argument of `\afterpage` command

I'm further assuming that there are no deferred figure and/or table environments already waiting to be typeset. If that were the case, you should issue a \clearpage instruction as the very first item in the argument of the \afterpage command. (Even if there are no accumulated deferred floats to take care of, there's no harm done by issuing a \clearpage instruction anyway at the start of the \afterpage material; it would simply be ignored by TeX.)

In addition, if the figure and table environments combined take up most of the page (say, more than 75% of the page), you may also want to issue a second \clearpage instruction, following the end of the table environment. This will tell LaTeX that you want to have just those two floats on the page in question.