Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In addition to tables and figures, I have a bunch of code pieces. Just like follows:

    language=C++, breaklines=true,
    caption={Data acquisition code},

Those codes do not appear in table of figures or table of contents which is exactly what I want.

Now I want to create a new table of codes \listofcodes similar to \listoffigures. It should create a third table. How do I do that?

share|improve this question
add comment

1 Answer

up vote 10 down vote accepted

If you are using the listings package, then you have \lstlistoflistings to generate a list of listings. I see that you are enclosing your lstinputlistings in a figure environment; if the idea is to turn them into floats then you could use the float option; a little example:



%A non-floating listing:
\begin{lstlisting}[caption={Useless code one},label=uselessone]
for i:=maxint to 0 do
{ do nothing }

%A floating listing:
\begin{lstlisting}[float,caption={Useless code two},label=uselesstwo]
for i:=maxint to 0 do
{ do nothing }


EDIT: corrected the example according to Andrey Vihrov's comment.

share|improve this answer
You are a lifesaver. Thanks! –  Dan Paradox Jun 1 '11 at 4:40
This isn't the correct usage. listings has the float parameter. –  Andrey Vihrov Jun 1 '11 at 6:43
@Andrey Vihrov: thanks. I've edited my answer accordingly. –  Gonzalo Medina Jun 1 '11 at 11:32
add comment

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.