# Strange wrapfig behavior

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}


-
\lipsum[1] ends with a \par; in your second paragraph, the \par is seen when the value of \intextsep has already been restored at the end of the group. Add an empty line before the second \endgroup. –  egreg Nov 13 '12 at 23:50

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}


-
you and egreg beat me to the answer by a fraction so I +1 this rather than posting mine:-) The OP would be best to put a blank line before every \endgroup (or not have the groups at all) placing paragraphs in groups that do not include the paragraph end almost always leads to trouble. –  David Carlisle Nov 13 '12 at 23:59
@DavidCarlisle: Thanks and you are right. Paragraphs are better be not placed inside groups. In this particular case groups may be avoided altogether. –  Harish Kumar Nov 14 '12 at 0:01