Regarding your caption problem. I don't get any error. I would suspect that your caption.sty is too old.
I have caption.sty 2010/01/09 v3.1m Customizing captions (AR)
You need to have enough text in order to surround your images with it. When I add some dummy-text here, it works just fine.
If you do not have enough text, you can use a multicolumn
environment or you put it in a tabbing
or a simple tabular
. This will make it less flexible but fully controllable.
% arara: pdflatex
\documentclass{amsart}
\usepackage{tikz}
\usepackage{wrapfig}
\usepackage{caption}
\captionsetup{justification=raggedright,singlelinecheck=false}
\usepackage{lipsum}
\pgfmathsetmacro{\ex}{0}
\pgfmathsetmacro{\ey}{0}
\newcommand{\figureone}[1]{
\begin{tikzpicture}[#1]
\draw [fill = lightgray] (0,0) circle [radius = 1.25 cm];
\draw (0,0) -- (0.8838834765,0.8838834765);
\node [above left] at (0.5,0.5) {$r$};
\node [above left] at (-1.0,0.575) {$C$};
\draw [->] (\ex,\ey) ++(135:1.5cm) arc (135:85:1.5cm);
\draw [->] (\ex,\ey) ++(160:1.5cm) arc (160:210:1.5cm);
\end{tikzpicture}
}
\newcommand{\figuretwo}[1]{%
\begin{tikzpicture}[#1]
\draw [fill = lightgray] rectangle (2,2);
\node [right, rotate=90] at (2.35,0.4) {1 unit};
\node [below] at (1,-0.1) {1 unit};
\node [above] at (1,1) {$A = 1$};
\node [below] at (1,1) {$\textrm{unit}^2$};
\draw [<-] (0,-0.375) -- (0.35,-0.375);
\draw [->] (1.65,-0.375) -- (2,-0.375);
\draw (0,-0.15) -- (0,-0.6);
\draw (2,-0.15) -- (2,-0.6);
\draw [<-](2.375,0) -- (2.375,0.35);
\draw [->](2.375,1.65) -- (2.375,2);
\draw (2.15,0) -- (2.6,0);
\draw (2.15,2) -- (2.6,2);
\end{tikzpicture}
}
\begin{document}
\begin{wrapfigure}{l}{0.25\textwidth}
\figureone{}
\caption{Caption}
\end{wrapfigure}
\noindent
Filler text: here is some filler text. In my document this is 7 lines long, including one displayed equation. The first figure should be positioned directly to the right of this text.
\section*{Section 1}
\begin{wrapfigure}{l}{0.25\textwidth}
\figuretwo{}
\caption{Caption}
\end{wrapfigure}
\lipsum[1-3]
\section*{Section 2}
\lipsum[2-3]
\end{document}
Best Answer
After the comments to the original question it is clear that the problem was caused by a page break. Pagebreaks (even non explicit ones) can be problematic if they occur in the place where the wrapfigure is supposed to appear. The
wrapfig
package documenatation mentions this explicitly:Moving the
wrapfigure
environment to another location fixes the problem.As a side note, instead of using the
center
environment it could be better to use the\centering
command; also, perhaps you might want to reconsider the use of the\vspace
commands.