算法中的“for”和“end for”不会开始新行

算法中的“for”和“end for”不会开始新行

我在算法环境中使用 for 循环,如下所示:

\begin{algorithm}
    \caption{data collection}
    \begin{algorithmic}[1]
\Procedure{Synthesised data}{\textit{input:} control docs}
    \Procedure{Keywords extraction}{\textit{input:} control docs}
         \For{doc in control docs}
            extract keywords from doc and add to keywords set
         \EndFor
         remove duplicated keywords from keywords set
         export keywords to a $txt$ file for manual filtration 
    \EndProcedure
    \EndProcedure
    \end{algorithmic}
\end{algorithm}

输出如图所示 在此处输入图片描述

有什么帮助吗!

答案1

发现我\State在每个语句的开头都缺少了什么,所以代码应该是这样的:

\Procedure{Keywords extraction}{\textit{input:} control docs}
         \For{doc in control docs}
            \State get indexed keywords from doc meta-data and add to keywords set
         \EndFor
         \State remove duplicate keywords from keywords set
         \State export keywords to a $txt$ file for manual filtration 
    \EndProcedure

相关内容