# Typesetting listofalgorithms like listoffigures and listoftables using titletoc

I would like to typeset the \listofalgorithms generated by package algorithm in the same way than the \listoffigures and \listoftables, using package titletoc. However, I have not been able to find a solution to that problem.

Here is a MWE:

\documentclass[12pt,a4paper]{book}

\usepackage{titletoc}
\usepackage[chapter]{algorithm}
\usepackage{algpseudocode}

\renewcommand{\cleardoublepage}{\clearpage}

\titlecontents{figure}[2.0em]{}{\contentslabel{2.3em}}{}{\titlerule*[0.25pc]{.}\contentspage}{}
\titlecontents{table}[2.0em]{}{\contentslabel{2.3em}}{}{\titlerule*[0.25pc]{.}\contentspage}{}
\contentsuse{algorithm}{loa}
\titlecontents{algorithm}[2.0em]{}{\contentslabel{2.3em}}{}{\titlerule*[0.25pc]{.}\contentspage}{}

\begin{document}

\listoffigures
\listoftables
\listofalgorithms

\chapter{Nice chapter}

\begin{figure}[t]
\caption{Nice figure}
\end{figure}

\begin{table}[t]
\caption{Nice table}
\end{table}

\begin{algorithm}[t]
\caption{Nice algorithm}
\end{algorithm}

\end{document}


Can someone think of a way to do it ?

The \listofalgorithms command is defined by the float package. One can do by copying the definition of \listoftables and patching it:

\documentclass[12pt,a4paper]{book}

\usepackage{titletoc}
\usepackage[chapter]{algorithm}
\usepackage{algpseudocode}
\usepackage{etoolbox}

\titlecontents{figure}[2.0em]{}{\contentslabel{2.3em}}{}{\titlerule*[0.25pc]{.}\contentspage}{}
\titlecontents{table}[2.0em]{}{\contentslabel{2.3em}}{}{\titlerule*[0.25pc]{.}\contentspage}{}
\contentsuse{algorithm}{loa}
\titlecontents{algorithm}[2.0em]{}{\contentslabel{2.3em}}{}{\titlerule*[0.25pc]{.}\contentspage}{}

\let\listofalgorithms\listoftables
\patchcmd{\listofalgorithms}{\listtablename}{\listalgorithmname}{}{}
\patchcmd{\listofalgorithms}{\listtablename}{\listalgorithmname}{}{}
\patchcmd{\listofalgorithms}{\listtablename}{\listalgorithmname}{}{}
\patchcmd{\listofalgorithms}{lot}{loa}{}{}

\begin{document}
...
\end{document}


• I was wondering if the line \contentsuse{algorithm}{loa} was still needed, but a simple compilation test told me that it was indeed. – BConic Mar 1 '13 at 7:16
• The \contentsuse{algorithm}{loa} is definitely the key part to this answer that is not immediately clarified when creating new floats and trying to create a "List of [New Float]" contents page. This also works great in combination with this answer: tex.stackexchange.com/a/9257/59034 – user59034 Jun 17 '15 at 20:07