%!TEX program = xelatex
\documentclass{article}
\usepackage{algorithm}
\usepackage{algorithmic}
\begin{document}
\begin{algorithm}[]
\caption{LDA}
\begin{algorithmic}[1]
\FOR{$d$}
\STATE{
\FOR{$k\in\{1,...,K\}$}
\STATE{Generate$\beta_k=(\beta_{k_1},...,\beta_{k,V})^T \sim Dirichlet(\cdot\vert\eta)$}
\ENDFOR
}
\ENDFOR
\end{algorithmic}
\end{algorithm}
\end{document}
答案1
\STATE
使用 时无需\FOR
。后一种构造\STATE
默认设置了 :
\documentclass{article}
\usepackage{algorithm,algorithmic,amsmath}
\begin{document}
\begin{algorithm}
\begin{algorithmic}[1]
\FOR{$d$}
\FOR{$k \in \{1,\dots,K\}$}
\STATE Generate $\beta_k = (\beta_{k_1},\dots,\beta_{k,V})^T \sim \text{Dirichlet}(\cdot\vert\eta)$
\ENDFOR
\ENDFOR
\end{algorithmic}
\end{algorithm}
\end{document}