1

I use the class memoir, and include algorithms using the algorithm2e package. I would like to have in the toc an entry such as "List of Algorithms". I saw in the documentation of algorithm2e that I have to use the dotocloa option, however, when I use it with the memoir class, i got the following error:

! Undefined control sequence.
\listofalgorithms ->\tocfile 
                             {\listalgorithmcfname }{loa}
l.13 \listofalgorithms

A minimal document to reproduce the error is:

\documentclass{memoir}
\usepackage[dotocloa]{algorithm2e}

\begin{document}
    \tableofcontents
    \pagebreak
    \listofalgorithms
    Test
    \begin{algorithm}
        \caption{Foo}
    \end{algorithm}
\end{document}

If I change the document class to book, it works... Does anyone have an idea of what is the problem?

1 Answer 1

1

An easy way to get rid of the error is to define \tocfile command. A fixed version is given below:

\documentclass{memoir}

\makeatletter
\newcommand{\tocfile}[2]{%
 \begingroup%
 \chapter*{#1}%
 \addcontentsline{toc}{chapter}{\listalgorithmcfname}%
 \@starttoc{#2}%
 \endgroup%
}
\makeatother

\usepackage[dotocloa]{algorithm2e}
\usepackage{blindtext}

\begin{document}
    \tableofcontents
    \listofalgorithms

\chapter{Test}    

\blindtext

\begin{algorithm}
\caption{Foo}
\end{algorithm}

\blindtext

\end{document}

The macro \tocfile inputs two arguments and sets the List of Algorithms. The following process is done by the macro:

  1. The first argument is the heading to set as \chapter*{}.
  2. Include the extension of file where the list of algorithms were written to auxiliary file named \jobname.loa.
2
  • Thanks to this I get rid of the error, however, It still not add an entry such as "List of Algorithms" in the table of contents. Any clue?
    – Vince
    Commented Jul 31, 2016 at 10:56
  • @Vince: I have updated the answer by adding \addcontentsline{toc}{chapter}{\listalgorithmcfname}. This will make what you are looking for.
    – Jagath
    Commented Jul 31, 2016 at 11:03

You must log in to answer this question.

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