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.

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?

share|improve this question
    
Related: tex.stackexchange.com/questions/101980/… –  badroit Mar 11 '13 at 19:22

2 Answers 2

up vote 37 down vote accepted
+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

share|improve this answer
1  
Many thanks. Worked perfectly: floated, correct labelling, separate captions, and even handled the footnote in my table correctly! –  badroit Dec 10 '10 at 18:01
1  
@alex: In my example, replace \rule{3cm}{3cm} with \includegraphics{<whatever>}. –  lockstep Nov 13 '11 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 '12 at 21:41
1  
...are you saying my questions aren't memorable? :P Anyways, don't spend it all in one shop. –  badroit Jan 11 '12 at 3:25
1  
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 at 21:18

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

share|improve this answer
    
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 '10 at 18:03
    
why does this no longer work if you try to put the captions above the figure and table? –  emily Jul 8 '12 at 16:35

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.