# “Figure” as name of listings in listoflistings with minted and newfloat

The following MWE gives me a List of Listings with "Figure" as name of listings.

\documentclass{scrreprt}
\usepackage{classicthesis}
\usepackage[newfloat]{minted}

\begin{document}
\listoflistings
\begin{listing}
\begin{minted}{sql}
Test
\end{minted}
\caption{My Listing}
\end{listing}
\end{document}


If I remove the newfloat option from minted, the "Figure"-String disappears. However, the desired behaviour would be to include something like "Listing" in front of every entry.

You should load minted before classicthesis, otherwise you get a

pdfTeX warning (ext4): destination with the same identifier
(name{figure.0.1}) has been already used, duplicate ignored


Then you can make \l@listing the same as \l@figure, which is what newfloat does anyway, but after classicthesis has modified the standard meaning of \l@figure. You can use a hook, usually empty, for locally changing \figurename to “Listing” and, possibly, for changing some of the indentation parameters.

\documentclass{scrreprt}

\usepackage[newfloat]{minted}
\usepackage{classicthesis}

\makeatletter
\let\l@listing\l@figure
\def\newfloat@listoflisting@hook{\let\figurename\listingname}
\makeatother

\begin{document}

\listoflistings

\begin{listing}
\begin{minted}{sql}
Test
\end{minted}
\caption{My Listing}
\end{listing}
\end{document}


With babel it seems that some timing problems arise. Here's a different workaround, including the change to the labels.

\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage[newfloat]{minted}
\usepackage{classicthesis}
\usepackage{etoolbox}

\renewcommand{\listlistingname}{Quellcodeverzeichnis}%
\renewcommand{\listingname}{Listing}%
}

\makeatletter
\let\l@listing\l@figure
\patchcmd{\l@listing}{\cftfigpresnum}{\cftlistingpresnum}{}{}
\newcommand\cftlistingpresnum{\listingname~}
\makeatother

\begin{document}

\listoflistings

\begin{listing}
\begin{minted}{sql}
Test
\end{minted}
\caption{My Listing}
\end{listing}
\end{document}


• Unfortunately, this stops working after including \usepackage[ngerman]{babel}. Loading babel with the ngerman option changes the string back to the german word for figure ("Abbildung"). – Stefan Braun Jan 16 '16 at 21:52
• @StefanBraun Fixed – egreg Jan 16 '16 at 22:26
• @StefanBraun Would you provide the words in place of ???? – egreg Jan 16 '16 at 22:33

minted loads the newfloat-Package if the identical option is applied. newfloat uses the \listoffigure command for new lists. Looks like this is a bit buggy - but I'm not sure who to blame: me, newfloat, minted or classicthesis.

In order to fix the list of listings I had to overwrite the \cftfigpresnum command.

\PrepareListOf{listing}{\renewcommand{\cftfigpresnum}{Listing~}}