LaTeX error "Not in outer par mode": cause and fix
A float (figure or table) or a \marginpar stands inside a box. LaTeX can only place floats and margin notes from the normal text of the page, not from inside a minipage, a \parbox, a table cell or another float.
Why it happens
- A
figureortableenvironment stands inside aminipageor a\parbox, often to put two figures side by side. - A
figurestands inside anotherfigureortable, for example inside asubfigure. - A
figureortablestands in a cell of atabular. \marginparis used in a table cell or inside\fbox.
How to fix it
- Turn the nesting around: the
figuregoes outside and theminipageinside. See Place images side by side in LaTeX. - For a captioned image inside a box without a float, drop the
figureenvironment and use\captionof{figure}{...}fromcaption. - For subfigures, put only
\includegraphicsand\captioninto eachsubfigure, with onefigurearound all of them. See Subfigures in LaTeX. - With
floatloaded,\begin{figure}[H]does not float and is allowed inside aminipage.
A document that produces the message
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{minipage}{0.5\textwidth}
\begin{figure}
\centering
\includegraphics[width=4cm]{image}
\caption{A figure}
\end{figure}
\end{minipage}
\end{document}The corrected document
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\begin{minipage}{0.5\textwidth}
\centering
\includegraphics[width=4cm]{image}
\caption{A figure}
\end{minipage}
\end{figure}
\end{document}Both documents were compiled with pdfLaTeX from TeX Live 2023. The first produces the message, the second compiles without an error.
Finding the line in the editor
The editor lists every error and warning of a compile run with file and line. Select an entry and the cursor jumps to that line. See Error list with jump to the line.
Related pages
- Error Float(s) lost
- Error \caption outside float
- How-to Place images side by side in LaTeX
- How-to Subfigures in LaTeX