17

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
    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. – David Carlisle Oct 22 '14 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)? – Carlo Todeschini Oct 22 '14 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:-) – David Carlisle Oct 22 '14 at 14:12
17

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}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.