Graphics, Figures & TablesReferencing and captioning Figures placed inside Tables

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
buzon
Posts: 7
Joined: Tue Jan 17, 2012 1:08 am

Referencing and captioning Figures placed inside Tables

Post by buzon »

hello, my problem is following: I would like to make a proper caption for the picture that I put inside a table (for now, unfortunately it goes captioned as table). Furthermore, I want to reference it - how to achieve this inside the table?

Code: Select all

\documentclass[10pt,a4paper]{article}

%\usepackage{xcolor}
\usepackage[table]{xcolor} % for colors in tables
\usepackage{tabularx} 
\usepackage{color} % for font color
\usepackage{graphicx}
\usepackage{multirow}  % for multirows in tables


\begin{document}
\begin{table}
\begin{tabular}{|c| p{9.5cm}|}
\hline
\multicolumn{2}{|c|}{ \textbf{ \textcolor{red}{Title} }} \\
\hline
\hline
\multicolumn{2}{|c|}{ \cellcolor{red} \textbf{Super} } \\
\hline
\hline Location & Left \\ 
\hline Description & Sample text \\
\hline Screenshot & 
	\vspace{1pt}
	\includegraphics[width=9cm]{gfx/3.png} 
	  \caption{This makes a table caption, not figure caption:(}
	  \label{fig:screenshot}
	   \\
\hline Solution &  latex-community.org :) \\ 
\hline 
\end{tabular} 
\caption{Here is ok - table caption}
\end{table}
\end{document}

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Referencing and captioning Figures placed inside Tables

Post by Stefan Kottwitz »

You could use the caption package and \captionof:

Code: Select all

\documentclass[10pt,a4paper]{article}

%\usepackage{xcolor}
\usepackage[table]{xcolor} % for colors in tables
\usepackage{tabularx}
\usepackage{color} % for font color
\usepackage[demo]{graphicx}
\usepackage{multirow}  % for multirows in tables
\usepackage{caption}

\begin{document}
\begin{table}
\begin{tabular}{|c| p{9.5cm}|}
\hline
\multicolumn{2}{|c|}{ \textbf{ \textcolor{red}{Title} }} \\
\hline
\hline
\multicolumn{2}{|c|}{ \cellcolor{red} \textbf{Super} } \\
\hline
\hline Location & Left \\
\hline Description & Sample text \\
\hline Screenshot &
   \vspace{1pt}
   \includegraphics[width=9cm]{gfx/3.png}
     \captionof{figure}{This makes a figure caption}
     \label{fig:screenshot}
      \\
\hline Solution &  latex-community.org :) \\
\hline
\end{tabular}
\caption{Here is ok - table caption}
\end{table}
\end{document}
mixed-captions.png
mixed-captions.png (9.86 KiB) Viewed 1485 times
Stefan
LaTeX.org admin
Post Reply