Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Typesetting algorithms in memoir

46 views
Skip to first unread message

Filip Miletic

unread,
Dec 12, 2006, 6:00:49 AM12/12/06
to
Greetings:

I would like to add algorithms in a document typeset using the memoir
class. I tried to use the alg and algorithm packages. Both attempts
failed as both packages use float.sty which defines \newfloat. \newfloat
is already defined in memoir.

Can someone advise how I can get around this problem? I tried to
customize alg.sty, but this did not work out as I probably missed
something important.

Thanks,
f

Danie

unread,
Dec 12, 2006, 7:00:14 AM12/12/06
to

The algorithm packages consists of two style files: algorithmic.sty and
algorithm.sty. The latter one, algorithm.sty uses internaly the float
packages which causes the clash with memoir (see algorithm
documentation). You can still use algorithmic to format your
algorithms, but you need to define your own float environment with
memoir. I very simple example follows

Danie Els (dnjels at sun dot ac dot za)

%---------------------------------------------------------------------------
\documentclass{memoir}

\usepackage{algorithmic}

%% New float in memoir. You can make a much more
%% fancy version, this is just a tamplate

\newcommand{\algorithmname}{Algorithm}
\newcommand{\listalgorithmname}{List of Algorithms}
\newlistof{listofalgorithms}{loa}{\listalgorithmname}
\newfloat{algorithm}{loa}{\algorithmname}
\newfixedcaption{\falgcaption}{algorithm}
\newlistentry{algorithm}{loa}{0}

\begin{document}
\listofalgorithms ...
\clearpage

\begin{algorithm}
\caption{An Algorithm}
\label{alg1}
\begin{algorithmic}
% .... you algorithm
\end{algorithmic}
\end{algorithm}

As diagrams~\ref{alg1} and \ref{alg2} shows ...

%% You can also add a non-floating algorithm ...
\begin{minipage}{.9\textwidth}
\falgcaption{Another algorithm}
\label{alg2} ...
\begin{algorithmic}
% .... you algorithm
\end{algorithmic}
\end{minipage}

\end{document}

Filip Miletic

unread,
Dec 12, 2006, 8:12:25 AM12/12/06
to
Danie wrote:
> documentation). You can still use algorithmic to format your
> algorithms, but you need to define your own float environment with

Thanks for the tip, it worked just as you described it.

f

0 new messages