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'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}
\renewcommand{\cftchapleader}{~\cftdotfill{}}
\renewcommand{\cftsubsecleader}{~\cftdotfill{}}
\renewcommand{\cftsubsubsecleader}{~\cftdotfill{}}
\renewcommand{\cftsecleader}{~\cftdotfill{}}
\renewcommand{\cftfigleader}{~\cftdotfill{}}
\renewcommand{\cfttableader}{~\cftdotfill{}}
\renewcommand{\cftpartleader}{~\cftdotfill{}}
\renewcommand{\cftparaleader}{~\cftdotfill{}}

% \renewcommand{\cftalgorithmleader}{~\cftdotfill{}}

\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}
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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:

enter image description here

\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
\renewcommand{\cftchapleader}{~\cftdotfill{0}}
\renewcommand{\cftsubsecleader}{~\cftdotfill{0}}
\renewcommand{\cftsubsubsecleader}{~\cftdotfill{0}}
\renewcommand{\cftsecleader}{~\cftdotfill{0}}
\renewcommand{\cftfigleader}{~\cftdotfill{0}}
\renewcommand{\cfttableader}{~\cftdotfill{0}}
\renewcommand{\cftpartleader}{~\cftdotfill{0}}
\renewcommand{\cftparaleader}{~\cftdotfill{0}}

\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.

share|improve this answer
    
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
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.