[Tex/LaTex] Table of code listings

listingstable of contents

I'm using the listings package to put a box around some source code in a document and also to provide some syntax hilighting. Is there an easy way that I could create a table of contents which just listed the code listings? I have already used the figure listing for actual figures and I would rather not mix figures and code listings. Is there perhaps a way I could build two distinct figures collections?

Best Answer

One could use the \lstlistoflistings macro that is part of the listings package.

\documentclass{article}

\usepackage{listings}

\begin{document}

\lstlistoflistings

\section{foo}

\begin{lstlisting}[caption={A listing}]
    Some source code
\end{lstlisting}

\end{document}