1

I'm attempting to generate a list of listings for my dissertation. The university doesn't have a standard LaTeX template, but there is a pretty good one generated sometime ago that does the trick. The only problem is that it did not include a List of Listings function, so I went ahead and modified the definition for the List of Figures (shown below) to define a new List of Listings.

% LIST OF TABLES
%
% Single-space list of tables, add it to the table of contents.
\def\listoftables{%
  \@restonecolfalse%
  \if@twocolumn\@restonecoltrue\onecolumn\fi%
  \newpage%
  \centerline{\expandafter\uppercase\expandafter{\listtablename}}%
  \bigskip%
  \phantomsection%
  \addcontentsline{toc}{frontmatter}{\protect\numberline{}\listtablename }%
  % This group overloads \numberline to output ``Table 1.3'' instead of ``1.3''
  \begingroup%
    \let\ORIG@numberline\numberline%
    \renewcommand*{\numberline}[1]{\ORIG@numberline{\tablename~##1:}}%
    {\ssp\@starttoc{lot}}%
    \if@restonecol\twocolumn\fi%
  \endgroup %
  }

\newlength{\@tablelength}
\settowidth{\@tablelength}{\tablename }
% Magic value, but consistent with the standard table length.
\addtolength{\@tablelength}{2.8em}
\def\l@table{\normalfont\@dottedtocline{1}{0em}{\@tablelength}}

This is what I came up with ...

% LIST OF LISTINGS
%
% Single-space list of listings, add it to the table of contents.

\def\listoflistings{%
  \@restonecolfalse%
  \if@twocolumn\@restonecoltrue\onecolumn\fi%
  \newpage%
  \centerline{\expandafter\uppercase\expandafter{\listlistingname}}%
  \bigskip%
  \phantomsection%
  \addcontentsline{toc}{frontmatter}{\protect\numberline{}\listlistingname }%
  %This group overloads \numberline to output ``Source Code 1.3'' instead of ``1.3''
  \begingroup%
    \let\ORIG@numberline\numberline%
    \renewcommand*{\numberline}[1]{\ORIG@numberline{\listingname~##1:}}%
    {\ssp\@starttoc{lol}}%
    \if@restonecol\twocolumn\fi%
  \endgroup %
  }

\newlength{\@listinglength}
\settowidth{\@listinglength}{\listingname }
% Magic value, but consistent with the standard listing length
\addtolength{\@listinglength}{2.8em}
\def\l@listing{\normalfont\@dottedtocline{1}{0em}{\@listinglength}}

The only problem is that the text \listingname (Source Code) and the short caption for the listing are overlapping (see below), when they shouldn't be (see example of List of Figures below).

enter image description here

enter image description here

I believe I have identified that the problem stems from how the .lot and .lol files are being generated, namely the .lol file is missing the keyword \ignorespaces.

.lot FILE

\boolfalse {citerequest}\boolfalse {citetracker}\boolfalse {pagetracker}\boolfalse {backtracker}\relax 
\defcounter {refsection}{0}\relax 
\addvspace {10\p@ }
\defcounter {refsection}{0}\relax 
\addvspace {10\p@ }
\defcounter {refsection}{0}\relax 
\contentsline {table}{\numberline {2.S1}{\ignorespaces Pedigree 1 Candidate Variants}}{33}{table.2.1}
\defcounter {refsection}{0}\relax 
\contentsline {table}{\numberline {2.S2}{\ignorespaces Pedigree 2 Candidate Variants}}{33}{table.2.2}
\defcounter {refsection}{0}\relax 
\addvspace {10\p@ }
\defcounter {refsection}{0}\relax 
\contentsline {table}{\numberline {3.1}{\ignorespaces Variants identified.}}{43}{table.3.1}
\defcounter {refsection}{0}\relax 
\contentsline {table}{\numberline {3.S1}{\ignorespaces Capture and Variant Calling Statistics.}}{44}{table.3.1}
\defcounter {refsection}{0}\relax 
\contentsline {table}{\numberline {3.S2}{\ignorespaces Variant Filtering Statistics.}}{44}{table.3.2}
\defcounter {refsection}{0}\relax 
\contentsline {table}{\numberline {3.S3}{\ignorespaces Primers.}}{45}{table.3.3}
\defcounter {refsection}{0}\relax 
\contentsline {table}{\numberline {3.S4}{\ignorespaces Candidate variants.}}{46}{table.3.4}
\defcounter {refsection}{0}\relax 
\contentsline {table}{\numberline {3.S5}{\ignorespaces Novel SNVs identified at a high rate in the Pakistani population.}}{47}{table.3.5}
\defcounter {refsection}{0}\relax 
\addvspace {10\p@ }
\defcounter {refsection}{0}\relax 
\contentsline {table}{\numberline {4.1}{\ignorespaces Dual index y-adaptors}}{64}{table.4.1}
\defcounter {refsection}{0}\relax 
\contentsline {table}{\numberline {4.S1}{\ignorespaces SNVs used for homozygosity mapping}}{74}{table.4.1}
\defcounter {refsection}{0}\relax 
\addvspace {10\p@ }
\defcounter {refsection}{0}\relax 
\contentsline {table}{\numberline {A.1}{\ignorespaces Example Read Depth Functions.}}{145}{table.A.1}
\defcounter {refsection}{0}\relax 
\addvspace {10\p@ }

.lol FILE

\defcounter {refsection}{0}\relax 
\contentsline {lstlisting}{\numberline {B.1}annotateVariants.cpp}{157}{lstlisting.B.1}
\defcounter {refsection}{0}\relax 
\contentsline {lstlisting}{\numberline {B.2}macPC.h}{200}{lstlisting.B.2}
\defcounter {refsection}{0}\relax 
\contentsline {lstlisting}{\numberline {B.3}patterns.h}{200}{lstlisting.B.3}
\defcounter {refsection}{0}\relax 
\contentsline {lstlisting}{\numberline {B.4}patterns.cpp}{200}{lstlisting.B.4}
\defcounter {refsection}{0}\relax 
\contentsline {lstlisting}{\numberline {B.5}genomeCDNAProtein.h}{207}{lstlisting.B.5}
\defcounter {refsection}{0}\relax 
\contentsline {lstlisting}{\numberline {B.6}genomeCDNAProtein.cpp}{208}{lstlisting.B.6}

closed as unclear what you're asking by user31729, Mensch, user11232, Axel Sommerfeldt, Paul Gaborit Oct 18 '15 at 10:05

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Why don't you use listings package or at least tocloft for easy generation of such list of something stuff? – user31729 Apr 13 '15 at 12:34
  • I am using the listings package, however; for uniformity with the List of Figures and List of Tables in the dissertation I've tried to adapt their commands to my needs. – user1757698 Apr 13 '15 at 13:22
  • Are there any news here? Maybe @christian has an idea? – Johannes_B Oct 17 '15 at 9:19
  • @Johannes_B: I'l look later on, now shopping for the weeking ;-) – user31729 Oct 17 '15 at 9:30