I'm trying to typeset algorithms in the memoir class. I'm using the algorithmic package with a custom environment as this was the only way I could get the list of algorithm to display correctly in the table of content, and the algorithm to be listed correctly in the list algorithms. As shown in the following images,

table of content correct list of algorithms correct

Currently the algorithm is displayed as follows,

algorithm display

How to I reformat the algorithms environment to look more like the following?

example one example two

I don’t need the exact formatting, just something more professional. I would ideally like line numbering, the vertical lines, the horizontal lines, and some form of left and right indentation that is less than the text width. My current code is,


\newcommand{\listalgorithmname}{List of Algorithms} \newlistof{listofalgorithms}{loa}{\listalgorithmname}


\chapter{Example Chapter}
\section{Example Section}

\caption{An Algorithm Template}
\REQUIRE $n \geq 0$
\ENSURE $y = x^n$ 
\STATE $y \leftarrow 1$
\STATE $X \leftarrow x$
\STATE $N \leftarrow n$
 \WHILE{$N \neq 0$}
 \IF{$N$ is even}
\STATE $X \leftarrow X \times X$
\STATE $N \leftarrow N / 2$
\ELSE[$N$ is odd]
 \STATE $y \leftarrow y \times X$
\STATE $N \leftarrow N - 1$

2 Answers 2


You can load the float package after having defined the new float with memoir macros:

\newcommand{\listalgorithmname}{List of Algorithms}


Then remove the \hrulefill commands and you'll get the "traditional" format.

enter image description here


I'm very happy with algorithm2e and memoir. But I had to add the following in the body of the text for the TOC (the text is is Spanish, that is why I had to reset the names, babel doesn't handle it, the spacing is to make the list of algorithms use the same spacing as the one adjusted for the other lists of...):

%%% For algorithm2e

\SetAlgorithmName{Algoritmo}{Algoritmo}{Índice de algoritmos}
  • I couldn't get this to work. If you could maybe provide a full example instead.
    – entropy
    Commented Feb 20, 2013 at 9:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .