# Will it ever be possible to use wrapfig with an enumerate or itemize environment?

wrapfig is incompatible with the enumerate and itemize environments. Is there a typographical reason not to wrap a list around a figure or is it a technical limitation of LaTeX? If it is a technical limitation, is there any work (new packages or changes to LaTeX) currently being done to eliminate the limitation in the future?

Edit: To respond to some of the comments: I realize that there are "gymnastics" which can make this work. I do not have an example of the problem. Whenever I run into a problem with wrapfig because it is near an enumerate or itemize environment, I search for an easy solution, find none, and move the figure elsewhere. In the vast majority of cases, the cost of learning the complex solutions isn't worth the benefit of keeping the figure where I want it.

-
It is would be helpful if you would compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. –  Peter Grill Jun 8 '12 at 18:44
I have some thoughts for LaTeX3: currently we still need to do work on this, but I would expect 13galley to eventually cover this. –  Joseph Wright Jun 8 '12 at 19:04
Another solution to having cutouts in latex lists is given here tex.stackexchange.com/questions/53702/… –  David Carlisle Jun 8 '12 at 20:45

The cutwin package (and some \parshape gymnastics) can be used here:

\documentclass{article}
\usepackage{cutwin}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{lipsum}

\begin{document}
\renewcommand\windowpagestuff{%
\hspace*{25pt}\includegraphics[height=4cm]{ctanlion}
\captionof{figure}{A test figure.}
}
\opencutleft

\begin{cutout}{2}{10pt}{0.5\linewidth}{12}
\begin{enumerate}
{%
\parshape 15 26pt \linewidth 26pt \linewidth 0.5\linewidth 0.5\linewidth
0.5\linewidth 0.5\linewidth  0.5\linewidth 0.5\linewidth  0.5\linewidth 0.5\linewidth
0.5\linewidth 0.5\linewidth   0.5\linewidth 0.5\linewidth   0.5\linewidth 0.5\linewidth
0.5\linewidth 0.5\linewidth   0.5\linewidth 0.5\linewidth   0.5\linewidth 0.5\linewidth
0.5\linewidth 0.5\linewidth   0.5\linewidth 0.5\linewidth 26 pt \linewidth
\item \lipsum[1]
}%
\item \lipsum[2]
\item \lipsum[2]
\end{enumerate}
\end{cutout}

\end{document}


CTAN lion drawing by Duane Bibby.

-
This should even work if you want to put the picture at the start of the numbering. I didn't try it with cutwin, but just an ordinary \parshape. –  Werner Jun 8 '12 at 19:05
@Werner you're probably right; I used cutwin to put the figure after some lines of the numbering; right now I have to leave, but I will do some tests later and post some code if no one else has done it. –  Gonzalo Medina Jun 8 '12 at 19:09
If this is a good, general solution to the problem, would it be possible to develop a package which makes it possible to do this as few of lines of code as wrapfig? Could wrapfig be modified to use this alternative approach when used in a list? –  ScottKu Jun 8 '12 at 20:01
Your minimal working example (cut win package) fails if one uses a different font, say \usepackage{palatino}. –  Vafa Khalighi Jun 9 '12 at 3:18
@VafaKhalighi yes, obviously it fails, because wrapping is related to font dimensions, that's why the packages like cutwin and wrapfig do exist, but in some cases, they cannot be used. The same problem can arise if the text contains inline math which changes the real baseline distance... –  tohecz Jun 9 '12 at 6:36

FWIW, wrapfigure works out of the box in ConTeXt. So, it is clearly not a limitation of TeX.

\setuppapersize[A5]

\useexternalfigure[ctanlion][http://www.ctan.org/lion/ctan_lion_350x350.png][width=3cm]

\starttext

\placefigure[left,2*hang]{Test}
{\externalfigure[ctanlion]}

\startitemize[n]
\item \input ward
\item \input ward
\item \input ward
\stopitemize

\stoptext


which gives:

Removing 2*hang from \placefigure gives:

-

Here's a kluge. It replaces itemize with a lookalike, instead of trying to fiddle around with wrapfig.

\documentclass{article}

%put this code in preamble
\newlength{\bulletwidth}\settowidth{\bulletwidth}{$\bullet$}
\newcommand{\mitem}{\setlength{\leftskip}{\leftmargin}\hspace*{-\labelsep}\hspace*{-\bulletwidth}$\bullet$\hspace*{\labelsep}}
\newcommand{\mend}{\setlength{\leftskip}{0cm}}

\begin{document}

Some text.

\mitem This is an example of a list item.

\mitem Second item in list.

\mend

Some more text.

\end{document}


Each \mitem in the list must be preceded by a blank line. The list ends with \mend (also preceded by a blank line). There's no command to begin the list. This works for simple text items; I haven't tried it with anything more complicated.

Someone who knows more about how itemize works (and why it conflicts with wrapfig) might be able to make an even better imitation. It would also be fairly easy to generalize this to enumerate'd lists if necessary.

-