# How to remove entry “Listings” from table of content (toc)

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)

-

## migrated from stackoverflow.comAug 26 '12 at 18:33

This question came from our site for professional and enthusiast programmers.

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 Aug 26 '12 at 20:09

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.