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