If you need your own indentation for different algorithms, you can do this by including a counter in the redefinition of comment commands. Here is an example:
\documentclass{amsbook}
\usepackage{algorithmicx,algorithm,eqparbox,array}
\algrenewcommand{\algorithmiccomment}[1]{\hfill// \eqparbox{COMMENT\thealgorithm}{
\algnewcommand{\LongComment}[1]{\hfill// \begin{minipage}[t]{\eqboxwidth{COMMENT\thealgorithm}}
\begin{document}
\begin{algorithm}
\begin{algorithmic}
\State{do nothing}\Comment{huh?}
\end{algorithmic}
\caption{Test Alg}
\end{algorithm}
\begin{algorithm}
\begin{algorithmic}
\State{do something} \LongComment{this is a comment broken over lines}
\State{do something else} \Comment{this is another comment}
\end{algorithmic}
\caption{Other Alg}
\end{algorithm}
\end{document}
source
share