[Tex/LaTex] table with caption in letter class

captionsletterstables

Self explanatory title question: How do I get to produce a table with caption in a letter class?

A working example would be great.

Best Answer

The letter class does not define the float types of table or figure, so \captionof from caption package will fail as will \caption of course too (since there are no figure or table environments).

However, it is possible to provide a 'fake' table environment with \DeclareFloatingEnvironment from newfloat.

\documentclass{letter}

\usepackage{caption}
\usepackage{newfloat}

\DeclareFloatingEnvironment[fileext=lot]{table}

\address{Ministry of Silly Walks\\ The Embankment\\ London}
\name{Mr. Gumby}
\begin{document}

\begin{letter}{Ann Elk}
\opening{Dear Sirs, I wish to report a burglary}

\begin{center}
\begin{tabular}{lll}
  1 & 2 & 3 
\end{tabular}
\captionof{table}{My nice table}
\end{center}
\closing{And now for something completely different}
\end{letter}
\end{document}

enter image description here