20

If I use an image with wrapfig into or near an itemized list, the result is the image overlapped to the text (see picture). I red a lot of posts related to wrapfig and itemize incompatibility but no one solved the problem ;-) Any help?

\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{lipsum}

\begin{document}

This is an example: first paragraph is OK but the second have the problem!

\begin{itemize}
  \item 
    \parbox[t]{\dimexpr\textwidth-\leftmargin}{%
      \vspace{-2.5mm}
      \begin{wrapfigure}{r}{0.5\textwidth}
        \centering
        \includegraphics[width=\linewidth]{beach.png}
        \caption{The beach}
      \end{wrapfigure}
      \lipsum[1]
    }
  \item
    \parbox[t]{\dimexpr\textwidth-\leftmargin}{%
      \vspace{-2.5mm}
      \begin{wrapfigure}{r}{0.5\textwidth}
        \centering
        \includegraphics[width=\linewidth]{beach.png}
        \caption{The beach}
      \end{wrapfigure}
      This is a short text...
    }
  \item \lipsum[1]
  \end{itemize}

\end{document}

Resulting image

3
  • 4
    wrapfig.sty says: Some idiosyncrasies: - You must not specify a wrapfigure in any type of list environment or or immediately before or immediately after one. It is OK to follow a list if there is a blank line ("\par") in between. Commented Oct 22, 2014 at 13:15
  • @DavidCarlisle: this is not a general solution. In fact, if I have a text in the second \item bigger than "This is a short text..." (try "\lipsum[1]") the result is bad. May I try to put the image outside the itemize (I mean before the star of the itemize set)? Commented Oct 22, 2014 at 14:00
  • It doesn't try to be general: I explicitly make a blank wrapfig in the last entry to leave space with a hand tuned number of rows. If your image or text is a different size you need to change the numbers. But it can allow you to finish a document. The general solution is to follow the documented usage and don't use wrapfig in lists:-) Commented Oct 22, 2014 at 14:12

1 Answer 1

20

Using wrapfig in lists is explicitly unsupported, but if you want to do it anyway it works if you help it a bit:

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
\usepackage{lipsum}

\begin{document}

This is an example: first paragraph is OK but the second have the problem!

\begin{itemize}
  \item 
    \parbox[t]{\dimexpr\textwidth-\leftmargin}{%
      \vspace{-2.5mm}
      \begin{wrapfigure}[10]{r}{0.5\textwidth}
        \centering
        \vspace{-\baselineskip}
        \includegraphics[width=\linewidth]{beach.png}
        \caption{The beach}
      \end{wrapfigure}
      \lipsum[1]
    }
  \item
    \parbox[t]{\dimexpr\textwidth-\leftmargin}{%
      \vspace{-2.5mm}
      \begin{wrapfigure}{r}{0.5\textwidth}
        \centering
        \vspace{-\baselineskip}
        \includegraphics[width=\linewidth]{beach.png}
        \caption{The beach}
      \end{wrapfigure}
      This is a short text...
    }
  \item     \parbox[t]{\dimexpr\textwidth-\leftmargin}{%
      \vspace{-2.5mm}
      \begin{wrapfigure}[8]{r}{0.5\textwidth}
      \end{wrapfigure}
\lipsum[1]}
  \end{itemize}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .