0

I'm trying to create figure that contains many subfigures and I want it to span multiple pages. I'm using the subfigure package to create my figure:

\usepackage{subfigure}

\begin{figure}[!hbp]
\begin{center}
    \subfigure[caption1]{\includegraphics[width = 12cm]{img/plot.png}}
   \subfigure[caption2]{\includegraphics[width = 12cm]{img/plot2.png}}
\end{center}
\end{figure}

After some googling I found a solution but using another package called subfig. However when I tried to use it, I get an error. I get the error just the moment I put the declaration to use \usepackage{subfig}.

Here is the error:

enter image description here

So I either need a solution to work with subfigure or a solution to work with subfig.

  • The subfig and subfigure packages are not compatible. By the way, the subfigure package is deprecated; use either the subfig or the subcaption package. Please provide more information regarding the multi-page nature of the material containing the subfigures. E.g., do you want the material to be contained in a single figure environment? How should the subfigures be numbered: Consecutively as in (a), (b), ..., or in some other style? – Mico Nov 6 '14 at 9:35
  • 1
    Two more comments. First, judging from the screenshot you've posted, it looks like you're using TeXLive2012 -- any chance you can upgrade your system to TeXLive2014? Second, the screenshot also seems to indicate that you're loading the caption package. If that's the case, ditch the subfig (or subfigure) package and load the subcaption package instead. Then, search for "ContinuedFloat" on this site and you'll find several postings about making a figure (or table) extend across more than one page. – Mico Nov 6 '14 at 9:52
  • A float (figure) cannot span more than one page, so you will need to pack your subfigures into multiple figures, one per page. Second, there is nothing \subfigure does than cannot be done using tabular. – John Kormylo Nov 6 '14 at 15:14
  • @Mico I also heard that subfig is deprecated, and now I'm confused which to use! I have one context (figure) that have subfigures (a,b,c). I want the subfigures to be placed either vertically one after the other, or next to each other ... as space allows. – Jack Twain Nov 7 '14 at 6:35
  • @Mico I removed the subfigure and now it compiles with subfig. I was using TeXShop but now I switched to TextMate. – Jack Twain Nov 7 '14 at 6:36
1

If you are going to stack these vertically, you might as well use a separate figure for each image. (I had to shrink it a little to fit 2 per page.)

\documentclass{article}
\usepackage{graphicx}
\usepackage{mwe}

\newcounter{subfig}[figure]
\newcommand{\subcap}[1]% caption
{\refstepcounter{subfig}(\alph{subfig}) {#1}\par\medskip}

\begin{document}
\begin{figure}[!htbp]
\centering\subcap{caption1}\includegraphics[width = 10cm]{example-image-a}
\end{figure}
\begin{figure}[!htbp]
\centering\subcap{caption2}\includegraphics[width = 10cm]{example-image-b}
\end{figure}
\end{document}

Here is a possible \contcaption, but for multipage figures with a single caption you really need a new environment (not figure).

\makeatletter
\newcommand{\contcaption}[0]% no arguments
{\@makecaption\fnum@figure{continued}}%
\makeatother
| improve this answer | |
  • Nice solution! I wondering how and where to add main caption? For example, if there are three page of subcaptions how you know to which figure belongs subfigures on the first or second page? For such a cases memoir (for other packages I don't know) provide contcaption (continuation of caption) which doesn't increment caption's counter. – Zarko Jun 8 '15 at 5:43
  • @Zarko - You can use \captionof{figure}{...} from the caption package, and I added a \contcaption fo the answer. The memoir \contcaption would reset the subfig counter each time. Anyway, where are you going to put it? Every figure? In the header? – John Kormylo Jun 8 '15 at 14:10
  • Your are right about resetting subcaption counter by contcaption. It is useful only if you manually adequate preset subcaption counter in each figure with `contcaption`` – Zarko Jun 8 '15 at 14:24

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.