3

I am using the classicthesis theme and I am trying to make my list of algorithms the same format as my lists of tables and figures. I am using the algorithm2e package. Here is how it looks at the moment.

enter image description here

I have tried the answers to this question but they do not work, presumably because they use the algorithm package instead. Using the accepted answer, the list of algorithms takes the name of the list of figures, but doesn't list anything: enter image description here

The other answer just doesn't change anything at all.

Since the classicthesis template is massive, I am not sure how to provide a minimal working example... The following code reproduces the issue, with the original classicthesis.sty file from the classicthesis template.

\documentclass{scrreprt}

\usepackage{classicthesis}
\usepackage{algorithm2e}

\begin{document}

\listoftables
\listofalgorithms

\newpage

Here is Algorithm \ref{alg:some_alg}.

\begin{algorithm}
    \For{something}{
        something else
    }
    \caption{Some algorithm.}\label{alg:some_alg}
\end{algorithm}

Here is Table \ref{tab:some_table}.

\begin{table}
    \centering
    \begin{tabular}{cc}
    some line & some content \\
    some other line & some other content \\
    \end{tabular}
    \caption{Some table.}
    \label{tab:some_table}
\end{table}

\end{document}

I wish to remove the dots from the algorithms table, as well as to undo the alignment of the page numbers so that it looks like the list of tables above.

Quarint
  • 33

1 Answers1

3

The key is the tocloft command \newlistof. The actual formatting is performed by \l@algocf.

\documentclass{scrreprt}

\usepackage{classicthesis}
\usepackage{algorithm2e}

\makeatletter
\newlistof{algorithms}{loa}{\listalgorithmcfname}%
    \renewcommand{\cftalgorithmsleader}{\hspace{1.5em}}%
    \renewcommand{\cftalgorithmsafterpnum}{\cftparfillskip}%
    \renewcommand{\cftalgorithmspresnum}{\algorithmcfname~}%
    \newlength{\algorithmslabelwidth}%
    \settowidth{\algorithmslabelwidth}{\cftalgorithmspresnum~999}%
    \addtolength{\algorithmslabelwidth}{2.5em}%
    \cftsetindents{algorithms}{0em}{\algorithmslabelwidth}%
    \let\l@algocf\l@algorithms
\makeatother

\begin{document}

\listoftables
\listofalgorithms

\newpage

Here is Algorithm \ref{alg:some_alg}.

\begin{algorithm}
    \For{something}{
        something else
    }
    \caption{Some algorithm.}\label{alg:some_alg}
\end{algorithm}

Here is Table \ref{tab:some_table}.

\begin{table}
    \centering
    \begin{tabular}{cc}
    some line & some content \\
    some other line & some other content \\
    \end{tabular}
    \caption{Some table.}
    \label{tab:some_table}
\end{table}

\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • I tried this but I get the error:
    l.57 \newlistof
                   {algorithms}{loa}{\listalgorithmcfname}%
    !  ==> Fatal error occurred, no output PDF file produced!
    
    – Konrad Höffner Jan 11 '20 at 19:18
  • The error I get (now) is undefined \spacedallcaps, which is used by classicthesis, but I have no idea where it is defined. – John Kormylo Jan 12 '20 at 19:25
  • Further research showed that \spacedallcaps was provided by mathpazo, but it appears to no longer be supported. – John Kormylo Jan 12 '20 at 19:34
  • I got it to work by placing the code into my main .tex file, not in classicthesis-config.tex but afterwards, so that classicthesis.sty is already loaded. – Konrad Höffner Jan 13 '20 at 14:22