いっつも検索してる気がするのでメモ。
ドキュメント
LaTeX/Algorithms - Wikibooks, open books for an open world
記述例
(〜省略〜) \usepackage{amsmath} \usepackage{algorithm} \usepackage[noend]{algpseudocode} \makeatletter \def\BState{\State\hskip-\ALG@thistlm} \makeatother (〜省略〜) \caption{My algorithm}\label{euclid} \begin{algorithmic}[1] \Procedure{MyProcedure}{} \State $\textit{stringlen} \gets \text{length of }\textit{string}$ \State $i \gets \textit{patlen}$ \BState \emph{top}: \If {$i > \textit{stringlen}$} \Return false \EndIf \State $j \gets \textit{patlen}$ \BState \emph{loop}: \If {$\textit{string}(i) = \textit{path}(j)$} \State $j \gets j-1$. \State $i \gets i-1$. \State \textbf{goto} \emph{loop}. \State \textbf{close}; \EndIf \State $i \gets i+\max(\textit{delta}_1(\textit{string}(i)),\textit{delta}_2(j))$. \State \textbf{goto} \emph{top}. \EndProcedure \end{algorithmic} \end{algorithm}