# algorithmicx \comment command

\documentclass{tudelft-report}
\usepackage[utf8]{inputenc}
\usepackage{algorithm,algorithmicx,algpseudocode}
\begin{algorithm}
\caption{cICA}\label{cICA}
\begin{algorithmic}[1]
\Procedure{cICA}{}\Comment{The procedure of cICA}
\State \textbf{Initialization} $b$\Comment{Initialize the parameters}
\begin{align*}
\mu& = 1      \quad \lambda  = 1\\
\gamma& = 1   \quad \eta  = 1\\
threshold& = 0.00001 \quad flag =1\\
\end{align*}
\While{$r\not=0$}\Comment{stop the loop when the changed value of weighted
vector is larger than threshold}
\State $\mu_{t} = max\{0,\mu_{t-1}+\gamma g(w_{t-1})\}$
\State $\lambda_{t} = \lambda_{t-1}+\gamma h(w_{t-1})$
\State $\Gamma_{1} = \overline{\rho}E\{zG'_{y}(y)\} - \frac{1}{2}\mu E\{zg'_{y}(y)\}-\lambda E\{zy\}$
\State $\Gamma_{2} = \overline{\rho}E\{G"_{y^{2}}(y)\} - \frac{1}{2}\mu E\{g"_{y^{2}}(y)\}-\lambda$
\If{$norm(w_{k} - w_{k-1}) < threshold$ }
\State flag = 0;
\Else
\State flag = 1;
\EndIf
\EndWhile\label{euclidendwhile}
\State \textbf{return} $w$\Comment{The optimal weight vector $w$}
\EndProcedure
\end{algorithmic}
\end{algorithm}


When I was using the comment command in algorithmicx, there is always a bank square at the beginning of the text. Could anaynoe help me with this?

You can redefine the way algorithmicx's \Comment works using

\algrenewcommand\algorithmiccomment[1]{\hfill #1}


According to this answer, the default behavior of \Comment is to insert \hfill $$\triangleright$$. The above redefines it to not render a symbol. You can alternatively use any other symbol.

When replacing the documentclass{tudeflt-report} with another documentclass, e.g. \documentclass{article}, the triangle is correctly rendered (instead of the box), so this might be an issue with the used documentclass.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{algorithm,algorithmicx,algpseudocode}

\algrenewcommand\algorithmiccomment[1]{\hfill #1}

\begin{document}

\begin{algorithm}
\caption{cICA}\label{cICA}
\begin{algorithmic}[1]
\Procedure{cICA}{}\Comment{The procedure of cICA}
\State \textbf{Initialization} $b$  \Comment{Initialize the parameters}
\begin{align*}
\mu& = 1      \quad \lambda  = 1\\
\gamma& = 1   \quad \eta  = 1\\
threshold& = 0.00001 \quad flag =1\\
\end{align*}
\While{$r\not=0$}\Comment{stop the loop when the changed value of weighted
vector is larger than threshold}
\State $\mu_{t} = max\{0,\mu_{t-1}+\gamma g(w_{t-1})\}$
\State $\lambda_{t} = \lambda_{t-1}+\gamma h(w_{t-1})$
\State $\Gamma_{1} = \overline{\rho}E\{zG'_{y}(y)\} - \frac{1}{2}\mu E\{zg'_{y}(y)\}-\lambda E\{zy\}$
\State $\Gamma_{2} = \overline{\rho}E\{G"_{y^{2}}(y)\} - \frac{1}{2}\mu E\{g"_{y^{2}}(y)\}-\lambda$
\If{$norm(w_{k} - w_{k-1}) < threshold$ }
\State flag = 0;
\Else
\State flag = 1;
\EndIf
\EndWhile\label{euclidendwhile}
\State \textbf{return} $w$\Comment{The optimal weight vector $w$}
\EndProcedure
\end{algorithmic}
\end{algorithm}

\end{document}


• I'm glad I could help. Would you like to mark the answer as accepted? – chrisma Jul 24 '18 at 14:25