TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 16 down vote accepted

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






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

share|improve this answer

I figured this out. What I did was

\DeclareCaptionType{code}[Code Listing][List of Code Listings] 
    Some source code
\caption[This here is a caption]{caption}

This creates a table of blocks of code. Super nifty.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.