I would like to find a pseudocode package that support the possibility to wrote a comment at the right side of a if and that it wont be between { }
but rather at the right side of the page, after a symbol.
I would like instead of
if x < p { .} then
something like this:
if (x < p) \blacktriangleright x is a ...
my code:
\documentclass[]{scrbook}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
\begin{algorithm}
\caption{Influx}
\label{influx}
\begin{algorithmic}[1]
\REQUIRE $p \in [0,1]$, $G$
\ENSURE None
\FOR{$i = 0 \to 2^d-1$}
\IF{$n(\nu_i) = 0$}
\IF{ $x < p$ \COMMENT{ $x$ is a normal distribution number in the range of $[0,1]$}}
\STATE Occupy $v_i$ site with probablility $p$
\ENDIF
\ENDIF
\ENDFOR
\end{algorithmic}
\end{algorithm}
Any ideas?
Best Answer
To achieve your desire, it would be necessary to make some (as far as I could tell) major changes in the
algorithmic
package. One possibility is to use the algorithmicx package instead. A little exampleHere's the result:
Uncommenting the line with
\algrenewcommand
you'll get a black triangle for the comments.