[Tex/LaTex] Strange wrapfig behavior

wrapfigure

I don't know how to explain this in words, but hopefully this MWE and attachment suffice.

Basically, I don't understand why the second \rule doesn't look like the first and third \rule. I want it to, but no matter what I try (on two different MacTeX installations), I can't get the second \rule to look like the others.

If I'm doing something really silly then I apologize, but…

\documentclass[12pt,titlepage]{article}
\usepackage[autocite=superscript,sorting=none]{biblatex}
\usepackage{upgreek,lipsum,caption}
\usepackage{wrapfig}
\usepackage{doi}
\usepackage[greek,english]{babel}
\usepackage{fontspec}
\usepackage[margin=1in]{geometry}
\setmainfont{Arial}

\begin{document}
\raggedright
\setlength{\parindent}{1cm}

\begingroup
\setlength\intextsep{0pt}
\begin{wrapfigure}{l}[1cm]{2cm}\rule{2cm}{2.67cm}\end{wrapfigure}
\lipsum[1]
\endgroup

The word leukemia is from the Greek leukos meaning "white", and haima "blood." It represents a class of neoplastic diseases affecting the blood (eg. lymphoblastic) and/or blood-forming (eg. myeloid) tissues.

\begingroup
\setlength\intextsep{0pt}
\begin{wrapfigure}{l}[1cm]{2cm}\rule{2cm}{2.67cm}\end{wrapfigure}
Some of the so-called "liquid cancers," there are two main types of leukemia: myeloid (or myelogenous) and lymphoblastic (or lymphocytic). These two main types are further characterized in terms of their severity as either chronic (mild severity requiring months or years to progress) or acute (rapid increase in the number of malignant cells over weeks or months). There are also several less common subtypes of leukemia such as hairy-cell and promyelocytic (or progranulocytic).
\endgroup

In 2011, leukemia represented \textless 5\% of all cancer cases in the US. In 2012, approximately 47,150 Americans will probably be diagnosed with some form of leukemia, and about half of them are expected to die of it.

\begingroup
\setlength\intextsep{0pt}
\begin{wrapfigure}{l}[1cm]{2cm}\rule{2cm}{2.67cm}\end{wrapfigure}
\lipsum[1]
\endgroup

APL accounts for about 10\% of AML patients (\textasciitilde 1 in 250,000 Americans), and about 70\textendash 90\% of APL patients are cured with treatment.

\end{document}

enter image description here

Best Answer

Shift \endgroup as in this code:

\documentclass[12pt,titlepage]{article}
\usepackage[autocite=superscript,sorting=none]{biblatex}
\usepackage{upgreek,lipsum,caption}
\usepackage{wrapfig}
\usepackage{doi}
\usepackage[greek,english]{babel}
\usepackage{fontspec}
\usepackage[margin=1in]{geometry}
\setmainfont{Arial}

\begin{document}
\raggedright
\setlength{\parindent}{1cm}

\begingroup
\setlength\intextsep{0pt}
\begin{wrapfigure}{l}[1cm]{2cm}\rule{2cm}{2.67cm}\end{wrapfigure}
\lipsum[1]
\endgroup

The word leukemia is from the Greek leukos meaning "white", and haima "blood." It represents a class of neoplastic diseases affecting the blood (eg. lymphoblastic) and/or blood-forming (eg. myeloid) tissues.

\begingroup
\setlength\intextsep{0pt}
\begin{wrapfigure}{l}[1cm]{2cm}\rule{2cm}{2.67cm}\end{wrapfigure}
Some of the so-called "liquid cancers," there are two main types of leukemia: myeloid (or myelogenous) and lymphoblastic (or lymphocytic). These two main types are further characterized in terms of their severity as either chronic (mild severity requiring months or years to progress) or acute (rapid increase in the number of malignant cells over weeks or months). There are also several less common subtypes of leukemia such as hairy-cell and promyelocytic (or progranulocytic).


In 2011, leukemia represented \textless 5\% of all cancer cases in the US. In 2012, approximately 47,150 Americans will probably be diagnosed with some form of leukemia, and about half of them are expected to die of it.
\endgroup %%<<<<<<<<<<<<<<<<<<<<<<<<<<<< shift to here.
\begingroup
\setlength\intextsep{0pt}
\begin{wrapfigure}{l}[1cm]{2cm}\rule{2cm}{2.67cm}\end{wrapfigure}
\lipsum[1]
\endgroup

APL accounts for about 10\% of AML patients (\textasciitilde 1 in 250,000 Americans), and about 70\textendash 90\% of APL patients are cured with treatment.

\end{document}

enter image description here