[Tex/LaTex] A table and a figure, with captions, in the same wide float in a two-column document

floatstwo-column

I'm trying to place a figure and a table inside the same wide float so that they are positioned together within a two-column document. However, they also need separate captions (i.e. a figure caption and a table caption).

I tried to wrap the table (\begin{tabular}...\end{tabular}) and the figure (\begin{figure}...\end{figure}) inside a figure*, but then I get a compilation error:

Float(s) lost.

And in the minimal example below, I get

LaTeX Error: Not in outer mode

as error.

\documentclass[twocolumn]{article}

\usepackage{lipsum}

\begin{document}
\begin{figure*}[t]
  \centering
  \begin{minipage}{\textwidth}
    \begin{figure}
      stuff
      \caption{abc}
    \end{figure}
    \begin{tabular}
      \begin{table}{c}
        more stuff
      \end{table}
      \caption{abc}
    \end{tabular}
  \end{minipage}
\end{figure*}
\lipsum
\lipsum
\end{document}

Anyone know how to solve this?

Best Answer

You can't put a figure inside a figure (or inside a minipage even), which is why you are getting floats lost. Just use a figure* on the outside and then use the caption or capt-of packages to allow you to go \captionof{table}{.....} for the table caption. Don't use table or figure environments within the float, just use \includegraphics tabular etc directly.

Note as it's a figure* latex will only ensure that it keeps the right order for the figure. the table may float out of sequence (similarly to using longtable or a [H] float from the float package). If that does happen you may need to help the ordering by moving tables in the source or adding \clearpage.