If you want to put several small figures under the same caption, then you need to include the subfigure (along with graphicx) package. The format is something like this:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Contents of main.tex (LaTeX Source) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %%%%%%%%% Preamble %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \documentclass[11pt,a4paper]{article} \usepackage{graphicx, subfigure} % %%%%%%%%% The Document starts here %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \begin{document} % Some random text at the beginning of the document ........ %% % -------------- Include the figures as follows -------------------% %% \begin{figure}[ht!] \begin{center} % \subfigure[Caption of First Figure]{% \label{fig:first} \includegraphics[width=0.4\textwidth]{FirstFigure} }% \subfigure[Caption of Second Figure]{% \label{fig:second} \includegraphics[width=0.4\textwidth]{SecondFigure} }\\ % ------- End of the first row ----------------------% \subfigure[Caption of Third Figure]{% \label{fig:third} \includegraphics[width=0.4\textwidth]{ThirdFigure} }% \subfigure[Caption of Fourth Figure]{% \label{fig:fourth} \includegraphics[width=0.4\textwidth]{FourthFigure} }% % \end{center} \caption{% The l-o-n-g caption for all the subfigures (FirstFigure through FourthFigure) goes here. }% \label{fig:subfigures} \end{figure} %% % -------------- End of figure environment ----------------------% %% The first, second, third and the fourth subfigures in Figure \ref{fig:subfigures} are labeled as \ref{fig:first}, \ref{fig:second}, \ref{fig:third} and \ref{fig:fourth}, respectively. Some more text before the end .......... % \end{document} % %%%%%% The End %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
It will create two rows of subfigures with two subfigures on each row (needless to say, you must have all those figures, viz. FirstFigure.eps through FourthFigure.eps, in the same directory as the LaTeX source file). The optional argument within the square brackets immediately following the subfigure
statement is the caption of the subfigure (besides the main caption for all the subfigures at the end).
Various other options (e.g., cropping, resizing are rotating the figures) for includegraphics
were explained awhile ago.
Reference: here.
Pingback: [latex] Use “fink” package to include filenames with spaces, underscores, etc. « *NIX tricks
Pingback: [latex] Use “fink” package to include filenames with special characters « *NIX tricks
Gula Kapas said:
when i compile, i get the error:
File “subfigure.sty” not found
kousik said:
This error indicates that you don’t have the required style file “subfigure.sty” in the LaTeX search path. As a temporary solution, you may download the subfigure.sty in your working directory and the compile your LaTeX document. (Copy subfigure.sty to the correct directory where all other style file resides to make this solution ‘permanent’!)
Download location in the CTAN archive:
http://www.ctan.org/tex-archive/obsolete/macros/latex209/contrib/misc
rob said:
Thanks, this was a big help.
giorgio said:
HI all, I think that the general label referring to the whole figure must be placed after the caption (that is, \label{fig:subfigures} must go just before \end{figure})
otherwise latex won’t show the good figure number..
giorgio
kousik said:
You are absolutely right. Thanks! I have fixed the problem.
NanashiNanashi said:
Thanks a lot, that helped me!
Anonymous said:
This tutorial is awesome! Thanks!
אורן said:
thanks! works like a charm.
Pingback: Multiple Figures in LaTeX | Ossido di Carbonio
alice said:
Thanks, but how could I have a good alignment for a graph with 4 figures in the first row, and 3 figures in the second row? I would like the figures in the two rows starting from the same postion. I tried to remove \begin{center} and \end{center}, but the two rows are still not in perfect alignment. Thanks.
Nadya said:
Hi I am newbie in LATEX. Your code seems to be real help, but when I tried execute it error appear. ! Missing number, treated as zero. I checked without script – it compiles perfectly. Do you know what else can I check? I really want my figures like this!
Thank you
kousik said:
Is it possible that you are using subcaption package in addition to subfigure? If so, “\subfigure” command will require an additional argument, namely the width of the figure. See
http://tex.stackexchange.com/questions/56163/subfigure-error-missing-number-treated-as-zero/114495#114495
Let me know if this helps.
Pingback: How to center subfigures in Latex - Inside Our Minds