Float(s) lost: Problem (Possible) from afterpage + double-column

1,297

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}%
Share:
1,297

Related videos on Youtube

Thomas Weise
Author by

Thomas Weise

Updated on July 16, 2020

Comments

  • Thomas Weise
    Thomas Weise over 3 years

    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.

    • Aubrey Blumsohn
      Aubrey Blumsohn over 8 years
      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.
    • Thomas Weise
      Thomas Weise over 8 years
      @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
    Thomas Weise over 8 years
    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).