« Doxygen, and how to use it | Main | "Formal Analysis of the Remote.." by Havelund »
October 08, 2003
Numbered Pseudocode in Latex
Numbererd pseudocode has line numbers that proceede each line of your pseudocode, as you might have guessed. The latex is...
\begin{figure}
% --------------------------------------------------
\noindent
\newcounter{alines}
\begin{list}{\arabic{alines}\ \ }{\usecounter{alines}}
\item \textbf{Algorithm Conciousness}
\item while (1)
\labe{line:example}
\item \ \ \ wait to recieve message;
\item \ \ \ if message = startDFS1 then DFS1
\item \ \ \ if message = (startDFS2, trace) then DFS2 (trace)
\item \ \ \ if message = abort then kill DFS1 and/or DFS2
\item endwhile
\item ...
\end{list}
\caption{Parts of the BEE algorithm.}
\label{fig:searches}
\end{figure}
As an added bonus, if you add \label entries on the line just below an \item, the label will refer to that particular line number. So in this example, \ref{line:example} refers to the line number of the line containing "while(1)"
Posted by jones at October 8, 2003 09:42 AM
Comments
Post a comment
Thanks for signing in, . Now you can comment. (sign out)
(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)