0

I am working on a package which allows for figures with many subfigures which can break over multiple pages. So far, my figureSeries package is working in most scenarios, except that I sometimes get "Float(s) lost" errors, which I do not understand. The whole situation is quite complex and I am not good enough in LaTeX yet to grasp it.

So far, they only occured in double-column documents (IEEEtran and sig-alternate). In my package, I use \afterpage to 'simulate' a multi-page float. Inside double-column documents, I switch to \onecolumn and back to \twocolumns after my figure series. I also use two nested \afterpage to get to the second column if I am in the first one.

The error can be reproduced with the following MWE, in which I use lorem ipsums as filler text and resized letters instead of graphics.

\documentclass{IEEEtran}%
\RequirePackage{lipsum}%
\RequirePackage{graphicx}%
\RequirePackage{figureSeries}%
%
\begin{document}%
%
\begin{figure*}%
\resizebox{0.19\linewidth}{0.12\textheight}{o}%
\caption{Interdum primis ultrices augue.}%
\end{figure*}
%
\lipsum[1-7]%
%
\begin{figure*}%
\resizebox{0.19\linewidth}{0.15\textheight}{j}%
\caption{Inceptos eget varius curae;.}%
\end{figure*}%
%
\figureSeriesFloat{Urna massa sollicitudin curae;.}{%
\figureSeriesRow{%
\figureSeriesElement{Vulputate exercitation faucibus fusce.}{\resizebox{0.95\linewidth}{0.21\textheight}{n}}%
}%
\figureSeriesRow{%
\figureSeriesElement{Nec per sodales aliquyam.}{\resizebox{0.95\linewidth}{0.21\textheight}{n}}%
}%
}%
%
\begin{figure}%
\resizebox{0.31\columnwidth}{0.13\textheight}{o}%
\caption{Sodales condimentum nascetur tempus?}%
\end{figure}%
%
\begin{figure}%
\resizebox{0.31\columnwidth}{0.15\textheight}{j}%
\caption{Soluta autem nascetur litora.}%
\end{figure}%
%
\lipsum[14]%
%
\end{document}%

My figureSeries package has the following code, which you can find documented in the GitHub repository. The documentation PDF there also includes multiple examples and a discussion why having a package such as figureSeries could be useful.

\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{figureSeries}
    [2015/02/13 v0.9.2 Provides a floating, figure*-like construct that can break over multiple pages]
