algpseudocode 在 elsarticle 範本中格式不正確

algpseudocode 在 elsarticle 範本中格式不正確

我正在用來algpseudocode編寫偽代碼。我注意到偽代碼是對齊的,這裡看起來不太好。下面是乳膠程式碼片段-

\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# 程式碼,但不知何故我無法編寫正確的偽代碼。上面的偽代碼使用System.Collections.Generic.List

相關內容