# Line of dots in the \listofalgorithms

I've been working with the ToC, LoF, LoT and more recently with the LoA (List of Algorithms) of my dissertation. I'm using the tocloft package so I can set their styles the way I want. My first problem was making these dots closer. I resolved that by renewing some commands and removing the separators from them.

I'm using the algorithm2e package to manage my algorithms and get the command \listofalgorithms. The index is well generated but the dots are still separated. I've tried to use the \newlistof but it didn't work. Also using renewing the command \renewcommand{\cftalgorithmleader}{~\cftdotfill{}} but it says that \cftalgorithmleader is undefined.

Here we have a minimal example of the problem where the dots are still separated in the list of algorithms.

\documentclass[10pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[portuguese,algosection,algoruled,linesnumbered]{algorithm2e}
\usepackage[titles]{tocloft}

\begin{document}

\tableofcontents
\listofalgorithms

\chapter{One}
\section{OnedotOne}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{this first text}
\caption{first algorithms}
\end{algorithm}

\chapter{Two}
\section{TwodotOne}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{this second text}
\caption{second algorithms}
\end{algorithm}

\end{document}

-

algorithm2e manages its own List of Algorithms (LoA). That's why tocloft has no idea what to do with the command \cftalgorithmleader. Moreover, it actually references the algorithms in the LoA as an algocf, and not an algorithm. Either way, you have to modify the dot separation in the "old fashion way" - by renewal of \@dotsep:

\makeatletter
\renewcommand{\@dotsep}{0}
\makeatother
\listofalgorithms


Here is what it looks like in your MWE:

\documentclass[10pt]{book}
%\usepackage[utf8]{inputenc}% http://ctan.org/pkg/inputenc
\usepackage[portuguese,algosection,algoruled,linesnumbered]{algorithm2e}% http://ctan.org/pkg/algorithm2e
\usepackage[titles]{tocloft}% http://ctan.org/pkg/tocloft

\begin{document}

\tableofcontents
\makeatletter
\renewcommand{\@dotsep}{0}% Remove gap between dot leader in LoA.
\makeatother
\listofalgorithms

\chapter{One}
\section{OnedotOne}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{this first text}
\caption{first algorithms}
\end{algorithm}

\chapter{Two}
\section{TwodotOne}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{this second text}
\caption{second algorithms}
\end{algorithm}

\end{document}


Note that you should not specify \cftdotfill{}, but rather \cftdotfill{0}, since the value that is set (just like with \@dotsep) is used as an argument to a unit: mus or math units.

-
On the spot. Thanks a lot! Do you know if there's how to put some extra space in the beginning of the dots? I want to separate the reference labels from the dots a little more. – Arthur Alvim Feb 29 '12 at 7:19