Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 5 down vote accepted

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.

share|improve this answer
    
Works like it should. Additionally this works together with the \subfloat command in the figures where the other two solutions fail. –  theomega Aug 4 '12 at 16:23

You can use the capt-of package to put individual captions for the table and the figure with or without using the usual floating environments:

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage{capt-of}

\begin{document}
\listoffigures
\listoftables

A non-floating version works\dots
\begin{center}
  \captionof{table}{Caption of the first table}\label{tab:tableone}
  \begin{tabular}{ll}
  ... & ... \\
  \end{tabular}
  \\[\floatsep]
  \rule{4cm}{2cm} % \includegraphics{yourpicture}
  \captionof{figure}{Caption of the first figure}\label{fig:figureone}
\end{center}

\dots as well as a floating example.
\begin{figure}[bp]
  \centering
  \captionof{table}{Caption of the second table}\label{tab:tabletwo}
  \begin{tabular}{ll}
  ... & ... \\
  \end{tabular}
  \\[\floatsep]
  \rule{4cm}{2cm} % \includegraphics{yourpicture}
  \captionof{figure}{Caption of the second figure}\label{fig:figuretwo}
\end{figure}

\end{document}

EDIT: extended the example to show a floating environment, too.

share|improve this answer

You can use the subcaption package with the help of the underlying caption package.

\documentclass{article}
\usepackage{subcaption}
\usepackage{mwe} %<- For dummy image
\DeclareCaptionLabelFormat{andtable}{#1˜#2 \& \tablename˜\thetable}

\begin{document}

\listoftables
\listoffigures


\begin{figure}
\begin{subfigure}{0.5\textwidth}\centering
\includegraphics[width=0.3\textwidth]{example-image-a}%
\label{fig:fig1}
\caption{important image}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\centering
\begin{tabular}[b]{cc}
a &b\\c&d
\end{tabular}
\label{tab:table1}
\caption{important result}
\end{subfigure}
\captionlistentry[table]{important result}
\captionsetup{labelformat=andtable}
\caption[important image]{typeset together}
\end{figure}


\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.