2

There are two ways I would like to describe the figures in the table: put sub caption under each figure (preferred) or insert the description directly in the figure.

To create a table of figures, I wrote the following code:

\begin{sidewaystable}[!htbp]
\label{tab:gr}
\centering\small\setlength\tabcolsep{2pt}
\begin{tabularx}{\textwidth}{@{}>{\bfseries}c*{9}{X}@{}}

  \includegraphics[width=2.2in,height=1.8in]{A1}&
  \includegraphics[width=2.2in,height=1.8in]{A2} & 
  \includegraphics[width=2.2in,height=1.8in]{A3} & 
  \includegraphics[width=2.2in,height=1.8in]{A4} \\

  \includegraphics[width=2.2in,height=1.8in]{B1} &
  \includegraphics[width=2.2in,height=1.8in]{B2} &
  \includegraphics[width=2.2in,height=1.8in]{B3} &
  \includegraphics[width=2.2in,height=1.8in]{B4} \\

  \includegraphics[width=2.2in,height=1.8in]{fig/C1} &
  \includegraphics[width=2.2in,height=1.8in]{fig/C2} &
  \includegraphics[width=2.2in,height=1.8in]{fig/C3} &
  \includegraphics[width=2.2in,height=1.8in]{fig/C4} \\

  \includegraphics[width=2.2in,height=1.8in]{fig/D1} &
  \includegraphics[width=2.2in,height=1.8in]{fig/D2} &
  \includegraphics[width=2.2in,height=1.8in]{fig/D3} &
  \includegraphics[width=2.2in,height=1.8in]{fig/D4} \\
  \end{tabularx}
  \caption{The main caption of the table.}
\end{sidewaystable}

Because I got different meanings of figures given a row, I want to put individual description under (right to, in this case) each figure.

2

You can use the \subcaption command from the package with the same name to add a caption for each sufigure.

There is a problem with using subcaptions inside a tabularx, see this bug report at SourceForge, so it's better to use a regular tabular with p columns.

Notes about the code:

  • The \label always has to be placed after (or within) the \caption.
  • I reduced the size of the images a bit, they need to be smaller to be able to fit in the page, due to the extra space added by the subcaptions. (Even with my adjustment the table may wider than the text block, depending on your settings.)
  • A space between the image and the subcaption seems to introduce extra vertical spacing. I.e., instead of

    \includegraphics[width=1.8in,height=1.2in]{example-image} \subcaption{Text}
    

    write

    \includegraphics[width=1.8in,height=1.2in]{example-image}\subcaption{Text}
    
  • To further compress the table vertically, you can add \renewcommand\arraystretch{0} right before the tabular. You can also move the subcaption closer to the images with \captionsetup[subtable]{aboveskip=2pt}. These are in the code, but commented.


\documentclass{article}
\usepackage{graphicx}
\usepackage{rotating}    
\usepackage{subcaption}
\begin{document}
\begin{sidewaystable}
\centering\small\setlength\tabcolsep{2pt}%
%\renewcommand\arraystretch{0}
%\captionsetup[subtable]{aboveskip=2pt}
\begin{tabular}{@{}*{4}{p{1.8in}}@{}}
  \includegraphics[width=1.8in,height=1.2in]{example-image}\subcaption{Text} &
  \includegraphics[width=1.8in,height=1.2in]{example-image-a}\subcaption{Text} & 
  \includegraphics[width=1.8in,height=1.2in]{example-image-b}\subcaption{Text} & 
  \includegraphics[width=1.8in,height=1.2in]{example-image-c}\subcaption{Text} \\

  \includegraphics[width=1.8in,height=1.2in]{example-image}\subcaption{Text} &
  \includegraphics[width=1.8in,height=1.2in]{example-image-a}\subcaption{Text} &
  \includegraphics[width=1.8in,height=1.2in]{example-image-b}\subcaption{Text} &
  \includegraphics[width=1.8in,height=1.2in]{example-image-c}\subcaption{Text} \\

  \includegraphics[width=1.8in,height=1.2in]{example-image}\subcaption{Text} &
  \includegraphics[width=1.8in,height=1.2in]{example-image-a}\subcaption{Text} &
  \includegraphics[width=1.8in,height=1.2in]{example-image-b}\subcaption{Text} &
  \includegraphics[width=1.8in,height=1.2in]{example-image-c}\subcaption{Text} \\

  \includegraphics[width=1.8in,height=1.2in]{example-image}\subcaption{Text} &
  \includegraphics[width=1.8in,height=1.2in]{example-image-a}\subcaption{Text} &
  \includegraphics[width=1.8in,height=1.2in]{example-image-b}\subcaption{Text} &
  \includegraphics[width=1.8in,height=1.2in]{example-image-c}\subcaption{Text} \\
  \end{tabular}
  \caption{The main caption of the table.}
\label{tab:gr}
\end{sidewaystable}
\end{document}
  • Thanks a lot! How to reduce the space between subcaption and the figures in next row in this case? – Fred Sep 12 '15 at 10:26
  • @Fred Adding \renewcommand{\arraystretch}{0.1} after the \setlength{\tabcolsep}{2pt} helps a bit. – Torbjørn T. Sep 12 '15 at 10:36
  • Is there anyway I can reduce the space significantly? Since each figure should have space to be displayed properly, the size of it should not be too small thus the caption can't occupy too much. – Fred Sep 12 '15 at 13:41
  • @Fred I don't actually know. By the way, is there any text in the subcaptions, or are they empty, so you just get the number? If the latter, consider adding the numbers/letters to the images themselves, and add \phantomsubcaptions for cross referencing (see the subcaption manual). – Torbjørn T. Sep 12 '15 at 14:07
  • Regarding the wrong table number, see sourceforge.net/p/latex-caption/tickets/23 But you could put a \refstepcounter{table} in front of the tabularx environment and cross your fingers anyway. – Axel Sommerfeldt Sep 16 '15 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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