Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

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    

\newcommand\addpicture[3]{% 
\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]
\addpicture{s}{tiger.pdf}{0.2}
\lipsum[1]    
\end{exam}

\end{document} 

enter image description here

share|improve this answer
    
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
add comment

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}

share|improve this answer
    
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 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 at 23:13
add comment

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

\RequirePackage{xparse, graphicx, caption, picins}
\DeclareDocumentCommand \addpic{O{0.4\textwidth} m g}{\parpic[r]{%
\begin{minipage}{#1}
    \includegraphics[width=\textwidth]{#2}%
    \IfNoValueTF{#3}{}{\captionof{figure}{\footnotesize #3}}
\end{minipage}
}}

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.