[Tex/LaTex] Latex! not in outer par mode – includegraphics – figure

errorsfloatssubfloats

I'm getting that after certain number of figures, with few ones it works but went I add the last seven ones, I got this, please help.

Here is the structure of each figure, and here the link to the entire code: https://gist.github.com/stellamiranda/9358223

\begin{figure}
\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/insa280}
    \caption{a280}
    \label{fig:a280}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/insberlin52}
    \caption{berlin52}
    \label{fig:berlin52}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/insbier127}
    \caption{bier127}
    \label{fig:bier127}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/insd1291}
    \caption{d1291}
    \label{fig:d1291}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/insd198}
    \caption{d198}
    \label{fig:d198}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/insd493}
    \caption{d493}
    \label{fig:d493}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/insd657}
    \caption{d657}
    \label{fig:d657}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/insfl1400}
    \caption{fl1400}
    \label{fig:fl1400}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/inskroA150}
    \caption{kroA150}
    \label{fig:kroA150}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/inskroA200}
    \caption{kroA200}
    \label{fig:kroA200}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/inskroB100}
    \caption{kroB100}
    \label{fig:kroB100}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/inskroB150}
    \caption{kroB150}
    \label{fig:kroB150}
\end{subfigure} 


\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/inskroB200}
    \caption{kroB200}
    \label{fig:kroB200}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/inskroC100}
    \caption{kroC100}
    \label{fig:kroC100}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/inskroD100}
    \caption{kroD100}
    \label{fig:kroD100}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}

    \includegraphics[width=\textwidth]{PlotsInstances/inskroE100}
    \caption{kroE100}
    \label{fig:kroE100}
\end{subfigure}    

\caption{Algunas instancias de TSPLib}
\label{fig:Algunas instancias de TSPLib}
\end{figure}

Best Answer

On line 822 of the code you linked to, you have:

\begin{figure} % fl1400

\begin{figure} % kroA150

So you start a figure environment inside another and this produces the error (you cannot nest floats); remove the \begin{figure} from line 822. This will leave you now with a

! LaTeX Error: Too many unprocessed floats.

error, since LaTeX can't handle all those consecutive floats you are writing. Adding a \clearpage around line 822 will give you a compilable code.