0

For the following MWE, why is the first image overlayed with the text when using \lipsum instead of pasting dummy text?

And how to fix the other two images to be placed properly next to their respective texts?

enter image description here

\documentclass{exam}
\usepackage{adjustbox,wrapfig,lipsum}

\newenvironment{mywrapfigure}
{%
    \setlength{\columnsep}{15pt}%
    \wrapfloat{figure}%
}
{\endwrapfloat}

\begin{document}

    \begin{mywrapfigure}{r}{0.3\linewidth}
        \centering
        \includegraphics[width=\linewidth]{example-image-a}
    \end{mywrapfigure}

    \lipsum[1]

    \bigskip
    \begin{questions}
        \question

        \begin{mywrapfigure}{r}{0.3\linewidth}
            \includegraphics[width=\linewidth]{example-image-b}
        \end{mywrapfigure}

        \lipsum[1]

        \bigskip
        \begin{parts}

            \part[4]

            \begin{mywrapfigure}{r}{0.3\linewidth}
                \includegraphics[width=\linewidth]{example-image-c}
            \end{mywrapfigure}

            \lipsum[1]

        \end{parts}

    \end{questions}
\end{document}
6
  • that is a bug in the lipsum package github.com/patta42/lipsum/issues/16. Dec 27 '19 at 21:58
  • My suggestion, ditch lipsum and use duckuments instead with \blindduck. If you then use \blindduck[1-] it will then use only one paragraph but correctly add a \par after it.
    – Skillmon
    Dec 27 '19 at 22:06
  • 1
    But nevertheless you will have issues getting wrapping figures in \question or \part stuff using wrapfig. Take a look here: tex.stackexchange.com/questions/476381
    – Skillmon
    Dec 27 '19 at 22:13
  • @Skillmon it is not a quick fix as I assumed. Thanks for sharing this with me.
    – Diaa
    Dec 27 '19 at 22:22
  • 1
    @Diaa note that my answer there doesn't deal with parts and I'm at least somewhat sure that it will not work out of the box in parts. So it might be a good idea to ask a follow up if you need it to work there automatically.
    – Skillmon
    Dec 27 '19 at 22:30

Browse other questions tagged or ask your own question.