[Tex/LaTex] Wrapfigure never ends

wrapfigure

I'll be honest and say I don't have a whole lot of experience with LaTeX. That being said, I've been through all the related posts on this topic and I can't seem to get anything to work. I'm trying to get a figure to text-wrap but I think my sections and subsections are getting in the way because the text doesn't wrap after the figure for the rest of the document.

My problem

The associated code is:

\documentclass{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage{ctable}
\usepackage{xcolor,colortbl}
\usepackage{tipa}
\usepackage{graphicx}
\usepackage{wrapfig}

\usepackage[margin = 1.0in]{geometry}

\pagestyle{plain}
\definecolor{Gray}{gray}{0.80}

\begin{document}
    \titlespacing{\section}{0pt}{0pt}{11pt}
    \titlespacing{\subsection}{0pt}{11pt}{0pt}

    \section{Project Narrative}

    \subsection{Preliminary Results}
    At this time, a simple Linear GP has been implemented, ...

    \subsection{Proposed Research}
    To answer the proposed questions the PI will ... Figure \ref{fig:flow1}.

    \begin{wrapfigure}[10]{R}{0.50\textwidth}
        \begin{center}
            \includegraphics[width = 0.48\textwidth]{ea_flow}
        \end{center}
        \caption{Shows the flow of execution ...}
        \label{fig:flow1}
    \end{wrapfigure}

    \subsubsection{Phenotype}
    The phenotype for this research ...

    \subsubsection{Genotype}
    The genotype for this research will ...

/end{document}

Any help in fixing this problem would be greatly appreciated.

Best Answer

I did

\end{wrapfigure}\leavevmode

and everything is ok right now.(but this solution is not ideal, I guess. I do not have a lot of experience too)

enter image description here

Related Question