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.

I have a table with four images.

\begin{table}[ht]
\caption{table caption...}
\centering
\begin{tabular}{cc}
\includegraphics[width=45mm]{w.png} &\includegraphics[width=45mm]{x.png}\\
\newline
\includegraphics[width=45mm]{y.png}&\includegraphics[width=45mm]{z.png}\\
\end{tabular}
\end{table}

I want to caption each of the images. Normally I would do this by placing includegraphics within a \begin{figure} block using \caption{...}. But when I do this, the images disappear.

What is the proper way to do this, so that I can caption each of the images.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

Or you could use the subfig package:

\usepackage{subfig}

...

\begin{figure}
  \centering
  \subfloat[Caption 1]{\label{ref_label1}\includegraphics[width=0.5\textwidth]{path/to/figure1}}
  \subfloat[Caption 2]{\label{ref_label2}\includegraphics[width=0.5\textwidth]{path/to/figure1}}
  \caption{\label{ref_label_overall}Overall caption}
\end{figure}
share|improve this answer

You could simply use capt-of which provides stand-alone captionof command

\documentclass{book}
\usepackage[demo]{graphicx}
\usepackage{capt-of}
\usepackage{tabu}

\begin{document}

\begin{table}[ht]
\caption{Simple but not clever}
\centering
\begin{tabu}to \textwidth {X[c]X[c]}
  \includegraphics[width=45mm]{w.png}\captionof{figure}{fd} &\includegraphics[width=45mm]{x.png}\captionof{figure}{fd} \\
  \includegraphics[width=45mm]{y.png}\captionof{figure}{fd} &\includegraphics[width=45mm]{z.png}\captionof{figure}{fd} \\
\end{tabu}
\end{table}

\end{document}

enter image description here

This has two disadvantages: first it's not elegant and the table caption is much to close to the first picture. In my opinion one of the subfig or subcaption solutions is much better. When using a KOMA class there is no need to load capt-of.

share|improve this answer

You can use the subcaption package for this but I think you don't need table for such use. You can embed everything into a general figure environment and place them as you wish. See the manual for that. Here is the version with Table.

\documentclass{article}
\usepackage{mwe} % For dummy images
\usepackage{subcaption}
\begin{document}
{\centering
\begin{table}[ht]
\begin{tabular}{cc}
\begin{subfigure}{0.4\textwidth}\centering\includegraphics[width=0.3\columnwidth]{example-image-a}\caption{Figure A}\label{fig:taba}\end{subfigure}&
\begin{subfigure}{0.4\textwidth}\centering\includegraphics[width=0.3\columnwidth]{example-image-b}\caption{Figure B}\label{fig:tabb}\end{subfigure}\\
\newline
\begin{subfigure}{0.4\textwidth}\centering\includegraphics[width=0.3\columnwidth]{example-image-c}\caption{Figure C}\label{fig:tabc}\end{subfigure}&
\begin{subfigure}{0.4\textwidth}\centering\includegraphics[width=0.3\columnwidth]{example-image-a}\caption{Figure A again}\label{fig:taba2}\end{subfigure}\\
\end{tabular}
\caption{A table with figures}
\label{tab:mytable}
\end{table}
}

We can see that Figure \ref{fig:taba} and Figure \ref{fig:taba2} is the same. Also the table counter value is used for the reference.
\end{document}

enter image description here

share|improve this answer

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.