[Tex/LaTex] ! LaTeX Error: Float(s) lost. ! LaTeX Error: This may be a LaTeX bug. Missing Figures in pdf

floats

I'm writing my thesis with the \documentclass{book}.

All worked like a charm until I added a few lines of text to the first section of one of the chapters.

From that moment on, I've got the following error:

! LaTeX Error: Float(s) lost.
! LaTeX Error: This may be a LaTeX bug.

pointing to an \end{figure} that is located (after several sections) in the same chapter, and the figure is not present anymore in the produced pdf.

This chapter contains several large figures that fill an entire page each one. This is one of them.

  • If I comment this figure, the error moves to the next large figure.
  • If I comment the two figures, then the document compiles correctly.
  • If I comment the lines I added in the first section of the chapter and uncomment both the figures, the document compiles correctly.

I checked many questions about the same error but none of them provides a solution for my specific case.
Also,

  • my figures are NOT in a minipage, neither is any of the figures in the whole document
  • I'm NOT using \afterpagehere
  • I'm NOT using any [h] or [htbp] to force the position of my figures (I also tried adding these options to see if something changed, all stayed the same)

My figures are as simple as this:

\begin{figure}
\centering
\includegraphics[scale=1.1]{Immagini/blabla.pdf}
\caption{blablabla}
\label{fig:bla}
\end{figure}

The only difference between the working/not working code is the little text added in the first section.

I really can't figure out the problem and, as you can imagine, I'd like to keep both the new text and the two figures in my thesis 🙂


MWE (OP kindly sent a full document off line, this MWE reproduces the issue, further analysis still needed) [David Carlisle]

MWE reduced further thanks to Dai Bowen

\documentclass[12pt]{book}
\linespread{1.2}

\usepackage{pdflscape}
\usepackage{afterpage}

\usepackage[a4paper]{geometry}
\geometry{left=3.0cm, right=2.5cm, top=2.5cm,bottom=2.5cm}%, includeheadfoot

\begin{document}

\chapter{aa}
\section{S}


aa\\aa\\aa\\aa\\aa\\aa\\aa\\aa\\aa\\aa\\aa\\aa

aa\\aa\\aa\\aa\\aa\\aa\\aa\\aa\\aa\\aa\\aa\\aa
aa\\aa\\aa\\aa


\afterpage{
\clearpage
}

\section{R}
\begin{figure*}
fff
\end{figure*}

\end{document}

Best Answer

I'm experiencing the same problem with one of my documents. The bug disappears as soon as I remove all \afterpage commands.

I have not found the solution, but I could find a "tricky and dirty" workaround: I added a vertical space by using \vskip{5cm} (for instance) to force LaTeX to move the text after the floats that I wanted to flush.

Of course, the main problem is that if you insert some text before, you may be obliged to revise manually each \vskip command to fix the way LaTeX places floatings. Anyway, for my personal purposes it is working fine.

Related Question