2

I use the wrapfigure package to make text wrapped around an image. Everything is fine except one thing: I want to move it lower on the page and make some (2 or 3) lines come before it. On the image you see, that the first line of the paragraph "wants" to wrap the image on the top, but can't.

Here is my current result

Command is:

Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. 


\begin{wrapfigure}[16]{o}{5cm}
\centering
\includegraphics[width=0.4\textwidth]{img01.jpg}
\captionsetup{labelsep=period}
\caption*{This is a figure caption.}
\end{wrapfigure}
\lipsum[1]

2 Answers 2

3

First set the text without the image, then add the wrapfig at the point a natural linebreak occurs.

enter image description here

\documentclass[10pt,a4paper]{article}

\usepackage{wrapfig,graphicx}

\begin{document}

Text here. Text here. Text here. Text here. Text here. Text here. Text
here. Text here. Text here. Text here. Text here. Text here. Text
here. 


Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum
gravida mauris. Nam arcu libero, nonummy eget, consectetuer id,
vulputate a, magna.%
    \begin{wrapfigure}[12]{o}{5cm}
        \centering
        \vspace*{-10pt}
        \includegraphics[width=0.4\textwidth]{example-image-a}
        \caption{This is a figure caption.}
    \end{wrapfigure}%
 Donec vehicula augue eu neque. Pellentesque habitant
morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus
vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor
gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra
ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus.
Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla.
Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh
mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci
sit amet orci dignissim rutrum.

Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi.
Morbi auctor lorem non justo. Nam lacus libero, pretium at, lobortis
vitae, ultricies et, tellus. Donec aliquet, tortor sed accumsan
bibendum, erat ligula aliquet magna, vitae ornare odio metus a mi. Morbi
ac orci et nisl hendrerit mollis. Suspendisse ut massa. Cras nec ante.
Pellentesque a nulla. Cum sociis natoque penatibus et magnis dis
parturient montes, nascetur ridiculus mus. Aliquam tincidunt urna. Nulla
ullamcorper vestibulum turpis. Pellentesque cursus luctus mauris.


\end{document}
9
  • David, I want "consectetuer" to come after "amet,", I use your commands, but the blank place still stays there. Even if I add \vspace. I also want previous paragraph to be left sided, so I add a blank line after "Text here" block. I use book layout, A5 Commented Jun 4, 2023 at 12:05
  • Also I changed wrapfig to wrapfig2 and \captionsetup[figure]{labelsep=period,font=small,labelfont=it} now doesn't work Commented Jun 4, 2023 at 12:11
  • @NikolayYasinskiy "I want "consectetuer" to come after "amet,"" sorry I can not guess what you mean: word order is not changed in any way. I just grabbed some text from somewhere rather than use lipsum package which is hard to use for examples where the insertion is mid text Commented Jun 4, 2023 at 12:37
  • @NikolayYasinskiy I just tested the above with \usepackage{wrapfig2,graphicx} and get identical output. Commented Jun 4, 2023 at 12:42
  • Please look at the image. I want the first line or two first lines to occupy all width of the page, but now if i add space with \vspace the image simply goes down Commented Jun 4, 2023 at 12:42
1

Like this:

enter image description here

Code:

\documentclass[10pt,a4paper]{article}

\usepackage{wrapfig2,lipsum}

\begin{document}
    \lipsum[1][1-8]
    \begin{wrapfigure}[12]{o}{5cm}
        \centering
        \vspace*{-10pt}
        \includegraphics[width=0.4\textwidth]{example-image-a}
        %\captionsetup{labelsep=period}
        \caption{This is a figure caption.}
    \end{wrapfigure}
    \lipsum[1]
\end{document}

You must log in to answer this question.

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