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

Zohar Levi
  • 1,237
  • 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. – David Carlisle Aug 23 '20 at 09: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. – Donald Arseneau Aug 23 '20 at 09: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 '20 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 '20 at 14:24
  • 1
    You can compute the remaining space on the page (see https://tex.stackexchange.com/questions/14512/how-to-define-a-figure-size-so-that-it-consumes-the-rest-of-a-page for example), then decide whether to use two wrapfigs or one. See also \newif. – John Kormylo Aug 23 '20 at 16:38
  • Not optimal (I still want it to use some lines from the first paragraph), but it would be an improvement. Before I start playing with it, do you perhaps have such an expression? – Zohar Levi Aug 24 '20 at 22:06
  • Actually, I have three wrapfig in three consecutive paragraphs. I think a proper solution is needed; something as good as placing a regular figure. – Zohar Levi Aug 26 '20 at 15:17
  • After much experimentation, I think the problem comes from amsart. I know that multicol formats the entire page as a single column in order to split it evenly into two columns, a feature amsart shares. In that case, floating to the next column would really mean floating to the next page. – John Kormylo Sep 02 '20 at 18:40

0 Answers0