TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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$
share|improve this question
up vote 2 down vote accepted

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

share|improve this answer

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}
share|improve this answer
I couldn't get this to work. If you could maybe provide a full example instead. – entropy Feb 20 '13 at 9:43

Your Answer


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.