I am using the letter class and would like to put a wrapped figure in the letter. How can this be done properly?
Attempting to insert a wrapped figure using the wrapfig package (with a caption) fails. The following is a workaround I stumbled upon but don't fully understand. I posted it as responding to a special case of this item: Letter class alternatives with support for figures, tables, and labels. It was deleted there (after some upvotes), presumably because a moderator felt it was raising a different question rather than providing a sound workaround. So I'm posting it as a separate issue. I mention the deleted post for context; readers may find related content there.
With the letter class, attempting to put a caption in a wrapfig environment with a standard \caption{} command gives an error:
! LaTeX Error: No counter 'figure' defined.
The same error appears if I use \caption*{} (evidently the counter is being used even though the count is not used in the caption). Adding a new figure counter only makes other errors appear.
I tried again, using \usepackage{caption}. This gives a different error:
! Package caption Error: No float type 'figure' defined.
This happens with both \caption{} and \caption*{}. Just as a shot in the dark, I tried adding:
\newcounter{figure}
After doing so, \caption*{} works fine, although a plain \caption{} gives an error:
! Undefined control sequence.
<write> \@writefile{\ext@figure ...
Further adding the following in the preamble:
\makeatletter
\def\ext@figure{}
\makeatother
makes the error go away, and produces correct captions, including correctly incrementing figure numbers.
I don't understand exactly what is going on "under the covers" that is making this workaround effective, but it works. I'd like to understand why it works, or a more correct solution.
Note that the regular figure environment remains unavailable.
In summary, my preamble has:
\usepackage{wrapfig}
\usepackage{caption}
% caption will raise "No float type 'figure'" w/i wrapfigure unless
% a figure counter is defined; ext@figure prevents further errors
\newcounter{figure}
\makeatletter
\def\ext@figure{}
\makeatother
Is there a better way to get a wrapped figure in a letter?