使用算法时更改注释的对齐方式

使用算法时更改注释的对齐方式

当使用 algorithmicx 包中的注释(如下面的代码)时,注释会右对齐。我该如何更改?我希望注释显示在代码旁边,并用制表符分隔。

\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{algorithm}
\begin{algorithmic}
\State $var$ \Comment{comment about var}
\end{algorithmic}
\end{algorithm}

答案1

您可以重新定义评论的格式,也许是这样的:

\renewcommand{\algorithmiccomment}[1]{\hskip2em$\triangleright$ #1}

相关内容