Banner

Donate

You find LaTeX Community useful? Please donate! Learn why!

Amount:

Partner Sites

goLaTeX
TeXblog
TeXnicCenter

Who is online

In total there are 9 users online :: 0 registered, 0 hidden and 9 guests (based on users active over the past 5 minutes)
Most users ever online was 108 on Tue Jun 08, 2010 3:33 pm

Users browsing this forum: No registered users and 9 guests

Custom List of Listings (listings package) possible?

Information and discussion about specific document classes and how to create your own document classes.

Custom List of Listings (listings package) possible?

Postby l0calh05t on Fri Jul 04, 2008 2:02 pm

I have all my Listings in an Appendix, and I want to add a list of listings at the beginning of that appendix. Obviously this means it should not be section level (rather subsection or no title at all), nor should it appear in the toc. By default (or at least in combination with the other packages I use), it appears in the toc and is considered an unnumbered section. Is there any way to change this?

Here's the list of packages I use:
Code: Select all
\documentclass[fontsize=11pt,paper=a4,titlepage,liststotoc,bibtotoc,twoside,BCOR=10mm]{scrartcl}

\usepackage[utopia]{mathdesign}
\usepackage[no-math]{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{ngerman}
\usepackage{amsmath}
\usepackage{array}
\usepackage{color}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{pdfpages}
\usepackage{ragged2e}
\usepackage{hyperref} % must be last package, except for cite packages
\usepackage{cite}
\usepackage{bibgerm}
l0calh05t
 
Posts: 18
Joined: Fri Jul 04, 2008 1:57 pm

Re: Custom List of Listings (listings package) possible?

Postby Stefan_K on Fri Jul 04, 2008 3:15 pm

Hi,

here's a quick workaround, you could place this where you called \lstlistoflistings:
Code: Select all
\newcommand\stdsection{}
\newcommand\stdaddtocontents{}
\let\stdsection\section
\let\stdaddtocontents\addtocontents
\def\section*#1{}
\renewcommand\addtocontents[3]{}
\lstlistoflistings
\let\section\stdsection
\let\addtocontents\stdaddtocontents

I just disabled \section* and \addtocontents temporarily.

Stefan
LaTeX Community Moderator
TeXblog.net
Stefan_K
Site Moderator
 
Posts: 2687
Joined: Mon Mar 10, 2008 8:44 pm
Location: Hamburg, Germany

Re: Custom List of Listings (listings package) possible?

Postby l0calh05t on Fri Jul 04, 2008 3:29 pm

That almost worked, but it still gets added to the hyperref pdf bookmarks.
l0calh05t
 
Posts: 18
Joined: Fri Jul 04, 2008 1:57 pm

Re: Custom List of Listings (listings package) possible?

Postby Stefan_K on Fri Jul 04, 2008 4:44 pm

If you want to avoid this bookmark you could disable \addcontentsline too. It should be enough to do this instead of disabling \addtocontents, the workaround changes to:
Code: Select all
\newcommand\stdsection{}
\newcommand\stdaddcontentsline{}
\let\stdsection\section
\let\stdaddcontentsline\addcontentsline
\def\section*#1{}
\renewcommand\addcontentsline[3]{}
\lstlistoflistings
\let\section\stdsection
\let\addcontentsline\stdaddcontentsline

Stefan
LaTeX Community Moderator
TeXblog.net
Stefan_K
Site Moderator
 
Posts: 2687
Joined: Mon Mar 10, 2008 8:44 pm
Location: Hamburg, Germany

Re: Custom List of Listings (listings package) possible?

Postby l0calh05t on Fri Jul 04, 2008 4:55 pm

Many thanks, it works as desired now.

I changed it to
Code: Select all
\newcommand\stdsection{}
\newcommand\stdaddcontentsline{}
\let\stdsection\section
\let\stdaddcontentsline\addcontentsline
\let\section\subsection
\renewcommand\addcontentsline[3]{}
\lstlistoflistings
\let\section\stdsection
\let\addcontentsline\stdaddcontentsline

to get a subsection style heading though.
l0calh05t
 
Posts: 18
Joined: Fri Jul 04, 2008 1:57 pm


Return to Document Classes

Who is online

Users browsing this forum: No registered users and 9 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group