1

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?

  • Heiko Oberdiek offered the following explanatory comment to the deleted post before it was deleted: \ext@figure usually expands to lof that is used by \addcontentsline to write the entry for the list of figures. If a list of figures is not needed, then the workaround looks fine. If \ext@figure expands to something that is not known, then the write order will be ignored. However, \ext@figure must be expandable in order to survive a \csname construct. Thus \def\ext@figure{} works and \let\ext@figure\relax does not. – – Tom Loredo May 17 '14 at 02:28
  • If you have a letter with a single? image in it why does it need a numbered caption?, you can just include the image and put a paragraph of text under it. – David Carlisle May 17 '14 at 11:39
  • In fact the letter in question only needed a single figure and I didn't need the numbered caption. I included information about experimenting with numbered captions here in case others might seek that capability. – Tom Loredo May 18 '14 at 06:06

0 Answers0