I'm trying to put a small figure in a floating box; the picture itself doesn't need to float, it should only float with the box. I've been doing some adjusting of minipages, but that requires some trial and error. I've been thinking that the wrapfig package would be able to do this, but it seems to interfere strangly with the floatrow package that I use to make the boxes.








\begin{BOX}{First box}



\begin{BOX}{Second box}



enter image description here enter image description here

1 Answer 1


Here is a poor man's wrapfig using \hangindent. The image is drawn in vmode before the indentation starts. Adding \leavevmode will cause it to be indented as well.

Note: \hangindent is quite versatile. As you can see, a negative value for \hangafter changes it from hanging indentation to regular indentation. A negative value for \hangindent cause the right margin to be hung/indented.



\fbox{\begin{minipage}{\dimexpr \textwidth-2\fboxsep-2\fboxrule}
\caption{Floating Box}%
\sbox0{\includegraphics[scale=0.25]{example-image}}% get height and width
\hangafter \numexpr -\ht0/\baselineskip -2\relax% adds two blank lines at bottom
\hangindent \dimexpr \wd0 + 1em\relax% adds 1em margin on right
\vbox{\raisebox{-\height}[0pt][0pt]{\box0}}\vspace{-1ex}% overlap image


floating box

  • Great answer! I have to add, though, that this doesn't work if the text that needs to be wrapped contains multiple paragraphs, but I can live with that. Is there a way to increase the space at the bottom ? When the text that needs to be wrapped is \small, the vbox seems too small and the text goes back to the left margin too early.
    – Jos
    Dec 4, 2015 at 9:36
  • You need to switch to \small before all the calculations are done, like right after begin{figure} or \begin{minipage}. If/when you make this a macro/environment, you could make the number of lines indented an optional parameter. Dec 4, 2015 at 16:29

You must log in to answer this question.

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