3

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}

output

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.

3

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

warning, with incorrect hyperlinks.

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}

enter image description here

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}

\addto\captionsngerman{%
  \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}

enter image description here

4
  • 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
  • I chose "Quellcodeverzeichnis" as title, while the designator in front of every item stays as "Listing". I've used the english word "Listing" throughout my thesis for referencing source code samples ... I believe that's kind of standard in (german) technical literature. The commands are \renewcommand{\listlistingname}{Quellcodeverzeichnis} and \renewcommand{\listingname}{Listing}. – Stefan Braun Jan 16 '16 at 22:45
0

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~}}

Source: http://mirrors.ctan.org/macros/latex/contrib/caption/newfloat.pdf, page 5

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.