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.

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)

share|improve this question

migrated from stackoverflow.com Aug 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
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
    
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 Aug 8 '10 at 15:13
    
Welcome to TeX.sx! Your answer 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 edit your answer. –  Werner Aug 26 '12 at 20:10
    
@grddev BTW, very good answer! Wouldn't you consider becoming more active here on TeX.SX? –  tohecz Aug 26 '12 at 21:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.