latex编写伪代码

使用algorithmicx包

\begin{algorithm}
  \caption{Sum of integers from 1 to n.}
    \begin{algorithmic}[1]
      \Procedure {Sum}{$n$}
        \State $sum \gets 0 \hfill \triangleright$ {Initialization}
        \For{$i \gets 1,n$}
          \State $sum \gets sum + i$		
        \EndFor
        \State \Return{$sum$} $\hfill \triangleright$ {Return}
      \EndProcedure
    \end{algorithmic}
\end{algorithm}

 

结果如下:

latex编写伪代码

 

 

上一篇:入门latex——环境搭建


下一篇:2021-10-02