6

How come \lipsum works but not actual text? I would like to be able to put my own text in.

This question came out of not getting this answer to work.

Thanks so much for any help.

\documentclass{article}
\usepackage{graphicx,lipsum,wrapfig}% http://ctan.org/pkg/{graphicx,lipsum,wrapfig}
\begin{document}

\begingroup
\setlength{\intextsep}{0pt}
\setlength{\columnsep}{15pt}
\begin{wrapfigure}{r}{0.45\textwidth}
\centering
  \includegraphics[width=\linewidth]{example-image-a}
  \caption{Caption}\label{versusMABs}
\end{wrapfigure}
\lipsum[1]
\endgroup

\begingroup
\setlength{\intextsep}{0pt}
\setlength{\columnsep}{15pt}
\begin{wrapfigure}{r}{0.45\textwidth}
\centering
  \includegraphics[width=\linewidth]{example-image-a}
  \caption{Caption}\label{versusMABs}
\end{wrapfigure}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam ac urna at eros tristique imperdiet et ut mauris. Maecenas semper commodo purus id egestas. Praesent at nisi non magna molestie varius ac sed arcu. Proin aliquet dui eget sapien venenatis rutrum. In vel eleifend tortor, eu sodales nulla. Vivamus sit amet posuere sem. Aliquam scelerisque ac mauris eu feugiat. Donec faucibus est in justo ullamcorper tincidunt. In hac habitasse platea dictumst. Ut et odio a orci eleifend iaculis. Praesent rhoncus auctor arcu eget vulputate. Sed commodo mi id quam hendrerit porttitor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
\endgroup
\end{document}

enter image description here

2 Answers 2

4

\lipsum definition ends with a paragraph end, you need a blank line before the \endgroup as below, or safer if there is any possibility of the group ending before the text cutout is finished, do not put wrapfig in a group at all.

Note that changing \columnsep within the document will have odd effects if you have a two column document and a page break happens to fall within the scope of the change.

enter image description here

\documentclass{article}
\usepackage{graphicx,lipsum,wrapfig}% http://ctan.org/pkg/{graphicx,lipsum,wrapfig}
\begin{document}

\begingroup
\setlength{\intextsep}{0pt}
\setlength{\columnsep}{15pt}
\begin{wrapfigure}{r}{0.45\textwidth}
\centering
  \includegraphics[width=\linewidth]{example-image-a}
  \caption{Caption}\label{versusMABs}
\end{wrapfigure}
\lipsum[1]
\endgroup

\begingroup
\setlength{\intextsep}{0pt}
\setlength{\columnsep}{15pt}
\begin{wrapfigure}{r}{0.45\textwidth}
\centering
  \includegraphics[width=\linewidth]{example-image-a}
  \caption{Caption}\label{versusMABs}
\end{wrapfigure}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam ac urna at eros tristique imperdiet et ut mauris. Maecenas semper commodo purus id egestas. Praesent at nisi non magna molestie varius ac sed arcu. Proin aliquet dui eget sapien venenatis rutrum. In vel eleifend tortor, eu sodales nulla. Vivamus sit amet posuere sem. Aliquam scelerisque ac mauris eu feugiat. Donec faucibus est in justo ullamcorper tincidunt. In hac habitasse platea dictumst. Ut et odio a orci eleifend iaculis. Praesent rhoncus auctor arcu eget vulputate. Sed commodo mi id quam hendrerit porttitor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.

\endgroup
\end{document}
5
  • 1
    I think I would write an explicit \par instead of a blank line, to emphasize to future editors of the source that a paragraph break is needed and it has to be inside the group.
    – zwol
    Aug 11, 2016 at 18:03
  • 1
    @zwol a blank line and \par are same thing, if I were reading a tex file I would not take any note which had been used. Aug 11, 2016 at 18:06
  • Perhaps you have internalized the equivalence better than I (or my coauthors). Having a blank line before \endgroup looks like a mistake to my inner copyeditor.
    – zwol
    Aug 11, 2016 at 18:22
  • Is it always the case that you need an additional paragraph break before the end of the environment? I could not infer that from the current documentation of wrapfig.
    – Vesnog
    Apr 8, 2017 at 17:32
  • 1
    @Vesnog not environments in general, but you can't float wrapfig from inside a group to outside the group as it will lose most of its information at the group end so you need to make sure enough paragraphs end within the group that wrapfig gets inserted Apr 8, 2017 at 18:06
3

The setting of \intextsep to zero is wrong (try it).

It's also better to define your own version of wrapfigure, rather than relying on code duplication in the document. It's necessary to use \wrapfloat and \endwrapfloat to build a new environment similar to the standard ones.

\documentclass{article}
\usepackage{graphicx,lipsum,wrapfig}

\newenvironment{lydiawrapfigure}
 {%
%  \setlength{\intextsep}{0pt}% <--- Wrong!
  \setlength{\columnsep}{15pt}%
  \wrapfloat{figure}%
 }
 {\endwrapfloat}

\begin{document}

\begin{lydiawrapfigure}{r}{0.45\textwidth}
\centering
  \includegraphics[width=\linewidth]{example-image-a}
  \caption{Caption}\label{versusMABs}
\end{lydiawrapfigure}

\lipsum[1]

\begin{lydiawrapfigure}{r}{0.45\textwidth}
\centering
  \includegraphics[width=\linewidth]{example-image-a}
  \caption{Caption}\label{versusMABs2}
\end{lydiawrapfigure}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Nam ac urna at eros tristique imperdiet et ut mauris. 
Maecenas semper commodo purus id egestas. Praesent at 
nisi non magna molestie varius ac sed arcu. Proin aliquet 
dui eget sapien venenatis rutrum. In vel eleifend tortor, 
eu sodales nulla. Vivamus sit amet posuere sem. Aliquam 
scelerisque ac mauris eu feugiat. Donec faucibus est in 
justo ullamcorper tincidunt. In hac habitasse platea 
dictumst. Ut et odio a orci eleifend iaculis. Praesent 
rhoncus auctor arcu eget vulputate. Sed commodo mi id quam 
hendrerit porttitor. Class aptent taciti sociosqu ad litora 
torquent per conubia nostra, per inceptos himenaeos.

\end{document}

enter image description here

2
  • In your document, Figure 2 does not start at the line Lorem ipsum. It starts at tur adipiscing line. This is the problem that I was trying to initially solve! However, I am trying to get it better by defining a new env like you said. Thanks :)
    – Lydia
    Aug 11, 2016 at 17:21
  • @Lydia Probably it's just a matter of omitting the blank line before Lorem
    – egreg
    Aug 11, 2016 at 18:04

You must log in to answer this question.

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