elsarticle 模板中的 algpseudocode 格式不正确

elsarticle 模板中的 algpseudocode 格式不正确

我用它algpseudocode来编写伪代码。我注意到伪代码是对齐的,这在这里看起来不太好。下面是 latex 代码片段-

\usepackage{algorithm}
\usepackage[noend]{algpseudocode}

\begin{algorithm}
\caption{Generate Random Slides}
\label{algo:slide_generator}
\begin{algorithmic}[1]
    \Procedure{SlideGenerator}{}
    \State Let ${array\_temp}$ is a new list of length $\gets {array\_alph}.Length$
    \State  Let ${array\_slides}$ is a new list of length $\gets {array\_alph}.Length$
    \For{$i = 0 \to \textit{array\_alph}.Length$}
        \State $first\_char\_per\_slide \gets getUniqueChar(array\_temp)$
        \Comment Get unique character from ${array\_alph}$ which is not present in ${array\_temp}$
        \State $unique\_alph.Add(first\_char\_per\_slide)$
            \While{$used\_alph.Length < items\_per\_slide$}
                \State $unique\_alph.Add(getUniqueChar(unique\_alph))$
                \Comment Get unique character from $unique\_alph$ and add it to $unique\_alph$
            \EndWhile
    \EndFor
    \State $array\_slides [i] \gets current\_slide(unique\_alph)$
    \State $array\_temp.Add(first\_char\_per\_slide)$\\
    \Return $array\_slides$
    \EndProcedure
\end{algorithmic}
\end{algorithm}

以下是生成的 pdf 的屏幕截图-

在此处输入图片描述

我有以下两个问题-

  1. 如何修正对齐?
  2. 既然伪代码看起来不太好看,如何修改它的内容呢?

我有上面的 C# 代码,但不知何故我无法编写正确的伪代码。上面的伪代码使用系统集合通用列表

相关内容