2

How can I add the list of algorithms from algorithm2e to the table of contents of a KOMA-Script class?

MWE:

\documentclass[oneside,listof=totoc]{scrbook}
\setuptoc{loa}{totoc} %does not work

\usepackage{algorithm2e}

\begin{document}

\tableofcontents

\listofalgorithms

\chapter{First}

\begin{algorithm}
\caption{title}
this is an algorithm
\end{algorithm}

\end{document}

The use of the global option dotocloa, which loads the package tocbibind is disliked by KOMA-Script classes.

1 Answer 1

2

To get the list of algorithms under control of package tocbasic use

\addtotoclist[float]{loa}
\renewcommand\listofalgorithms{\listoftoc[{\listalgorithmcfname}]{loa}}

Example:

\documentclass[oneside,listof=totoc]{scrbook}

\usepackage{algorithm2e}
\addtotoclist[float]{loa}% <- added
\renewcommand\listofalgorithms{\listoftoc[{\listalgorithmcfname}]{loa}}% <- added

\begin{document}
\tableofcontents
\listofalgorithms
\chapter{First}
\begin{algorithm}
\caption{title}
this is an algorithm
\end{algorithm}
\end{document}

screenshot


With float in the optional argument of \addtotoclist the list of algorithms has the same owner like LOF and LOT. Therefore listof=totoc adds also the LOA to the Table of Contents.

If you choose another owner or omitt the optional argument, you have to add \setuptoc{loa}{totoc}:

\usepackage{algorithm2e}
\addtotoclist[\jobname]{loa}
\renewcommand\listofalgorithms{\listoftoc[{\listalgorithmcfname}]{loa}}
\setuptoc{loa}{totoc}

You must log in to answer this question.

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