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.

Possible Duplicate:
remove unwanted contents from list of listings

How can I hide a listing from the listoflistings, similar to using \section*{Title} to hide a section from the table of contents?

I want to do this in order to use a listing as an example in the preface of my thesis. As this isn't really an actual listing, I don't want it to show up in my list of listings because it doesn't really concern the content.

share|improve this question

marked as duplicate by Peter Grill, Thorsten, diabonas, Marco Daniel, percusse Sep 18 '12 at 1:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
Use title=Title of this listing instead of caption=Title of this listing. Please, provide an example of what you're doing, if this is unclear or doesn't work. –  egreg Sep 17 '12 at 8:01
    
This is not a duplicate -- see egreg's answer. –  lockstep Sep 17 '12 at 11:27

1 Answer 1

up vote 4 down vote accepted

The answer in the linked question doesn't really apply here, as the nolol=true setting will still number the listing. For an unnumbered listing one can use the keyword title.

\documentclass{article}
\usepackage{listings}
\begin{document}
\title{A title}
\author{A. U. Thor}
\date{}
\maketitle

\tableofcontents
\lstlistoflistings

\section*{Introduction}
Here we have an unnumbered listing that won't go in the list of listings.

\begin{lstlisting}[title=Preliminary listing]
Hello world
\end{lstlisting}

\section{Title}

Here we have a real listing.

\begin{lstlisting}[caption=Real listing]
Hello world
\end{lstlisting}

\end{document}

enter image description here

share|improve this answer
    
Perfect! Thanks! –  Florian Peschka Sep 17 '12 at 9:59

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