# Get List of Listings in an Appendix

I am using LyX with the listings package. I want to have Appendix A be titled "Code Listings" and then have the List of Listings.

Right now I have \lstlistoflistings in an ERT.

By using \renewcommand\lstlistlistingname{} in the pre-amble I was able to get the "Listings" text removed. But it still breaks to a new page. How do I keep it from doing that?

-
Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Apr 29 '12 at 6:04
This very much depends on the document class that you're using. report, book, memoir, ...? The previous assumptions suggest you're using a class that provides a \chapter. If there's no more chapters following Appendix A, then you can add \let\cleardoublepage\relax and \let\clearpage\relax in another ERT which should remove the new page. However, you would still have a complete chapter-style setting, which may not look good starting part-way on a page. – Werner Apr 29 '12 at 6:20

## migrated from stackoverflow.comApr 29 '12 at 5:58

It seems you want your "Code listings" to be a numbered (appendix) \chapter. A solution that works for the classes book, report, scrbook, scrreprt , and memoir is to define a new command (say, \lolnoheading) in the preamble that will print the contents of the List of Listings without sectioning (here: chapter) heading, and then to use this command after \appendix\chapter{Code listings}.

\documentclass{report}

\usepackage{listings}

\makeatletter
\makeatother

\begin{document}

\chapter{foo}

\begin{lstlisting}[caption={A listing}]
Some text.
\end{lstlisting}

\appendix

\chapter{Code listings}