Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer
    
That's a good workaround, but it would not allow to use "Algorithm" as autoref for instance. I tried a more complete solution be defining a new list using tocloft (similar to what classicthesis does with listings), but I could not get the "Algorithm" label to show properly in the list. So something like \newlistof{algorithms}{loa}{\lstlistalgorithmname}...\renewcommand{\cftlistings‌​presnum}{\lstalgorithmname~} does not work because the command lstalgorithmname is not processed. –  Jörg Nov 7 '12 at 13:59
3  
@Jörg Just do \newcommand{\algorithmautorefname}{Algorithm} after loading classicthesis –  egreg Nov 7 '12 at 14:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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