Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 ?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

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}

enter image description here

share|improve this answer
    
This works great, thank you. –  AldurDisciple Mar 1 '13 at 7:10
    
I was wondering if the line \contentsuse{algorithm}{loa} was still needed, but a simple compilation test told me that it was indeed. –  AldurDisciple Mar 1 '13 at 7:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.