# How to wrap around a figure in a theorem-like environment?

I want to illustrate my examples, which are set in a theorem-like environment. Is it possible to wrap the text and equations around the figures? I have read about several packages but I can't get them to work in a theorem. Am I doing something wrong?

-

I don't know the cutwin package but it's possible to use it with the picins. This package is not actually in TeXLive (we can find it now here).

I use windowpagestuff from the cutwin package to stock the picture with the caption, then I get the width of the picture. It's not sure that all of this stuff is robust but it's interesting to try ...

\documentclass{scrartcl}
\usepackage[]{graphicx}
\usepackage{lipsum}
\usepackage{amsthm}
\usepackage{caption}
\usepackage{picins}
\usepackage{microtype}
\usepackage{cutwin}
\newtheorem{exam}{Example}
\newbox\mybox
\newdimen\myboxwidth

\setbox\mybox=\hbox{\includegraphics[scale=#3]{#2}}
\myboxwidth\wd\mybox
\renewcommand\windowpagestuff{%
\includegraphics[scale=#3]{#2}
\captionof{figure}{A test figure.}}
\parpic[#1]{%
\begin{minipage}{\myboxwidth}
\windowpagestuff
\end{minipage}
} }
\begin{document}

\begin{exam}
\lipsum[1]
\lipsum[1]
\end{exam}

\end{document}


-
And with this approach you can use displayed math environments (equation, align, etc.); at least that's why my tests suggest. –  Gonzalo Medina Apr 3 '11 at 16:10

The wrapfig package won't behave well with theorem-like structures created with amsthm or ntheorem. The cutwin package can be used with those theorem-like structures (see my example below) as long as only text is involved. However, none of those packages interacts well with displayed math.

A little example of the text of a theorem-like structure wrapped around a figure with caption, using the cutwin package:

\documentclass{article}
\usepackage{cutwin}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage{amsthm}
\usepackage{caption}

\captionsetup{singlelinecheck=no}
\newtheorem{exam}{Example}

\begin{document}
\renewcommand\windowpagestuff{%
\includegraphics[height=4cm, width=5cm]{figure}
\captionof{figure}{A test figure.}
}
\opencutleft
\begin{exam}
\begin{cutout}{2}{0pt}{0.5\linewidth}{13}
\lipsum[1]
\end{cutout}
\end{exam}
\lipsum[1]

\end{document}


-
This doesn't work at all in many environments that I use. For example in the springer lncs example environment this glitches and overwrites paragraphs on top of others. –  Arlen Cox Feb 22 '14 at 18:30
@ArlenCox well, and what did you expect? Classes which are not the standard ones redefine a lot of things. Feel free to open a new question with that class or contact the author/maintainer of the class and ask for a solution there. –  Gonzalo Medina Feb 22 '14 at 23:13

I tweaked @Altermundus' solution, which does indeed work inside theorems with maths:

\RequirePackage{xparse, graphicx, caption, picins}

Now I can call addpic using addpic{filename}, addpic[width]{filename}, addpic{filename}{caption}, or addpic[width]{filename}{caption}.