0

I've suceeded in creating list of listings, but the font of the /lstlistoflistings is too large. I don't have any idea how to decrease it.

2
  • Do you mean the font size of the title "List of Listings", or the font size of the list items?
    – Marijn
    Jan 12, 2022 at 20:43
  • 1
    usually for list of ... the heading is a standard document section heading and the list itself is just set at \normalsize so it should not be "too large" and would not normally have its own font settings. can you add a small example to your question that shows the problem? Jan 12, 2022 at 20:44

1 Answer 1

0

For the title a quick workaround is to include a size command in the name of the list:

\documentclass{article}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[float,caption=A listing]
This is a listing
\end{lstlisting}
\def\lstlistlistingname{\small Listings}
\lstlistoflistings
\end{document}

enter image description here


Changing the font size of the list items is more difficult. You can copy the definition of \lstlistoflistings from the package source and add a size command just before the \tableofcontents command in that definition. Also include \makeatletter and \makeatother around the redefinition because the code contains @ symbols. Here I used \footnotesize for the list items.

MWE:

\documentclass{article}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[float,caption=A listing]
This is a listing
\end{lstlisting}
\begin{lstlisting}[float,caption=Another listing]
This is a listing
\end{lstlisting}
\def\lstlistlistingname{\small Listings}
\makeatletter
\def\lstlistoflistings{%
\bgroup \let\contentsname\lstlistlistingname%
\let\lst@temp\@starttoc%
\def\@starttoc ##1{\lst@temp {lol}}%
\footnotesize% here the size command is added
\tableofcontents%
\egroup}
\makeatother
\lstlistoflistings
\end{document}

enter image description here

2
  • But when I want to change the font size of the list below the title ?
    – Konrad
    Jan 12, 2022 at 21:02
  • @Konrad see edit.
    – Marijn
    Jan 12, 2022 at 21:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .