Reputation: 63
I've written the code, but line number are not proper, the code looks like this:
\begin{algorithm}[H]
\caption{Algorithm}
\begin{algorithmic}[1]
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\REQUIRE $Graph\ G(V, E)$
\STATE $\textbf{\textit{function}}\ $
\Do
\State Something
\doWhile
\end{algorithmic}
\label{algo1}
\end{algorithm}
The output of above code looks like this:
How I can get the proper numbering? Or is there any simpler way to write do while loop in latex?
Upvotes: 1
Views: 15893
Reputation:
Try the algorithm2e
package. ;)
\documentclass[a4paper, 11pt]{article}
\usepackage[norelsize, linesnumbered, ruled, lined, boxed, commentsnumbered]{algorithm2e}
\begin{document}
\begin{algorithm}[H]
\SetAlgoLined
\LinesNumbered
\SetKwInOut{Input}{Input}
\Input{$Graph\ G(V, E)$}
\SetKwProg{Function}{function}{}{end}
\SetKwRepeat{Do}{do}{while}
\Function{function(param: int) : int}{
\Do{done = false}{ something }
}
\caption{Algorithm}
\end{algorithm}
\end{document}
Upvotes: 0