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.

How can I prevent the \listofalgorithms from being indented? I tried everything I could find on the internet, but the index of my algorithms refused to be aligned along with the title.

Here is a MWE:

\documentclass{article}
\usepackage{nomencl}
\usepackage{mathtools}
\usepackage{algorithm}
\usepackage{algpseudocode}
\numberwithin{algorithm}{section}
\begin{document}
    \renewcommand{\nomname}{List of Algorithms}
    \listofalgorithms
    \newpage
    \section{Introduction}\noindent
    Text\\
    \begin{algorithm}[H]
        \caption{Caption}
        \label{algo:caption}
        \begin{algorithmic}[1]
            \State hello world
        \end{algorithmic}
    \end{algorithm}
\end{document}

Any help is appreciated. Thanks!

share|improve this question

1 Answer 1

up vote 6 down vote accepted

The indentation is due to how the \listof macro works; it's provided by float that's loaded by algorithm. The easiest way to remove the indent is to patch that command:

\usepackage{etoolbox}
\patchcmd{\listof}{1.5em}{0pt}{}{}

The definition of \listofalgorithms is

\newcommand{\listofalgorithms}{\listof{algorithm}{\listalgorithmname}}

and \listof is

\newcommand{\listof}[2]{%
  \@ifundefined{ext@#1}
    {\float@error{#1}}
    {\@namedef{l@#1}{\@dottedtocline{1}{1.5em}{2.3em}}%
     \float@listhead{#2}%
     \begingroup\setlength{\parskip}{\z@}%
       \@starttoc{\@nameuse{ext@#1}}%
     \endgroup}%
}

So once we know that \@dottedtocline is responsible for the typesetting of the line and 1.5em is the initial indent, we're done.

share|improve this answer
    
Thank you very much for the quick and accurate response! –  al.schmid Nov 4 '12 at 21:35

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.