5

This is more a comment than a question. I've tried several hours to wrap text around a picture using the wrapfig package.

Among others, I have relied on

Adjusting left/right margins of a wrapfig

and

Too much space around wrap figure

as that is exactly what I am looking for. I could not get it working for one reason - I was using \blindtext[] instead of \lipsum[]. Interestingly, those examples not running with lipsum do not work with "real" input, neither. Have a look at my example:

    \documentclass[10pt,a5paper]{article}
    \usepackage[demo]{graphicx}
    \usepackage{wrapfig}
    \setlength{\parindent}{0pt}

    \usepackage{lipsum}
    \usepackage{blindtext}
    \begin{document}
    %########################## works with both lipsum and blindtext AND real text.
    \lipsum[1]
    %\blindtext[1]
    \begin{wrapfigure}[9]{r}{0.5\textwidth}
        \centering
            \vspace{-12pt}
        \includegraphics[width=0.5\textwidth]{cow.jpg}
    \end{wrapfigure}
    %\lipsum[1]
    \blindtext[1]
    %########################## works only on lipsum
    \newpage
    \lipsum[1]
    %\blindtext[1]
    \begingroup
        \setlength{\columnsep}{8pt}%    
        \setlength{\intextsep}{0pt}%
        \begin{wrapfigure}[9]{r}{0.5\textwidth}
            \centering
    %       \vspace{-12pt}
            \includegraphics[width=0.5\textwidth]{cow.jpg}
    %       \includegraphics[width=\linewidth]{cow.jpg}
    %       \vspace{+12pt}
        \end{wrapfigure}
    %\lipsum[1]
    \blindtext[1]
    \endgroup
    \end{document}
5

\lipsum ends the paragraph with \par you need the * form to avoid adding \par but the main reason the second example was overprinting is the somewhat brave use of wrapfig inside a local group, especially as you ended the group with blindtext not followed by a paragraph so you lost the parshape setting before the paragraph was set.

\documentclass[10pt,a5paper]{article}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
\setlength{\parindent}{0pt}

\usepackage{lipsum}
\usepackage{blindtext}
\begin{document}
%########################## works with both lipsum and blindtext AND real text.
\lipsum[1]
%\blindtext[1]
\begin{wrapfigure}[9]{r}{0.5\textwidth}
    \centering
        \vspace{-12pt}
    \includegraphics[width=0.5\textwidth]{cow.jpg}
\end{wrapfigure}
%\lipsum[1]
\blindtext[1]
%########################## works only on lipsum
\newpage
\lipsum*[1]
%\blindtext[1]
\begingroup
    \setlength{\columnsep}{8pt}%    
    \setlength{\intextsep}{0pt}%
    \begin{wrapfigure}[9]{r}{0.5\textwidth}
        \centering
%       \vspace{-12pt}
        \includegraphics[width=0.5\textwidth]{cow.jpg}
%       \includegraphics[width=\linewidth]{cow.jpg}
%       \vspace{+12pt}
    \end{wrapfigure}
%\lipsum[1]
\blindtext[1]\par
\endgroup
\end{document}
3
  • Thank you @DavidC for answering. \par after \lipsum[] or some text solves the issue. I did not feel good about using wrapfigure. It was, however, the only way I could have my images inline with some text after a gap. Still, the examples mentioned above do not address the problem. This one [tex.stackexchange.com/questions/82647/… is a more specific in that matter.
    – lactea
    Jun 13 '14 at 10:34
  • 1
    @lactea nothing wrong with using wrapfig but using it surrounded by \begingroup \endgroup makes it very fragile and you need to make sure if you do that that (a) you end the paragraph before \endgroup and (b) that you have enough text to wrap the figure within the group, but far simpler and safer is not to surround wrapfig by the group. Jun 13 '14 at 11:40
  • I have tried that, too. I could not manage to reliably have the top border of the image to be inline with the upper margin of the text field and have the \columsep at a given value. The document I am working on has always enough text to wrap around, so that is no concern.
    – lactea
    Jun 13 '14 at 11:48

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.