# A figure-like environment that can contain many subfigures and break over pages: How to align double-column starts after the thing properly?

I have a problem similar to post 11059, i.e., I need a figure-like environment that can contain an arbitrary number of sub-figures. These may take so much space that the figure may span over multiple pages, i.e., be something like a figure series. Additionally, this environment should work in both single- and double-column documents.

Since I did not find a package that can do that, I tried to make one myself and I think I am almost there. You can find my current solution approach, the "figureSeries" package at my blog. There I discuss my idea in detail, list the currently unfixed problems, and provide everything for download (LaTeX package, sources, examples). To describe my (currently incomplete) approach fully here seems to be too much, especially if I wanted to include code and examples. Thus, I think I leave the details on my website and give only a short outline introducing the main ideas and the problem. (I hope I do not violate any community rules by doing so.)

Anyway, my solution idea works as follows: Like Hendrik Vogt in post 11059, I make a center environment instead of a figure. I make it (almost) float by using the command \afterpage from the afterpage package. Inside the environment (or, actually, command body), the subfigures are rendered as \subcaptionboxs (from the subcaption package. Spacing between the subfigures is achieved via \strut\hfill\struts, so the number of subfigures per row doesn't matter, they will still be distributed nicely. That's all that needs to be done in the single-column case.

For the double-column case, things get more complex: I first switch the \onecolumn, since such a series of figures only makes sense at full page width. \onecolumn causes a page break, but that can be defused by putting the figure series into an \afterpage (it starts on the next page, hence there is a page break anyway). After the the figure series, I switch back to \twocolumn, which would case a page break as well (potentially in the middle of a page, ugly). In order to avoid that, I temporarily \let\clearpage\relax. This in turn messes up the beginning of the following text: The text of the now starting left column begins right under my figure, but in the right column, it starts at the page top (and writes over my figures!). In order to avoid that, I calculate the occupied space of my figure via \pagetotal and then \afterpage a \vspace of the same size into the beginning of the right column. That works almost well: The two columns now often start at the same vertical offset, but sometimes are a bit off... I still need to work on that and welcome any feedback.

That, basically, is my question: How can I properly align the starting lines of the two columns beginning after my figure series vertically? Is there a way to make my method work reliable?

Anyway, as you see, that is a bit too complex to put everything here. Since I would really appreciate help to get this to work right, I wrote a detailed description and included my code and examples at my blog. If the problems with my solution can be fixed, I would post an update here and release it to ctan.

• Welcome to TeX.SE! There's a brand-new package called longfigure on the CTAN. It was uploaded just a few days ago. I haven't tried it out myself so far, but its description sounds like it might be useful to you. – Mico Jun 18 '14 at 21:37
• Yes, I also looked at longfigure. It is really nice. It does not work in double-column documents, though. In other words, if I use longfigure, I need to do the same \onecolumn-\twocolumn trickery I am doing in my approach (which is not yet working well...) – Thomas Weise Jun 18 '14 at 22:38

I think I may have found an answer to my own question. As a result, I could create a package which allows me to have something like figure* which can contain arbitrarily many sub-figures, which looks like it floats, and which can work in both single- and double-column mode. Helpful to solve the problem was the answer of Tomáš Hejda to Multi-page one-column abstract in a two-column document.

I put everything together as a LaTeX package and put it on GitHub under http://github.com/thomasWeise/figureSeries.

## Use Case and Functionality of the figureSeries Package

Figure and figure* environments in LaTeX cannot break across pages. They may, however, include sub-figures. If you have more sub-figures than what fits on one page, you have to manually divide them into two separate figure environments. Doing this is not only tedious, it is virtually impossible to be automated. Such automation may be wanted if you either don't want to do it by hand or if your sub-figures (along with their captions) are automatically generated by some tool.

The package figureSeries provides

1. a facility to include an arbitrary number of (potentially differently-sized) sub-figures into a figure*-like construct,
2. the ability to make this figure*-like construct look as if it was a floating object, which
3. works well in both single-column and double-column documents.