# ! LaTeX Error: Float(s) lost. ! LaTeX Error: This may be a LaTeX bug. Missing Figures in pdf

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}

\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}
• Welcome to TeX.SX! It seems like you've already done a great deal of detective work to identify which parts of your code are causing the error, if you could distill that into a minimal working example (MWE) which we can compile to replicate your error that will be helpful (and potentially necessary) for us to find out what is going amiss. Reproducing the problem and finding out what the issue is will be much easier with compilable code, starting \documentclass{...} and ending \end{document}. Nov 5 '16 at 22:11
• Yes, you're right, but the problem was to make it minimal... In the meantime I found the work around Nov 5 '16 at 22:14
• If you still can reproduce the "may be a latex bug error" we'd be interested to see a test case (no need to be minimal if that's hard to do) you could send a zip file to me (google for my gmail address) or the official latex bug address latex-project.org/bugs Nov 5 '16 at 23:38
• @DaiBowen I can reproduce but test file is very large and includes half of ctan, most attempts to cut it down make the problem go, I've tried every now and then but nothing much to report so far.... (gets the usual fancyhdr warning about bad headheight, not sure if that's all that's wrong, will try to isolate) Nov 25 '16 at 14:51
• Note you say in the question that you are not using afterpage but the test file was using that (and almost certainly that's the culprit) afterpage is a very dangerous and fragile beast to use on a real document... Nov 25 '16 at 21:39