1

I want to describe algorithms that have two parts: an interface specification and an algorithm.

The interface specifications should be labeled Module and the algorithm specifications should be labeled Algorithm. Moreover, I want the interfaces to be numbered separately from the algorithms.

The output should be something like the following:

Module 1: An interface specification
     Some interface spec...


Algorithm 1: An algorithm
     Some pseudocode...

The following, however, is what I'm currently getting:

mwe output

My code is the following:

\documentclass{article}

\usepackage{algorithm}
\usepackage{algpseudocode}

\makeatletter
  \renewcommand{\ALG@name}{Module: }
\makeatother

\begin{document}

\begin{algorithm}
\caption{An interface specification}
\begin{algorithmic}
\State Some interface spec...
\end{algorithmic}
\end{algorithm}

\begin{algorithm}
\caption{An algorithm}
\begin{algorithmic}
\State Some pseudocode...
\end{algorithmic}
\end{algorithm}

\end{document}
4
  • There are a couple of packages for typesetting algorithms, such as algorithm2e, algorithmicx, algorithms, or just a plain tabbing environment. Please try out any of these first and then come back with a specific question. I'm voting to close as unclear for now, but once you add a minimal example illustrating your specific problem we can reopen it. Commented Sep 7, 2016 at 7:13
  • On CTAN there is the dedicated category pseudocode collecting all packages for typesetting algorithms. Commented Sep 7, 2016 at 7:14
  • You are maybe also interested in UML. There are also a couple of packages for that: ctan.org/topic/uml Commented Sep 7, 2016 at 7:16
  • I have added a MWE and rephrased my question.
    – davitenio
    Commented Sep 15, 2016 at 5:56

1 Answer 1

0

The following is based on an answer to the question Modify Algorithm name in French:

\documentclass{article}

\usepackage{algorithm}
\usepackage{algpseudocode}

\newfloat{module}{htb}{lop}
\floatname{module}{Module}

\makeatletter
\newcommand{\newalgname}[1]{%
  \renewcommand{\ALG@name}{#1}%
}
\makeatother

\begin{document}

\begin{module}
\caption{An interface specification}
\begin{algorithmic}
\State Some interface spec...
\end{algorithmic}
\end{module}

\begin{algorithm}
\caption{An algorithm}
\begin{algorithmic}
\State Some pseudocode...
\end{algorithmic}
\end{algorithm}

\end{document}

It produces the following output:

desired output

You must log in to answer this question.

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