124

Looking to put a table and a figure side by side so that the table and figure have their own captions. A crude sketch

 ------------              -----------------
    TABLE 
  | a |  b |                     FIGURE
  | c |  d |
 ------------             
Table 2: Caption           -----------------
                           Figure 7: Caption

The closest I've gotten is:

\begin{table}%
\centering
\parbox{0.4\textwidth}{
\begin{footnotesize}
\begin{tabular}{| l | r |} \hline
some & table\\
\end{tabular}
\end{footnotesize}
\caption{Table}
\label{tab:table}
}
\qquad
\begin{minipage}[c]{0.53\textwidth}%
\centering
    \includegraphics[width=1\textwidth]{awesome}
\caption{Figure}
\label{fig:figure}
\end{minipage}
\end{table}

But that gives two Table X: Caption captions. I didn't find anything in subfig.

Help?

1

2 Answers 2

105
+50

Use a floatrow environment of the package of the same name.

\documentclass{article}

\usepackage{floatrow}
% Table float box with bottom caption, box width adjusted to content
\newfloatcommand{capbtabbox}{table}[][\FBwidth]

\usepackage{blindtext}

\begin{document}

\blindtext

\begin{figure}
\begin{floatrow}
\ffigbox{%
  \rule{3cm}{3cm}%
}{%
  \caption{A figure}%
}
\capbtabbox{%
  \begin{tabular}{cc} \hline
  Author & Title \\ \hline
  Knuth & The \TeX book \\
  Lamport & \LaTeX \\ \hline
  \end{tabular}
}{%
  \caption{A table}%
}
\end{floatrow}
\end{figure}

\end{document}

enter image description here

14
  • 4
    Many thanks. Worked perfectly: floated, correct labelling, separate captions, and even handled the footnote in my table correctly!
    – badroit
    Dec 10, 2010 at 18:01
  • 4
    @alex: In my example, replace \rule{3cm}{3cm} with \includegraphics{<whatever>}.
    – lockstep
    Nov 13, 2011 at 16:55
  • 2
    It was a joke, I swear! It was a joke! And I didn't remember I answered one of your questions! ... But this is a nice surprise. :-)
    – lockstep
    Jan 9, 2012 at 21:41
  • 6
    I get the error: Package floatrow Error: Do not use float package with floatrow. will floatrow replace float? or is there another workaround ?
    – Fry
    Feb 6, 2014 at 21:18
  • 3
    The suggestion and the code example are great, however, the figure and table seem to each take half the page width. What can one do, if the figure is rather thin, but the table rather wide? Here is a screenshot: dl.dropbox.com/u/29095240/2014-10-06%20Selection_003.png Oct 6, 2014 at 17:05
76

You can use the »caption« package. See code below for an example derived from the package manual.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}

\DeclareCaptionLabelFormat{andtable}{#1~#2  \&  \tablename~\thetable}

\begin{document}
  \begin{figure}[!ht]
    \centering
    \rule{6.4cm}{3.6cm}
    \qquad
    \begin{tabular}[b]{cc}\hline
      Table head & Table head \\ \hline
      Some values & Some values \\
      Some values & Some values \\
      Some values & Some values \\
      Some values & Some values \\
      Some values & Some values \\
      Some values & Some values \\ \hline
    \end{tabular}
    \captionlistentry[table]{A table beside a figure}
    \captionsetup{labelformat=andtable}
    \caption{A table beside a figure}
  \end{figure}
\end{document}

You will find more details in the manual. This is not exactly what you want, but it would float.


alt text


Supplement:

Another solution that would give the desired output. But this won't float.

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf]{caption}

\begin{document}
  \begin{minipage}{\textwidth}
  \begin{minipage}[b]{0.49\textwidth}
    \centering
    \rule{6.4cm}{3.6cm}
    \captionof{figure}{A table beside a figure}
  \end{minipage}
  \hfill
  \begin{minipage}[b]{0.49\textwidth}
    \centering
    \begin{tabular}{cc}\hline
      Table head & Table head \\ \hline
        Some values & Some values \\
        Some values & Some values \\
        Some values & Some values \\
        Some values & Some values \\
        Some values & Some values \\
        Some values & Some values \\ \hline
      \end{tabular}
      \captionof{table}{A table beside a figure}
    \end{minipage}
  \end{minipage}
\end{document}

alt text

4
  • Thorsten, many thanks for the detailed answer and excellent examples. I went with the other answer since it's essentially a floating version of your second example where I can have separate captions.
    – badroit
    Dec 10, 2010 at 18:03
  • 3
    why does this no longer work if you try to put the captions above the figure and table?
    – emily
    Jul 8, 2012 at 16:35
  • 1
    @emily a fix for that can be found here: tex.stackexchange.com/questions/459423/… Nov 26, 2020 at 12:51
  • with the minipage version, when table title is at the top, and the figure is taller, can you set the table verticle_alignment=centre? or align at top.
    – Anthony
    Aug 6, 2021 at 22:54

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