Perfect positioning of an image on top of text
Based on this perfect answer, using pullquote
environment, following code maybe help:
\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum,graphicx}
\usepackage[latin]{babel}
\usepackage{pullquote}
\usetikzlibrary{shapes,backgrounds,calc}
\def\mygraphic
{%
\begin{tikzpicture}
\node (0,0) {\includegraphics[width=4cm]{example-image-a}};
\end{tikzpicture}%
}
\begin{document}
\begin{pullquote}{shape=rectangular,object=\mygraphic}
\lipsum[1-4]
\end{pullquote}
\end{document}
wrapfig
isn't actually suited for this-- I came to realize-- thanks to the interesting question put up @永劫回帰 (the package documentation particularly warns: "It does work in two-column format, but are your figures that small ?" Rather the previous answer @ferahfeza seems far closer up to the mark !
But still, there are situations where one tries and tries one's own way... even to fall short of perfect success. The trial should count, I believe, at least in terms of developers. So, I'm posting this answer fully aware that it might be too clumsy to implement (at least when there's a straightforward pullquote
), but could extend the wrapfigure
environment to somewhere its developer Donald Arseneau might not have wondered when creating it sixteen years ago !
Here's my tailored solution, inspired by a ctan documentation:
\documentclass[twocolumn]{article}
\usepackage{lipsum,graphicx,wrapfig}
\begin{document}
\lipsum[1]
\begin{wrapfigure}[15]{r}[0.35\columnwidth]{5.2cm}
\includegraphics[width=5cm,height=10\baselineskip]{example-image-a}
\caption{This wrapfigure spans two-columns of text}
\end{wrapfigure}
\lipsum[3-5] % deciding the break is vital to the
% nice functioning of a 2-col wrapfigure
\begin{wrapfigure}[17]{l}[0.35\columnwidth]{5.2cm}
% this only creates free space without inserting anything
\end{wrapfigure}
\lipsum[6-7]
\end{document}
producing this output: