LaTeX error "Not in outer par mode": cause and fix

Error Not in outer par mode

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

How to fix it

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