32 Comments

  1. 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.

  2. ondra

    Hi,

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

    Best regards, Ondra

  3. 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…

  4. 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

  5. Giuseppe

    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

    • 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.

  6. 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.

  7. 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.

  8. Hi,

    Great blog, thanks for that.

    I was wondering whether you or anyone else reading this might have tried putting text inside subfigures. As in, rather than including a graphic, have \texttt or even plain text as the content of the subfigure.

    I’m trying to do this and \subfigure decides that \\ and \newline shouldn’t work inside it.

    Any ideas?

    Thanks,
    Eoin

  9. groupie

    Is it possible to put figures and tables next to eachother. Like a picture to the left and a table to the right next to it???

    I hope someone can help ..

  10. Joan Sola

    Nice post. I found the minipage solution better. You forgot to mention a crucial difference: the minipage solution places two independent figures side-biside, with independent numbering and captioning. The subfigure makes a single figure with sibfigures in it. Sometimes this does not matter, but if both figures have little in common it would be odd to place them in a single figure and two independent figures would then be better.

    So, sumarizing, this is what you get:

    subfigure solution:

    (a) (b)
    Figure 1

    minipage solution:

    Figure 1 Figure 2

  11. chandan

    Is it possible to remove the alphabetic numbering and keep only the captions in the subfigure?

    • Hi Chandan,

      If you are using the subfigure package, try:

      \renewcommand{\thesubfigure}{\relax}

      The relax command does actually nothing.
      For the subfig package, use:

      \usepackage[labelformat=simple]{subfig}

      Cheers, Tom

    • Hi Savan,

      You can use the \hfill command. Assuming you want to display the two logos in your header, you’ll find a minimal example below:

      \documentclass[11pt, twoside]{report}
      \usepackage{fancyhdr, graphicx}
      \usepackage[english]{babel}
      \usepackage{blindtext}
      \pagestyle{fancy}
      \fancyhead{}
      \fancyhead[LE, RO]{\includegraphics{logo1}\hfill\includegraphics{logo2}}
      \begin{document}
      \Blindtext
      \end{document}
      

      It works similarly within text using:

      \includegraphics{logo1}\hfill\includegraphics{logo2}

      Cheers, Tom.

  12. Karolis

    There is a small bug in the code. \label for the whole figure has to go after caption, not before. Otherwise, referencing to the whole figure does not work.

    That is:

    \caption[Optional caption for list of figures]{Caption of subfigures \subref{fig:subfig1}, \subref{fig:subfig2} and \subref{fig:subfig3}}
    \label{fig:subfigureExample}

    Instead of:

    \label{fig:subfigureExample}
    \caption[Optional caption for list of figures]{Caption of subfigures \subref{fig:subfig1}, \subref{fig:subfig2} and \subref{fig:subfig3}}
      • amrinder

        sir, everything works fine with subfigure, only one trouble is coming;
        The subcaptions are placed a little towards left from the centre of figures. which doesnt loook good,,, i have tried evrything using nooneline, hang , centrelast etc. but no desired result is coming . kindly suggest me something..

      • Please send a minimal working example to illustrate the problem and I will try to propose a solution.

Leave a Reply