\newif\if@figSer@captionCompatibilityFalse%
\@figSer@captionCompatibilityFalsefalse%
\ifx\spnewtheorem\@undefined%
\else%
\@figSer@captionCompatibilityFalsetrue%
\fi%
\if@figSer@captionCompatibilityFalse%
\RequirePackage[compatibility=false]{caption}%
\else%
\RequirePackage{caption}%
\fi%
\RequirePackage{subcaption}%
\DeclareCaptionSubType*[arabic]{figure}%
\RequirePackage{afterpage}%
\long\gdef\figureSeriesElement#1#2{%
\strut\hfill\strut%
\edef\@captype{figure}%
\subcaptionbox{#1}{#2}%
\strut\hfill\strut%%
}%
\long\gdef\figureSeriesRow#1{%
\begin{center}%
\ifx\@figSer@delayedCaption\@empty%
\vspace\abovecaptionskip%
\strut#1\strut%
\else%
\parbox[b]{\textwidth}{%
\@figSer@delayedCaption%
\xdef\@figSer@delayedCaption{}%
\vspace\abovecaptionskip%
\strut#1\strut%
}%
\fi%
\end{center}%
}%
\long\def\figureSeriesHere#1#2{%
\@figSer@detectColumns%
\if@figSer@isTwoColumns%
\@figSer@hereTwoCol{#1}{#2}%
\else%
\@figSer@hereOneCol{#1}{#2}%
\fi%
}%
\long\gdef\figureSeriesFloat#1#2{%
\@figSer@detectColumns%
\if@figSer@isTwoColumns%
\@figSer@floatTwoCol{#1}{#2}%
\else%
\@figSer@floatOneCol{#1}{#2}%
\fi%
}%
\newif\if@figSer@isTwoColumns%
\@figSer@isTwoColumnsfalse%%
\def\@figSer@detectColumns{%
\@figSer@isTwoColumnsfalse%
\ifx\multicols\@undefined%
\else%
\ifnum\col@number>\@ne%
\@figSer@isTwoColumnstrue%
\fi%
\fi%
\if@twocolumn%
\@figSer@isTwoColumnstrue%
\fi%
}%
\edef\@figSer@delayedCaption{}%
\long\def\@figSer@hereOneCol#1#2{%
\def\@figSer@delayedCaption{%
\noindent\parbox{\textwidth}{%
\captionof{figure}{#1}%
\global\advance\c@figure by 0%
}%
\par}%
\begin{center}%
#2%
\end{center}%
\medskip%
}%
\long\def\@figSer@floatOneCol#1#2{%
\afterpage{\@figSer@hereOneCol{#1}{#2}}%
}%
\xdef\@figSer@floatingBody{}%
\gdef\@figSer@afterPage{%
\@figSer@longTwoColumnMain[\@figSer@floatingBody]%
\xdef\@figSer@floatingBody{}%
}%
\long\def\@figSer@floatTwoCol#1#2{%
\ifx\@figSer@floatingBody\@empty%
\gdef\@figSer@floatingBody{\@figSer@hereOneCol{#1}{#2}}%
\if@firstcolumn%
\afterpage{\afterpage{\@figSer@afterPage}}%
\else%
\afterpage{\@figSer@afterPage}%
\fi%
\else%
\g@addto@macro{\@figSer@floatingBody}{\@figSer@hereOneCol{#1}{#2}}%
\fi%
}%
\let\@figSer@hereTwoCol\@figSer@floatTwoCol%
\newsavebox\@figSer@box%
\def\@figSer@breakBodyRepeat@Orig{%
\@figSer@longTwoColumn[{\@twocolumnfalse%
\ifdim\ht\@figSer@box>1.00\textheight%
\begingroup%
\vbadness10000%
\setbox0\vsplit\@figSer@box to 1.00\textheight%
\setbox1\vbox{\unvbox\@figSer@box}%
\global\setbox\@figSer@box\vbox{\unvbox1}%
\setbox2\vbox to \textheight{%
\unvbox0%
}%
\ht2=0.9\textheight%
\box2%
\endgroup%
\else%
\ifdim\ht\@figSer@box>0.84\textheight%
\global\let\@figSer@breakBodyRepeat\clearpage%
\else%
\global\let\@figSer@breakBodyRepeat\relax%
\fi%
\unvbox\@figSer@box%
\vspace{15pt plus 15pt}%
\fi%
}]%
\@figSer@breakBodyRepeat%
}%
\long\def\@figSer@longTwoColumnMain[#1]{%
\let\@figSer@breakBodyRepeat\@figSer@breakBodyRepeat@Orig%
\begingroup%
\let\@figSer@longTwoColumn\twocolumn%
\@figSer@longTwoColumn[{\@twocolumnfalse%
\global\setbox\@figSer@box\vbox{#1}%
\ifdim\ht\@figSer@box>\textheight%
\begingroup%
\vbadness10000%
\setbox0\vsplit\@figSer@box to 1.00\textheight%
\setbox1\vbox{\unvbox\@figSer@box}%
\global\setbox\@figSer@box\vbox{\unvbox1}%
\setbox2\vbox to \textheight{%
\unvbox0%
}%
\ht2=0.9\textheight%
\box2%
\endgroup%
\else%
\ifdim\ht\@figSer@box>0.87\textheight%
\global\let\@figSer@breakBodyRepeat\clearpage%
\else%
\global\let\@figSer@breakBodyRepeat\relax%
\fi%
\unvbox\@figSer@box%
\fi%
}]%
\@figSer@breakBodyRepeat%
\endgroup%
}%
\endinput

I would be very thankful if anyone can help me to solve this problem.

  • Not an answer -- but I eventually eliminated afterpage from all of my documents and macros after facing recurrent, and all completely inexplicable "floats lost" problems. I spent hundreds of hours working on the problem. – Aubrey Blumsohn Jun 27 '15 at 7:52
  • @aubrey: Hm, currently, I need to use \afterpage in my package (but I am happy to switch if there would be an alternative which would not cause the reported problem). My package provides a series of (sub-)figures which can span multiple pages. It works for both single- and double-column documents. I use \afterpage to make the figure series float. I need to make it float, as a figure series behaves like a figure* in two-column documents. For this I need to use \onecolumn. But if I do \onecolumn in the middle of the page, it would leave half the page empty. So I \afterpage it. – Thomas Weise Jun 27 '15 at 8:19
1

I didn't attempt to trace what your code is doing but the figureseries float code is losing the existing double column floats that are pending at this point. If you flush them out with \clearpage then no floats are lost.

\documentclass{IEEEtran}%
\RequirePackage{lipsum}%
\RequirePackage{graphicx}%
\RequirePackage{figureSeries}%
%
\begin{document}%
%
\begin{figure*}%
\resizebox{0.19\linewidth}{0.12\textheight}{o}%
\caption{Interdum primis ultrices augue.}%
\end{figure*}
%
\lipsum[1-7]%
%
\begin{figure*}%
\resizebox{0.19\linewidth}{0.15\textheight}{j}%
\caption{Inceptos eget varius curae;.}%
\end{figure*}%
%
\clearpage
\figureSeriesFloat{Urna massa sollicitudin curae;.}{%
\figureSeriesRow{%
\figureSeriesElement{Vulputate exercitation faucibus fusce.}{\resizebox{0.95\linewidth}{0.21\textheight}{n}}%
}%
\figureSeriesRow{%
\figureSeriesElement{Nec per sodales aliquyam.}{\resizebox{0.95\linewidth}{0.21\textheight}{n}}%
}%
}%
%
\begin{figure}%
\resizebox{0.31\columnwidth}{0.13\textheight}{o}%
\caption{Sodales condimentum nascetur tempus?}%
\end{figure}%
%
\begin{figure}%
\resizebox{0.31\columnwidth}{0.15\textheight}{j}%
\caption{Soluta autem nascetur litora.}%
\end{figure}%
%
\lipsum[14]%
%
\end{document}%
  • Yes, that would work. But it may also create half-filled pages, which I want to avoid with my package. In the new version, based on package cuted (see also tex.stackexchange.com/questions/255091), this problem can be avoided. It is not an error in \afterpage, but caused by my code (or better: my lack of understanding of LaTeX). – Thomas Weise Jul 15 '15 at 11:48
0

My original answer attempt below was wrong

It solved the problem in my minimal example and some other situations, but now the error appears in documents which previously did not exhibit it. :-(

I now use the packages placeins and everypage in conjunction to do yet another hack: When I begin a floating figure series, I issue an \AddThispageHook{\FloatBarrier}, which seems to get rid of the compiler errors. This is not a nice solution, but at least my erroring-example above works with it. I updated my figureSeries package with this "fix" to release 0.9.3.

It turns out that the culprint was \if@firstcolumn which I used to determine whether I need to do \afterpage once or twice. However, \if@firstcolumn is unreliable. After several attempts to fix my package, I found the cuted package whose strip environment can do the layout I need. However, now I am facing another problem: `strip` Environment Does Not Work in Empty Document / Interaction with `\afterpage`

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.