I am writing an article and I have to display figures side by side. I used the commands from the following link How to order 3 images horizontally? to do that. However, the figures are numbered in sequence, eg. Figure 1, Figure 2 Figure 3. I would like all of them to be part of same figure 1 and have subsections as (a) , (b) and (c).
[Tex/LaTex] Latex figure numbering as part a,b,c
floatssubfloats
Related Solutions
This is a known problem in LaTeX2e; it is fixed by loading the fixltx2e
package.
Here's one possibility using a temporal counter. For me it wasn't clear why you used
\addtocounter{subfigure}{1}
but I respected this in my example codes below.
\documentclass{article}
\usepackage{subfigure}
\usepackage[demo]{graphicx}
\newcounter{tmp}
\begin{document}
\begin{figure}
\centering
\subfigure[a]{\includegraphics[width=0.31\linewidth]{fig1.pdf}}\hfill
\subfigure[b]{\includegraphics[width=0.31\linewidth]{fig2.pdf}}\hfill
\subfigure[c]{\includegraphics[width=0.31\linewidth]{fig3.pdf}}\\
\subfigure[d]{\includegraphics[width=0.31\linewidth]{fig4.pdf}}\hfill
\subfigure[e]{\includegraphics[width=0.31\linewidth]{fig5.pdf}}\hfill
\subfigure[f]{\includegraphics[width=0.31\linewidth]{fig6.pdf}}\\
\refstepcounter{tmp}
\renewcommand\thefigure{\arabic{figure}.\arabic{tmp}}
\caption{title}
\label{fig:11}
\end{figure}
\begin{figure}
\centering
\refstepcounter{tmp}
\renewcommand\thefigure{\arabic{figure}.\arabic{tmp}}
\addtocounter{figure}{-1}
\addtocounter{subfigure}{1}
\subfigure[g]{\includegraphics[width=0.31\linewidth]{fig7.pdf}}\hfill
\subfigure[h]{\includegraphics[width=0.31\linewidth]{fig8.pdf}}\hfill
\subfigure[i]{\includegraphics[width=0.31\linewidth]{fig9.pdf}}
\caption{title}
\label{fig:12}
\end{figure}
\end{document}
subfigure
is an obsolete package which shouldn't be used anymore; in its stead you should use subfig
or subcaption
. Here's the above approach, but using subfig
:
\documentclass{article}
\usepackage{subfig}
\usepackage[demo]{graphicx}
\newcounter{tmp}
\begin{document}
\begin{figure}
\centering
\subfloat[a]{\includegraphics[width=0.31\linewidth]{fig1.pdf}}\hfill
\subfloat[b]{\includegraphics[width=0.31\linewidth]{fig2.pdf}}\hfill
\subfloat[c]{\includegraphics[width=0.31\linewidth]{fig3.pdf}}\\
\subfloat[d]{\includegraphics[width=0.31\linewidth]{fig4.pdf}}\hfill
\subfloat[e]{\includegraphics[width=0.31\linewidth]{fig5.pdf}}\hfill
\subfloat[f]{\includegraphics[width=0.31\linewidth]{fig6.pdf}}\\
\refstepcounter{tmp}
\renewcommand\thefigure{\arabic{figure}.\arabic{tmp}}
\caption{title}
\label{fig:11}
\end{figure}
\begin{figure}
\centering
\renewcommand\thefigure{\arabic{figure}.\arabic{tmp}}
\refstepcounter{tmp}
\addtocounter{figure}{-1}
\addtocounter{subfigure}{1}
\subfloat[g]{\includegraphics[width=0.31\linewidth]{fig7.pdf}}\hfill
\subfloat[h]{\includegraphics[width=0.31\linewidth]{fig8.pdf}}\hfill
\subfloat[i]{\includegraphics[width=0.31\linewidth]{fig9.pdf}}
\caption{title}
\label{fig:12}
\end{figure}
\end{document}
The demo
option for graphicx
simply replaces actual figures with black rectangles; do not use that option in your actual document.
Best Answer
You could also use the
subcaption
package and itssubfigure
environment. The following example sets up the subfigures so that they occupy the full width of the textblock. It also assumes that the graphs associated with each subfigure are all equally wide; if that's not the case, simply adjust the widths of thesubfigure
s appropriately.