0

I'm trying to make a List of Listings that appears in the Table of Contents like List of Figures. I'm using a class that was provided for me, and I tried editing it but it isn't working.

This is what the List of Figures looks like: enter image description here

But this is what the attempted List of Listings looks like: enter image description here

For some reason, it's being treated as if it is a Table of Contents.

Here is the code in the .cls file:

%
%   List of figures
%
\def\textofLoF#1{\gdef\@textofLoF{#1}}  \textofLoF{List of Figures}
\def\listoffigures{\chapter*{\@textofLoF\@mkboth{}{}}
   \thispagestyle{plain}
   \addcontentsline{toc}{chapter}{\protect\@textofLoF}
   \hbox to\textwidth{Figure Number \hfill Page}
   {\let\footnotemark\relax  % in case one is in the title
    \uwsinglespace
   \@starttoc{lof}
    }
   }
%
%   List of listings
%
\def\textofLoL#1{\gdef\@textofLoL{#1}}  \textofLoL{List of Listings}
\def\lstlistoflistings{\chapter*{\@textofLoL\@mkboth{}{}}
   \thispagestyle{plain}
   \addcontentsline{toc}{chapter}{\protect\@textofLoL}
   \hbox to\textwidth{Listing Number \hfill Page}
   {\let\footnotemark\relax  % in case one is in the title
    \uwsinglespace
   \@starttoc{lol}
    }
   }
%

I just copied the block for the List of Figures and tried changing it appropriately, but it doesn't work. I assume this is because \lstlistoflistings is in the listings package, so it's different, but I'm not sure in what way.

EDIT: here is a minimal .tex file that reproduces the problem:

\documentclass [11pt, proquest] {uwthesis}[2020/02/24]
\setcounter{tocdepth}{1}  % Print the chapter and sections to the toc

% for code listings
\usepackage{listings}

\begin{document}


% ----- contents & etc.
%
\tableofcontents
\listoffigures
\lstlistoflistings

\textpages

\begin{figure}
    \centering
    test
    \caption{Pipeline Diagram}
    \label{fig:pipeline}
\end{figure}

\begin{lstlisting}[caption=Example file snippet]
hello world
\end{lstlisting}


\end{document}
7
  • Hey Liz. Can you also generate code that would resemble a minimal example to go with your code snippets? It should generate a ToC and LoF and LoL so we can see the layout it produces by default. From there we can move to providing solutions. Your minimal example should start with \documentclass and end with \end{document}. Can you do that?
    – Werner
    Feb 1 at 22:09
  • Is this question helpful? List of listings similar to list of figures Feb 1 at 22:11
  • @barbarabeeton, I did see that question, thank you! But I wasn't sure if the solution provided was what I wanted to go with, because what I want to do is edit the .cls file I was given to account for a List of Listings, as opposed to doing it in the preamble.
    – Liz C.
    Feb 1 at 22:31
  • @Werner, I think I added what you were suggesting, but let me know if this is still not right. Thank you!
    – Liz C.
    Feb 1 at 22:33
  • Alas, there are hundreds of different document classes named thesis. Your MWE works fine for me, except that \textpages is undefined. Feb 1 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.