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
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}
Thanks for the tip, it worked just as you described it.
f