1

I have following algorithm with two different procedures (i.e., phases) and want to give separate line numbers to both of them. Can any body help me out please? Thanks...

\documentclass[10pt,a4paper]{IEEEtran}
\usepackage{algorithmic}
\usepackage{algorithm}
\begin{document}

\begin{algorithm}
\caption{Boundaries calculation and rank computation}
\label{abc}
\begin{algorithmic}[1]

\STATE Phase 1: Compute boundaries
\STATE computer abc
\STATE calculate bcd

\STATE Phase 2: rank computation
\STATE compute wxy
\STATE calculate xyz

\end{algorithmic}
\end{algorithm}
\end{document}

1 Answer 1

0

Something like this. Wrap each phase with different/independent alogrithmic environment.

Update: To add a blank line without being numbered between two phases, add \item[] at the end of the phase 1 environment.

enter image description here

enter image description here

Code

\documentclass[10pt,a4paper]{IEEEtran}
\usepackage{algorithmic}
\usepackage{algorithm}
\begin{document}

\begin{algorithm}
\caption{Boundaries calculation and rank computation}
\label{abc}
\begin{algorithmic}[1]
\STATE Phase 1: Compute boundaries
\STATE computer abc
\STATE calculate bcd
\end{algorithmic}
\begin{algorithmic}[1]
\STATE Phase 2: rank computation
\STATE compute wxy
\STATE calculate xyz
\end{algorithmic}
\end{algorithm}
\end{document}
5
  • Simple yet powerful! So just a use of separate algorithmic environment for each phase.
    – mani
    Commented Sep 7, 2014 at 13:51
  • I also want to add a blank line without a line number between two phases.
    – mani
    Commented Sep 7, 2014 at 13:52
  • Add an \item[] at the end or beginning of an algorithmic environment.
    – Jesse
    Commented Sep 7, 2014 at 13:56
  • What about if one does not want to show line number with Phase 1: Compute boundaries and Phase 2: rank computation lines.
    – mani
    Commented Sep 7, 2014 at 14:22
  • Well, \STATE will count the line number while \item[] won't. So replace the \STATE with \item[] in front of Phase 1 and Phase 2
    – Jesse
    Commented Sep 7, 2014 at 14:35

You must log in to answer this question.

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