I am using the
\usepackage{algpseudocode}
\usepackage{algorithm}
packages and creating a sample algorithm using the \COMMENT
, \IF
, \ENDIF
and \FOR
constructs. When I compile this and view the PDF file, I don't see any of the key words, the indenting is not correct and I have to explicitly mention the key words. Is there anything that I am missing here?
I am using TeXShop on OS X.
EDIT :
This is what I am using
\begin{algorithm}
\caption{Algorithm for finding server indices using OFG}
\begin{algorithmic}
\newline
\COMMENT { \%comment: servers[] contains the index of servers whose data rate are sorted in descending order\%}\newline
\STATE servers[]= index(of all servers) \newline
\STATE serverIndex[]=servers[0..K]\newline
\STATE linearlyIndependentServerIndex[]=0\newline
\STATE $[Z] \leftarrow 0$\newline
\FOR {$i=0$ to $serverIndex.length$} \newline
\COMMENT{ \%comment: find the equation corresponding the serverIndex from the mapping at the File Server\%} \newline
\STATE $eqn= equation(serverIndex[i])$ \newline
\COMMENT{ \%comment: try insert equation into Z using OFG\%} \newline
\ENDFOR end for\newline \newline
\WHILE{ ( linearlyIndependentServerIndex.length!=K ) } \newline
\COMMENT{\%comment: remove all the server index which were not inserted in Z\%} \newline
\STATE temp[]=serverIndex[]-linearlyIndependentServerIndex \newline
\IF{ (linearlyIndependentServerIndex.length=K) }\newline
\STATE break\newline
\ENDIF \newline
\ENDWHILE \newline
\end{algorithmic}
\end{algorithm}
I had to include newline so that the code is readable.
The resulting output after compiling: