Floats – Formatting List of Custom Floats in Classic Thesis

classicthesisfloatskoma-scripttable of contents

I am writing a document using classicthesis package, where I have some algorithms written with the clrscode package. I used package float to create a new float named "algorithm". However when I print the list of algorithms using \listof{algorithm}{List of algorithms} I either get a wrongly formatted list (i.e. with the long series of dots ……….., which is different from the other ones in classicthesis), or a correctly formatted one, but where algorithms are called "figure".

I trimmed down my document so that I got this minimal working example:

\documentclass[english]{scrreprt}

\usepackage{scrhack}

\usepackage{float}

\floatstyle{ruled}
\newfloat{algorithm}{thp}{loa}[chapter]
\floatname{algorithm}{Algorithm}

\usepackage[pdfspacing,floatperchapter]{classicthesis}

\begin{document}

\begingroup
    \let\clearpage\relax
    \let\cleardoublepage\relax

    \tableofcontents
    \listoffigures
    \listoftables
    \listof{algorithm}{List of algorithms}
\endgroup

\chapter{Test chapter}\label{ch:algotest}

\section{Some tests}

Algorithm \ref{alg:first} shows a plain algorithm. Figures \ref{fig:first} and \ref{fig:second} show a couple figures, and a table is shown in table \ref{tab:first}.

\begin{algorithm}
  \caption{A plain algorithm\label{alg:first}}
  \begin{verbatim}
    while not finished:
      do stuff
  \end{verbatim}
\end{algorithm}

\begin{figure}
  \caption{First figure\label{fig:first}}
  This one is a figure.
\end{figure}

\begin{figure}
  \caption{Second figure\label{fig:second}}
  This one is a figure too.
\end{figure}

\begin{table}
  \caption{Table figure\label{tab:first}}
  This one is a table.
\end{table}

\end{document}

If the line \usepackage{scrhack} is used I got the "figure" name instead of "algorithm", whereas if it is commented out I got the wrongly formatted list.

From what I found on the web it seems that scrreprt and float packages are incompatible, thus the need for scrhackpackage, but I could not find anything related to classicthesis.

Is there a way to properly format a list of custom floats?

Best Answer

Here's a hack:

\documentclass[english]{scrreprt}

\usepackage{float}

\floatstyle{ruled}
\newfloat{algorithm}{thp}{loa}[chapter]
\floatname{algorithm}{Algorithm}

\usepackage{scrhack} % load after "float"

\usepackage[pdfspacing,floatperchapter]{classicthesis}

\begin{document}

\begingroup
    \let\clearpage\relax
    \let\cleardoublepage\relax

    \tableofcontents
    \listoffigures
    \listoftables

    \renewcommand{\figurename}{Algorithm}
    \listof{algorithm}{List of algorithms}
\endgroup

\chapter{Test chapter}\label{ch:algotest}

\section{Some tests}

Algorithm \ref{alg:first} shows a plain algorithm. Figures \ref{fig:first} and \ref{fig:second} show a couple figures, and a table is shown in table \ref{tab:first}.

\begin{algorithm}
  \caption{A plain algorithm\label{alg:first}}
  \begin{verbatim}
    while not finished:
      do stuff
  \end{verbatim}
\end{algorithm}

\begin{figure}
  \caption{First figure\label{fig:first}}
  This one is a figure.
\end{figure}

\begin{figure}
  \caption{Second figure\label{fig:second}}
  This one is a figure too.
\end{figure}

\begin{table}
  \caption{Table figure\label{tab:first}}
  This one is a table.
\end{table}

\end{document}

enter image description here

Thanks to @lockstep for pointing out the correct loading order of the packages.