1

This post suggests that scrhack is required to format a list if listings consistently: How to have the list of code listings also in twocolumn? I would like to format my List of Listings consistently with my LoF and LoT by means of the KOMA-Script \DeclareTOCStyleEntries but I do not know what to use in between the ??. I've tried listing, listings, lstlisting, listlistings

\DeclareTOCStyleEntries[%
indent=-5ex,
numwidth=5ex,
entryformat=\normalsize,
entrynumberformat=...
]{tocline}{figure,table,??listing??}

Error:(81) tocbasic: toc style `tocline' needs toc style level.

1 Answer 1

1

Entry level name lstlisting does work. But because the level of entries of package listings has not been defined before, you have to set it. To give all three entries the same level, you can just use level:=figure or level:=table. This uses the level either of figure or table, which are already known:

\documentclass{scrartcl}
\usepackage{scrhack}
\usepackage{listings}
\DeclareTOCStyleEntries[%
  level:=figure,
  indent=-.5ex,% negative?
  numwidth=5ex,%
  entrynumberformat=\textbf,% Should be a command with exactly one argument.
]{tocline}{figure,table,lstlisting}
\begin{document}
\listoffigures
\listoftables
\lstlistoflistings
\section{Test}
\captionof{figure}{Example figure}
\captionof{table}{Example table}
\begin{lstlisting}[caption=Example listing]
Test
\end{lstlisting}
\end{document}

See the documentation of \DeclareTOCStyleEntry in the KOMA-Script manuals from version 3.37 (or newer) for more information about key:=value. Note, that there must not be any space between key and : (but spaces between : and = seem to be ignored).

4
  • 1
    BTW: After I've reported this to the KOMA-Script author, he has added new default for listings. So from next release option level:=figure will not be needed any longer in this example. However using scrhack will still be recommended.
    – cabohah
    Oct 24, 2022 at 8:14
  • Easy peasy--thanks for pointing out some other issues as well. Oct 25, 2022 at 1:35
  • What exactly is the meaning of :=? Kind of like 'inherit'? Oct 25, 2022 at 1:59
  • @likethevegetable From KOMA-Script manual, documentation of \DeclareTOCStyleEntry: ”In addition to the usual assignment with key=value, both commands understand an assignment in the form key:=entry level for all options of the KOMA-Script styles. In this case, the current setting of key for the entry level will be copied. For example, you can copy the current indent of the figure level using indent:=figure.” Note: There are also + options. See the manual for more information.
    – cabohah
    Oct 25, 2022 at 7:01

You must log in to answer this question.

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