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.
MWE:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
\usepackage{lipsum}
\usepackage{floatrow}
\DeclareNewFloatType{Box}{
name=Box,
placement=htbp,
fileext=lob}
\floatsetup[Box]{
style=BOXED,
capposition=top,
justification=justified}
\newenvironment{BOX}[2][htbp]{%
\begin{Box}[#1]
\ifx\relax#2\relax\else\caption{\textbf{#2}}\fi
}{\end{Box}}
\newenvironment{BOX*}[2][htbp]{%
\begin{Box*}[#1]
\ifx\relax#2\relax\else\caption{\textbf{#2}}\fi
}{\end{Box*}}
\begin{document}
\title{Title}
\maketitle
\begin{BOX}{First box}
\begin{minipage}[t][1\totalheight][c]{0.3\columnwidth}%
\vspace{0pt}
\includegraphics[width=1\textwidth,height=0.2\textheight]{foo}%
\end{minipage}\hspace{0.03\textwidth}%
\begin{minipage}[t]{0.67\columnwidth}%
\vspace{0pt}
\lipsum[1]
\end{minipage}
\lipsum[3]
\end{BOX}
\begin{BOX}{Second box}
\begin{wrapfigure}{l}{0.4\textwidth}
\includegraphics[width=1\textwidth,height=0.2\textheight]{foo}%
\end{wrapfigure}
\lipsum[2]
\end{BOX}
\end{document}
Best Answer
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.