Not in outer par mode error produced by a single word

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.

• Welcome to TeX.SX! That error is only issued in contexts of floats (figure or table) and \marginpar. – egreg Aug 21 '16 at 7:53
• The methodological approach most recommended for the *TeX world is to isolate the error by constructing what is known as a minimal working example or 'MWE' (see also here). – jon Aug 21 '16 at 18:56
• What's the reason for \afterpage? I see none. You just want \begin{figure}[p]. – egreg Aug 22 '16 at 7:18
• The use of \afterpage to force the figure to be in a separate page (it is a pretty big figure) is suggested at tex.stackexchange.com/questions/22191/… – Mauro Gatti Aug 22 '16 at 9:26
• Removing \afterpage as suggested by egreg completely fixed the problem. Thanks a lot for helping. – Mauro Gatti Aug 22 '16 at 12:42

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.

• Egreg, thanks for very much for the suggestion. Unfortunately it was not enough to fix my problem. I realized that I was having also a problem due to the twocolumn format that required the use of the figure* environment of whose existence I was not aware. See [tex.stackexchange.com/questions/30985/… for details. – Mauro Gatti Aug 27 '16 at 12:38