Graphics, Figures & TablesFigure & table side-by-side in minipage -- caption wrong

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
sputnik_b
Posts: 1
Joined: Mon Jan 11, 2010 10:49 pm

Figure & table side-by-side in minipage -- caption wrong

Post by sputnik_b »

Hi,

I'm using the minipage environment to place a figure and table side-by-side, similar to this:

Code: Select all

\begin{figure}[t]
  \begin{minipage}{0.5\textwidth}
    \includegraphics % figure here
    \caption{Figure caption}
  \end{minipage}
  \begin{minipage}{0.5\textwidth}
    \begin{tabular}
     % table data here
    \end{tabular}
    \caption{Table caption}
  \end{minipage}
\end{figure}
The problem is that the table gets labeled as a Figure when the caption is printed, whereas I need it to say Table. The figure, of course, must still be labeled as Figure.

Any help would be greatly appreciated!! Thanks...

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Figure & table side-by-side in minipage -- caption wrong

Post by gmedina »

One possible solution would be to use the \captionof command provided by the caption package. Take a look at the following example:

Code: Select all

\documentclass{article}
\usepackage{caption}

\begin{document}

{\centering
\begin{minipage}{0.45\textwidth}
  \centering
  \rule{4cm}{2cm} %to simulate an actual figure
  \captionof{figure}{Figure caption}
\end{minipage}
\begin{minipage}{0.45\textwidth}
  \centering
  \rule{4cm}{2cm} %to simulate an actual table
  \captionof{table}{Table caption}
\end{minipage}
}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply