[Tex/LaTex] Not in outer par mode error produced by a single word

errors

While compiling a LateX file I keep on getting the following error message:

! LaTeX Error: Not in outer par mode.

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

l.400 \end{document}

?

I get this error from a text containing this sentence:

In Yang the authors review the application of process mining

If I remove from the text above the word "mining" the error disappears. I am using MikTeX 2.9 and the editor TexWorks 0.6.1. This looks to me as a bug but reinstallation of MikTeX did not fix the problem.

I think I need a methodological approach to spot the source of the error. Any suggestion on what I could do?

Further details

As suggested below by egreg I have removed all \marginpar instruction but that did not fix the error. Then I removed all embedded figures and this fixed the error. It looks like the offending block of code is the following:

\afterpage{
\begin{figure}[h]
    \caption{Time elapsed for critical activities}
    \centering
    \includegraphics[scale=0.6]{Triage-FibrinolysisElapsedTime}
    \label{fig:tfet}
\end{figure}
\clearpage
}

I do not know what is wrong in this block of code, but if I comment it the error disappears. What I do also not know is why this is block of code, that is at the end of the document, makes an error appear when I add the a single word at the beginning of the document.

Best Answer

I'm not sure, for lack of information, what the cause for the error is. However, for a ”pretty big figure“ (but also for all figures) the best approach is to do

\begin{figure}[htp]
<code for the figure>
\caption{...}\label{...}
\end{figure}

I'm not saying that the \afterpage trick has no value, but it should be attempted only in rare cases when the final figure positioning is awkward and no other method succeeds.

Never use the [h] option alone.