This question is in regards to customizing the format of the list of listings produced with the minted package. In particular, I want to replicate the formatting produced via the tocloft for Figures:
Despite being related to the following two questions:
(1) Formatting \listoftables and \listofalgorithms;
(2) Customizing the list of listings generated by \lstlistoflistings?,
I have been unable to replicate the formatting of the list of figures for list of listings from minted. This question differs from these two examples in that minted uses the float package to create the list of listings, whereas the above two questions address the algorithm and listing packages, respectively.
An attempt to produce a similar result follows.
\documentclass{report}
\usepackage{minted}
\usepackage[titles]{tocloft}
\makeatletter
\begingroup
\let\newcounter\@gobble
\let\setcounter\@gobbletwo
\globaldefs\@ne
\let\c@loadepth\@ne
\newlistof{listings}{lol}{\listoflistingscaption}
\endgroup
\let\l@listings\l@listing
\makeatother
\renewcommand{\cftfigpresnum}{Figure }
\cftsetindents{fig}{0em}{5em}
\renewcommand{\listoflistingscaption}{List of Listings}
\renewcommand{\cftlistingspresnum}{Listing }
\cftsetindents{listings}{0em}{5em}
\begin{document}
\listoffigures
\listoflistings
\clearpage
A minted environment:
\begin{listing}
\begin{minted}{java}
// Java class
\end{minted}
\caption{A Java Class.}
\end{listing}
A Figure:
\begin{figure}[h]
\centering
\rule{1cm}{1cm} \caption{A Figure}
\end{figure}
\end{document}
This approach yields the unsatisfactory list:
Any suggestions would be greatly appreciated.
Best Answer
I think you are better off if you load
minted.sty
with optionnewfloat
and use the interface totocloft.sty
as described innewfloat.pdf
. Code: