This question came from our site for professional and enthusiast programmers.

Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question.
– WernerFeb 22 '12 at 16:39

It would be possible to re-purpose the figure environment and associated macros, but it may make the code harder to read. For example,

\begin{figure}[..]
% <contents>
\caption[..]{...}
\end{figure}

would then serve the (possibly) dual purpose of posting a listing or a figure. Additionally, what should be contained within \listoffigures?

The float package allows for the easy definition of new floats. Here's a minimal example declaring a new float listing, as well as the appropriate \listoflistings command to display a "List of Listings":