# Add algorithm2e to ToC with KOMA-Script

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.

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}

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


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}