LaTeX Error: Float(s) lost

A figure or table sits inside a footnote, a framed box or a similar construct LaTeX cannot place floats from, and it disappears. Move it into the text.

Help centre › LaTeX errors › Floats and layout · Error: the build stops or the output is wrong

What the log says

! LaTeX Error: Float(s) lost.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.5 \end{document}

What it means

LaTeX accepted a float somewhere it could not later put it on a page, and at the next page break the float was gone. The line number is where LaTeX noticed, often far below the float (even \end{document}), so search for floats inside footnotes, framed boxes and similar constructs.

Causes and fixes

Most common first. Each example is a complete document; the first fails with this message, the second is the same document fixed.

1. A figure or table inside a \footnote

A footnote cannot hold a float. Put the figure in the main text and refer to it from the footnote with \ref.

Fails
\documentclass{article}
\begin{document}
Text.\footnote{See \begin{figure}\centering\rule{2cm}{1cm}\caption{Raw data.}\end{figure}}
\end{document}
Fixed
\documentclass{article}
\begin{document}
Text.\footnote{See Figure~\ref{fig:raw}.}
\begin{figure}\centering\rule{2cm}{1cm}\caption{Raw data.}\label{fig:raw}\end{figure}
\end{document}

2. A float inside a framed, shaded or breakable box

Environments that can break across pages (framed, mdframed, breakable tcolorbox) typeset their content in a way that loses floats. Put the figure outside the box, or inside it without the figure environment, using \captionof from the caption package for the caption.

Fails
\documentclass{article}
\usepackage{framed}
\begin{document}
\begin{framed}
Key result.
\begin{figure}\centering\rule{2cm}{1cm}\caption{Raw data.}\end{figure}
\end{framed}
\end{document}
Fixed
\documentclass{article}
\usepackage{framed}
\begin{document}
\begin{framed}
Key result.
\end{framed}
\begin{figure}\centering\rule{2cm}{1cm}\caption{Raw data.}\end{figure}
\end{document}

3. A \marginpar or \todo note inside a figure or table

A margin note is a float as well, and one inside a figure or table is lost with it. Move the note into the text next to the float.

Fails
\documentclass{article}
\begin{document}
\begin{figure}
\centering
\rule{3cm}{2cm}\marginpar{Check scale}
\caption{A sample.}
\end{figure}
\end{document}
Fixed
\documentclass{article}
\begin{document}
As shown in the figure.\marginpar{Check scale}
\begin{figure}
\centering
\rule{3cm}{2cm}
\caption{A sample.}
\end{figure}
\end{document}

In Manulyx

The editor shows the error with an explanation; because the line is where LaTeX noticed, not where the float is, search the text above it for a float inside a footnote or box.

Write in Manulyx for free · Journal templates

More in floats and layout

Every example on this page was compiled with pdfLaTeX to check that it fails and is fixed as described. All LaTeX errors