4

I wish to accomplish something like:

enter image description here

Where 1 and 2 are images. 1 is aligned to the left and 2 is aligned to the right. All text between those should be as illustrated with lines in the image.

My current code is:

\clearpage
\newpage

\begin{wrapfigure}{L}{0.5\textwidth}
\includegraphics[width=1\textwidth]{image1.png}
\caption{Image 1}
\end{wrapfigure}

Really long text to be on the right of image 1...

\begin{wrapfigure}{R}{0.40\textwidth}
\includegraphics[width=1\textwidth]{image2.png}
\caption{Image 2}
\end{wrapfigure}

Really long text to be on the left of image 2...

However, my code results in Image 1 being on the left (as it should be) with the text which belongs to it on its right (as it should be) and the text which should be on the left of Image 2 immediately after the text of Image 1 (why?). And Image 2 is on a new page and still on the left. Here is what it looks like:

enter image description here

1
  • 1
    Are you open to use other packages or tricks to achieve what you want? Or you want to stick to wrapfigure environment?
    – Niranjan
    Feb 1, 2020 at 6:15

3 Answers 3

3

Will this serve the purpose?

\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{multicol,caption}
\newenvironment{Figure}
{\par\medskip\noindent\minipage{\linewidth}}
{\endminipage\par\medskip}

\begin{document}
    \begin{multicols}{2}
        \begin{Figure}
            \begin{tikzpicture}
            \draw (1,1) circle (3cm);
            \end{tikzpicture}
            \captionof{figure}{text}
        \end{Figure}
        \lipsum[2]
    \end{multicols}
    \begin{multicols}{2}
        \lipsum[2]
        \begin{Figure}
            \begin{tikzpicture}
            \draw (1,1) circle (3cm);
            \end{tikzpicture}
            \captionof{figure}{text}
        \end{Figure}
    \end{multicols}
\end{document}

1

I have not used wrapfigure here, but multicols can also serve something similar. I agree that this is not a good solution for you if you want to continue using wrapfigure environment.

1
  • Thank you. This worked out great.
    – IamOptimus
    Feb 1, 2020 at 10:35
4

Another solution, using the insbox plain TeX macro package: it defines \InsertBoxL and InsertBoxR commands with two mandatory arguments: the number of lines unshortened in the following paragraph, before the insertion of the box, and the content of the box, and a last optional argument, the number of supplementary shortened lines, in case TeX has erroneously calculated the height of the inserted box. Of course, the inserted objects are no more floating, so you have to use \captionof{figure}{some caption}.

\documentclass{article}
\usepackage[latin]{babel} 
\usepackage{lipsum}
\usepackage{graphicx,caption} 
\input{insbox}
\makeatletter
\@InsertBoxMargin=3mm
\makeatother

\begin{document}

\InsertBoxL{0}{%
\parbox{0.5\textwidth}{
\includegraphics[width=0.45\textwidth ]{AliceSteadman}
\captionof{figure}{Ralph Steadman’s cover for Alice in Wonderland}
}}[10]
\lipsum[1]

{\InsertBoxR{6}{%
\parbox{0.4\textwidth}{
\includegraphics[width=0.4\textwidth ]{traccia-table}
\captionof{figure}{Meret Oppenheim Table with bird legs (1972)}
}}[7]
\lipsum[1-2]}
\lipsum

\end{document} 

enter image description here

4

You can do it with wrapfig, so long as you make sure the first wrapfig is done before starting another. \wrapfill adds blank lines (actually, paragraphs) until this point is reached.

Note, always use \parskip=0pt with wrapfig.

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

\newcommand{\wrapfill}{\par\ifnum\value{WF@wrappedlines}>0
  \addtocounter{WF@wrappedlines}{-1}%
  \null\vspace{\arabic{WF@wrappedlines}\baselineskip}%
  \WFclear
\fi}

\begin{document}

\begin{wrapfigure}{L}{0.5\textwidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{Image 1}
\end{wrapfigure}

Really long text to be on the right of image 1...
\arabic{WF@wrappedlines}
\wrapfill

\begin{wrapfigure}{R}{0.40\textwidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{Image 2}
\end{wrapfigure}

Really long text to be on the left of image 2...
\wrapfill

At this point the bottom wrapfigure is done.

\end{document}

demo

2
  • This is absolutely perfect, and fixed an issue I had with text still being wrapped on the next page despite the wrapfig ending sooner. I wonder why this isn't a standard feature of the package? The documentation doesn't really go over this.
    – mid_kid
    Jul 12, 2021 at 15:16
  • BTW, I now recommend using paracol instead of wrapfig (see tex.stackexchange.com/questions/509450/…) Jul 12, 2021 at 15:36

You must log in to answer this question.

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