Placing figures/tables side-by-side (\subfigure)

By thurnherr

There are two different ways to place two figures/tables side-by-side. The subfigure package provides functionality to arrange figures and tables next to each other, within the usual figure-floating-environment. You can find a post on the minipage-environment here, behaving differently compared a subfigure, but is also used within a floating environment.

Subfigure is a package, therefore the first thing you have to do is add the package to your Latex-document:

\usepackage{subfigure}

Once the package is included, you can start using the environment.


\begin{figure}[ht]
\centering
\subfigure[Caption of subfigure 1]{
\includegraphics[scale=1]{subfigure1.eps}
\label{fig:subfig1}
}
\subfigure[Caption of subfigure 2]{
\includegraphics[scale=1]{subfigure2.eps}
\label{fig:subfig2}
}
\subfigure[Caption of subfigure 3]{
\includegraphics[scale=1]{subfigure3.eps}
\label{fig:subfig3}
}
\label{fig:subfigureExample}
\caption[Optional caption for list of figures]{Caption of subfigures \subref{fig:subfig1}, \subref{fig:subfig2} and \subref{fig:subfig3}}
\end{figure}

If the horizontal margins are exceeded, Latex will automatically place the sub-figure onto the next line.

Subfigure differs from minipage in that you cannot choose the space between two figures, but it is determined automatically, depending on the figure size. There is also a lower limit, whereas using minipage, you can theoretically place your figures directly side-by-side. By default, subfigure will alphabetically number your subfigures and you have access to the comlete reference as usual through \ref{fig:subfig1} or to the letter only through \subref{fig:subfig1}. The optional caption of a subfigure will be placed next to the letter. As usual, a caption can be added to the complete figure.

Subtables can be used in the very same way, just replace the \subfigure by \subtable for each table you want to place horizontally. See here for an introduction on tables. The tabular environment is sufficient, as basically the table environment is replace by subtable.

Remark: Even though not very nice, you can even place sub-figures next to sub-tables.

Tags: , , , , ,

17 Responses to “Placing figures/tables side-by-side (\subfigure)”

  1. thurnherr Says:

    You can find the documentation of the subfigure-package here:
    http://www.ctan.org/tex-archive/obsolete/macros/latex/contrib/subfigure/subfigure.pdf

  2. Floating text around figure/table « Blog on Latex Matters Says:

    [...] page. Even though you can have several figures/tables next to each other (see posts on minipage and subfigure), with none of these techniques it is possible to have floating text around a figure or [...]

  3. Blog on Latex Matters » Blog Archive » Floating text around figure/table Says:

    [...] page. Even though you can have several figures/tables next to each other (see posts on minipage and subfigure), with none of these techniques it is possible to have floating text around a figure or [...]

  4. Blog on Latex Matters » Blog Archive » Placing figures/tables side-by-side (\minipage) Says:

    [...] Remark: Using the subfigure-package is another way to place figures or tables side-by-side. You might want to have a look at this post on subfigures. [...]

  5. Josiah Yoder Says:

    Thanks for the example — it was very helpful! It seems like there is a small typo, however, in the placement of “\label{fig:subfigureExample}”. To be able to use it like “See Figure \ref{fig:subfigureExample}”, it should be in the \caption{} block.

  6. Pandammonium: blogs [pandammonia] Says:

    [...] This is exactly what I wanted to find yesterday. Why didn’t Google find it for me then? I happened across it when looking at this post on side-by-side tables. [...]

  7. siva Says:

    HI,
    Can you give an example of side by side tables.
    Cheers,
    siva

  8. thurnherr Says:

    Hi Siva,

    Check out my post on minipages, there is an example on how to place tables sid-by-side:
    http://texblog.wordpress.com/2007/08/01/placing-figurestables-side-by-side-minipage/

    Cheers,
    Tom

  9. ondra Says:

    Hi,

    it seems to me that the subfigure package is obsolete and is replaced by the subfig.

    Best regards, Ondra

  10. Carlos Says:

    Hey….just want to say thanks for the info…it help me a lot

  11. Seamus Says:

    I was just wondering whether there is a way of globally specifying that the two side by side figures should take up x inches horizontally, or \linewidth or whatever? Rather than specifying the sizes of the figures separately…

  12. thurnherr Says:

    Hi Seamus,

    I am not sure about whether you can specifiy the width globally, but you can always use a relative size of course as you proposed:

    \includegraphics[width=0.45\textwidth]{figure1.jpg}

    Tom

  13. Giuseppe Says:

    Hi,
    I have a structure of this kind

    \begin{table}[htbp]
    \centering
    \subtable[subcatpion1]{
    \begin{tabular}{c|c|c}
    \hline\hline

    \end{tabular}
    }
    \subtable[subcaption2]{
    \begin{tabular}{c|c|c}
    \hline\hline

    \end{tabular}
    }
    \caption{global caption}\label{label of figure}
    \end{table}

    and I would like to have the subcaptions below the subtables, but latex
    puts them above. Do you know how to do it?
    Thanks,

    Giuseppe

    • thurnherr Says:

      Hi Giuseppe,

      Thanks for your comment.

      I assume you are using the “subfigure” package as I proposed. In the mean-time this package became obsolete and was replaced by the “subfig” package.
      I think with the new package, captions are below the figure/table by default, but you can tell Latex to print them below (and similarly above) as follows:

      \usepackage{caption}
      \usepackage[position=below]{subfig}

      The caption package is needed for the option to be recognized by Latex. Also, apparently you have to replace “subtable” with “subfloat”.
      You might be interested in the complete documentation of the package.

      Btw. you probably know, the table option you are using (htbp) does not make much sense (here/top/bottom/page). Usually, one would use something like ht to tell Latex to flush the floating environment content either on this page is there is enough space or on top of the next page.

      Cheers,
      Tom.

  14. Placing figures/tables side-by-side « Bekhongdeokinh’s Blog Says:

    [...] Using subfigure package. Here is an example. [...]

  15. Seamus Says:

    Hi I have another question.

    Is it possible to have a figure aligned to the side and have text wrap around it? i.e. I want to have a figure on the left, but instead of another figure on the right half, I want the main body of my text to flow around it. Is that possible?

    Thanks.

  16. Seamus Says:

    I have found an answer to my own question: You can use the wrapfig package to do what I want. However, it doesn’t float, so you have to be careful where you use it. (i.e. it puts the picture where you tell it to, rather than where it would look best. This can lead to weird stuff happening if you try and include a figure near the very bottom of the page) Any advice on a similar effect that floats would be appreciated.

Leave a Reply