# wrapfigure with enumerate [duplicate]

I would like to use a wrapfigure with enumerate. But it doesn't work. With this code:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{wrapfig}
\usepackage{blindtext}

\begin{document}
And now let's do a little test
\begin{wrapfigure}{r}{4cm}
\centering
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=0em]
{M &N\\
M/N&\\};
\path[-stealth,>=stealth]
(m-1-1)edge node[left]{$p$} (m-2-1)
edge node[above]{$f$}(m-1-2)
(m-2-1)edge[dashed,->]node[below]{$\bar{f}$}(m-1-2);
\end{tikzpicture}
\end{wrapfigure}
\blindtext[1]

\begin{enumerate}
\item\begin{wrapfigure}{r}{4cm}
\centering
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=0em]
{M  &N\\
M/N&\\};
\path[-stealth,>=stealth]
(m-1-1)edge node[left]{$p$} (m-2-1)
edge node[above]{$f$}(m-1-2)
(m-2-1)edge[dashed,->]node[below]{$\bar{f}$}(m-1-2);
\end{tikzpicture}
\end{wrapfigure}
\blindtext[1]
\item\blindtext[1]
\end{enumerate}
\end{document}


I get this:

Now, with cutwin package and this code:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{cutwin}
\usepackage{caption}
\usepackage{lipsum}
\begin{document}
\renewcommand\windowpagestuff{%
\hspace*{25pt}

\begin{tikzpicture}
\matrix (m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=0em]
{ M  &N\\
M/N&\\};
\path[-stealth,>=stealth]
(m-1-1)edge node[left]{$p$} (m-2-1)
edge node[above]{$f$}(m-1-2)
(m-2-1)edge[dashed,->]node[below]{$\bar{f}$}(m-1-2);
\end{tikzpicture}

}
\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}


It doesn't work.

## marked as duplicate by Gonzalo Medina, egreg, Jesse, jub0bs, GuidoApr 12 '14 at 18:26

• As stated in the docs (first page), wrapfig does not work into list environments. You might try to replicate the desired effect with minipages (if this is only for one figure), but the result might not be optimal. – Nico Boni Apr 12 '14 at 16:12
• In your code, what's the point of centering inside a wrapped figure that must be put on the left or the right side? – Bernard Apr 12 '14 at 16:18
• @Bernard he probably wants to center the tikzpicture inside the wrapped space, try to remove the first centering and see the difference. – Nico Boni Apr 12 '14 at 16:20
• Not with wrapfig, but a possible work-around with cutwin is possible: please see tex.stackexchange.com/a/59106/3954. – Gonzalo Medina Apr 12 '14 at 16:30
• I tried this Gonzalo, but I have the following error: Package pgfbasematrix Error: Single ampersand used with wrong catcode. And I have the same error with the picins package – chickpea Apr 12 '14 at 16:40

Using the workaround with cutwin and \parshape I suggested in Will it ever be possible to use wrapfig with an enumerate or itemize environment?. you need to use ampersand replacement for your matrix and make some adjustments for the \parshape settings:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{cutwin}
\usepackage{caption}
\usepackage{lipsum}
\begin{document}
\renewcommand\windowpagestuff{%
\hspace*{25pt}%
\begin{tikzpicture}[ampersand replacement=\&]
\matrix (m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=0em]
{ M  \&N \\
M/N \& \\};
\path[-stealth,>=stealth]
(m-1-1)edge node[left]{$p$} (m-2-1)
edge node[above]{$f$}(m-1-2)
(m-2-1)edge[dashed,->]node[below]{$\bar{f}$}(m-1-2);
\end{tikzpicture}%
}
\opencutleft

\begin{cutout}{2}{0pt}{0.6\linewidth}{8}
\begin{enumerate}
{%
\parshape 11 26pt \linewidth 26pt \linewidth 0.4\linewidth 0.6\linewidth
0.4\linewidth 0.6\linewidth   0.4\linewidth 0.6\linewidth
0.4\linewidth 0.6\linewidth   0.4\linewidth 0.6\linewidth   0.4\linewidth 0.6\linewidth
0.4\linewidth 0.6\linewidth   0.4\linewidth 0.6\linewidth 26 pt \linewidth
\item \lipsum[1]
}%
\item \lipsum[2]
\item \lipsum[2]
\end{enumerate}
\end{cutout}
\end{document}


• Thank you very much @Gonsalo. I tried your solution with the picins package and it works too! – chickpea Apr 12 '14 at 18:29
• @chickpea You're welcome! Glad to hear it worked. Since this question is basically a duplicate of the linked one, and it has been already marked as such, I will delete this answer shortly. – Gonzalo Medina Apr 12 '14 at 18:35
• My personal opinion is that it´s good similar questions, becauswe sometime therre are particular things or new solutions. It´s good punt the link with usefull info to a question. – Mika Ike Apr 13 '14 at 8:27