Properly add a List of Listings in LaTeX

Hi folks,
today I’d like to show you how to properly add a “List of Listings” using the listings package to your LaTeX document. Before we start you have to include the listings package:

Then you can (if you like to) change the title of the section. By default it is named “Listings”. Here I change it to “List of Listings”:
\renewcommand{\lstlistlistingname}{List of Listings}

These two commands were outside the begin{document}, so the following ones will be inside.

Now we have to add a listing
\begin{lstlisting}[caption={ANSI C Hello World},label={lst:c_helloworld}]
#include <stdio.h>

int main(void) {
printf("Hello World\n");
return 0;

And finally here is the code which properly adds the List of Listings (also to the ToC)
% List of Listings
\addcontentsline{toc}{section}{\lstlistlistingname} % Add it to the ToC
\lstlistoflistings % The list itself

Hope this helps šŸ˜‰


This entry was posted in LaTeX and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s