Is there a way to exclude a specific listing from being printed in the LoL? I put one in a figure environment for the sake of not being printed on two seperate pages. But now I have the figure as well as the listing in the toc
\documentclass{article}
\usepackage{tikz}
\usepackage{listings}
\begin{document}
\lstlistoflistings
\listoffigures
\begin{figure}
\begin{lstlisting}[caption=Listing]
\end{lstlisting}
\caption{Figure}
\end{figure}
\end{document}
Update:
I used this to have a special listing caption for all real listings.
\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{%
\parbox{\textwidth}{\colorbox{gray}{\parbox{\textwidth}{\bf\sffamily\smaller#1#2#3}}\vskip-1pt}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}
\caption? And why do you use figure to avoid a page break. Maybe a minipage is better for your situation. – knut Jan 03 '13 at 22:57\caption{Figure}. Otherwise: http://tex.stackexchange.com/questions/43995/ignore-figure-for-list-of-figures – Torbjørn T. Jan 03 '13 at 23:27\begin{lstlisting}[caption=Listing]– Torbjørn T. Jan 03 '13 at 23:32[caption=Listing]option, you don't obtain an entry in the LoL (and that's not a joke)... – Werner Jan 03 '13 at 23:36[caption=Listing]goes into the List of Listings (LoL), and\caption{Figure}goes into the List of Figures (LoF). In your MWE you do not even have a\tableofcontents, nevertheless you have an entry in the Table of Contents (“ToC”)? Remove[caption=Listing]to get rid of the LoL entry, remove\caption{Figure}or use\caption[]{Figure}to remove the LoF entry. And by the way, your MWE misses\usepackage{caption}and at least a definition of\smaller(but that’s not the point). – Qrrbrbirlbel Jan 03 '13 at 23:40nolol:\begin{lstlisting}[caption=Listing,nolol]. Or:\begin{lstlisting}[caption={[]Listing}]which hides the Listing number and doesn’t produce a LoL entry. – Qrrbrbirlbel Jan 03 '13 at 23:46nololworked for me. It was strange, because before there was actually no caption printed, but I got a.in the LoL. Thanks again! – Matthias Jan 03 '13 at 23:55