LaTeX Error: \caption outside float.

\caption is used outside a figure or table environment. Wrap the content in figure or table, or use \captionof from the caption package.

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

What the log says

! LaTeX Error: \caption outside float.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
l.6 \caption{Measured data}

What it means

\caption numbers and labels a figure or table, so it has to be inside a figure or table environment (or another float) to know which counter to use. Outside one, LaTeX does not know whether this is a figure or a table and stops.

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. An image or tabular with a caption but no figure or table around it

Wrap the content and its caption in \begin{figure}…\end{figure} or \begin{table}…\end{table}, with \label after \caption.

Fails
\documentclass{article}
\begin{document}
\begin{center}
\begin{tabular}{lr} Sample & 4.2 \\ \end{tabular}
\end{center}
\caption{Measured data}
\end{document}
Fixed
\documentclass{article}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{lr} Sample & 4.2 \\ \end{tabular}
\caption{Measured data}
\end{table}
\end{document}

2. The caption is wanted in a fixed place, not a floating one

To keep a captioned figure exactly where it is (in a minipage, a multicolumn layout or a slide), load \usepackage{caption} and write \captionof{figure}{…} or \captionof{table}{…}.

Fails
\documentclass{article}
\begin{document}
\begin{minipage}{0.45\linewidth}
\centering\rule{3cm}{2cm}
\caption{The probe}
\end{minipage}
\end{document}
Fixed
\documentclass{article}
\usepackage{caption}
\begin{document}
\begin{minipage}{0.45\linewidth}
\centering\rule{3cm}{2cm}
\captionof{figure}{The probe}
\end{minipage}
\end{document}

3. The float ended before the caption

A misplaced \end{figure} leaves the \caption after it outside. Check that \caption sits before the float's \end.

In Manulyx

The editor shows the error beside the \caption line with an explanation.

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