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.
\documentclass{article}
\begin{document}
\begin{center}
\begin{tabular}{lr} Sample & 4.2 \\ \end{tabular}
\end{center}
\caption{Measured data}
\end{document}\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}{…}.
\documentclass{article}
\begin{document}
\begin{minipage}{0.45\linewidth}
\centering\rule{3cm}{2cm}
\caption{The probe}
\end{minipage}
\end{document}\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
- LaTeX Error: There's no line here to endA line break (\\ or \newline) comes where no line has started, typically after a blank line. Use \vspace or \medskip for vertical space.
- LaTeX Error: Not in outer par modeA figure, table or \marginpar is inside a box, minipage, table cell or another float. Floats must be in the main text; put the box inside the float.
- LaTeX Error: Too many unprocessed floatsFigures and tables are queued faster than LaTeX can place them, often behind one that cannot be placed. Relax placements, shrink it, or add \clearpage.
- LaTeX Error: Float(s) lostA 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.
- Overfull \hbox (<n>pt too wide) in paragraph at lines <a>--<b>A line sticks out into the margin because TeX found no acceptable place to break it: a long URL or word, or an image or equation wider than the column.
- Underfull \hbox (badness <n>) in paragraph at lines <a>--<b>A line had to be stretched more than TeX likes, leaving wide gaps between words. Usually caused by \\ or \linebreak in running text.
Every example on this page was compiled with pdfLaTeX to check that it fails and is fixed as described. All LaTeX errors