0

I'm using wrapfig like this:

\documentclass{acmart}
...
\setlength{\columnsep}{.2cm}
\setlength{\intextsep}{.0cm}
\begin{wrapfigure}{r}{0cm}
\centering
\includegraphics[width=2cm]{img}
\end{wrapfigure}
...

If it's near the end of the page, then it would overflow. The appropriate solution should be to use {R} instead of {r}. However, the result is that the figure is placed after the paragraph, alone (not wrapped in text) and on the left side.

The remedy is to use {r} and place it within the paragraph such that there are enough lines before the pagebreak. This is a tedious manual operation that needs updating every time the document is changed.

What I'd like is that it would position itself within the paragraph automatically, taking into consideration pagebreaks and such.


EDIT: The issue seems to be two wrapfig in a row. The {R} seems to simply tell it to go to the next paragraph, not taking advantage of the current paragraph at all. Since the next paragraph already has a wrapfig, the first wrapfig remains dangling.

What I would have liked: take advantage of the current paragraph--as much as possible, and if it overflows to the next paragraph, then the overflow should cascade: the second wrapfig should overflow to the next one, but nothing dangles.

A full example:

\documentclass[acmtog,anonymous,review,export]{acmart}

\usepackage{graphicx}
\usepackage{wrapfig}
%\usepackage{lipsum}
\usepackage{blindtext} % wrapfigure doesn't work well with lipsum

\begin{document}

\title{test}
\maketitle

\blindtext[6]

\blindtext[1]

\begin{wrapfigure}{R}{0cm}
\includegraphics[width=2cm, height=5cm]{example-image-a.pdf}
\end{wrapfigure}
\blindtext[1]

\begin{wrapfigure}{R}{0cm}
\includegraphics[width=2cm, height=5cm]{example-image-a.pdf}
\end{wrapfigure}
\blindtext[1]

\blindtext[1]

\blindtext[6]

\end{document}

Related: Two consecutive wrapfigure images

8
  • 2
    I'm not sure it's easily solvable using wrapfig but why do you assume a mwe isn't needed, anyone who attempts an answer will need a test document. Aug 23, 2020 at 9:10
  • 1
    You have left out the most critical information, which is how each ensuing paragraph begins. Your assumption that it just works wrong in all circumstances does not make sense. There are, unfortunately, several circumstances that break it. Aug 23, 2020 at 9:30
  • Yeah, I was kind of hoping it's a known issue. Anyway, I spent some time to construct an MWE, see edit.
    – Zohar Levi
    Aug 23, 2020 at 13:54
  • 1
    Since you already use a twocolumn fromat: Why don't you just place both images side by side and let them occupy the whole width of one of the two columns?
    – leandriis
    Aug 23, 2020 at 14:24
  • 1
    You can compute the remaining space on the page (see tex.stackexchange.com/questions/14512/… for example), then decide whether to use two wrapfigs or one. See also \newif. Aug 23, 2020 at 16:38

0

You must log in to answer this question.

Browse other questions tagged .