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.

4
  • 2
    Questions seeking debugging help (“why isn't this code working?”) must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See minimal working example (MWE). Aug 21, 2019 at 10:47
  • 2
    I have tried to improve the question by providing a minimal working example.
    – Quarint
    Aug 21, 2019 at 11:25
  • 1
    Very good, +1. Surely someone will answer soon. Aug 21, 2019 at 12:02
  • 1
    Looking at classicthesis.sty, I see that it is already set up for listings. The code for this adaptation is rather extensive. Aug 21, 2019 at 13:45

1 Answer 1

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}
4
  • I tried this but I get the error: ! Undefined control sequence. l.57 \newlistof {algorithms}{loa}{\listalgorithmcfname}% ! ==> Fatal error occurred, no output PDF file produced! Jan 11, 2020 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. Jan 12, 2020 at 19:25
  • Further research showed that \spacedallcaps was provided by mathpazo, but it appears to no longer be supported. Jan 12, 2020 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. Jan 13, 2020 at 14:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .