views:

51

answers:

1

How can I use \lstlistoflistings to create a list of listings, but not have this list as an entry in the table of content?

Normally, a star helps to hide things like that and I use memoir as document class which supports and helps hiding lists like \tableofcontents*, \listoffigures*, \listoftables*, ... But adding the star like that: \lstlistoflistings* does not help.

I don't want to patch any of the class file or other packages if not really needed. (I use tex seldom enough to get annoyed if I want to have the listings list in the toc and then can't remember anymore what I changed).

At the moment I use latexmk to typeset my files. And so I currently have a .latexmkrc file with a hook that delete this entry from the content before it gets added to the toc, like this:

add_cus_dep("toc", "toc", 0, "removelistingfromtoc");
sub removelistingfromtoc {
  $origin = "$_[0].toc";
  $dest = "$_[0].toc.unpatched";
  system("mv '$origin' '$dest' && grep -v '\\contentsline.*{List of Listings}' ".
         "'$dest' > '$origin'");
  return 0;
}

This removes for example the following line from the toc file:

\contentsline {chapter}{List of Listings}{}{section*.3}

(I changed the name "Listing" to "List of Listings". Btw: Any author with english as their native language might help me to critic if this "List of Listings" is a proper and common term)

A: 

In the memoir class, the lists seem to be defined in terms of \newlistof, and since the listings package implements \lstlistoflistings by retrofitting \tableofcontents, it should be possible to redefine it the memoir way:

\newlistof{lstlistoflistings}{lol}{\lstlistlistingname}

And then simply add the * as you said. Note that I haven't tried this myself.

grddev
@grddev Thanks a lot! Your tip did the job. The Listing is not anymore included in the TOC and I can latexmkrc hack. Here a snippet of what's left now: : \renewcommand*{\lstlistlistingname}{List of Listings} \newlistof{lstlistoflistings}{lol}{\lstlistlistingname} : \begin{document} \lstlistoflistings* :
Kreisquadratur