\begin{algorithm}\caption{Algorithm Title}\begin{algorithmic}\REQUIRE$n\geq1$%输入条件\ENSURE$Sum=1+\cdots+n$%输出\STATE$Sum\leftarrow0$%\STATE 命名演示\IF{$n <1$}%条件语句\PRINT{Input Error}%打印语句\ELSE\FOR{$i=0$to n}%FOR循环结构\STATE$Sum=Sum+i$\\\STATE$i=i+1$\ENDFOR\...
commentsnumbered]{algorithm2e} \begin{document} \begin{algorithm}[H] \SetAlgoLined \KwData{this text} \KwResult{how to write algorithm with \LaTeX2e } initialization\; \While{not at end of this document}{ read current\; \eIf{understand}{ go to next section\; current section becomes this...
\documentclass{article} \usepackage{algorithm} \usepackage{algorithmic} \begin{document} \begin{algorithm} \caption{Example Pseudocode with Comments} \begin{algorithmic}[1] \STATE Initialize variables $x \gets 0$, $y \gets 1$ % Initialization step \WHILE{$x < 10$} % Loop until $x$ ...
在论文写作和排版过程中,常常会用到算法描述,在LaTex中,算法描述块的排版会用到两个宏包 \usepackage{algorithm} 和 \usepackage{algorithmic}。算法的排版,主要在于控制缩进、粗体、横线等格式,这些都会在这篇博客中进行介绍。 在开始算法排版之前,首先在文档开头加入下面两句,以导入宏包: \usepackage{algorithm} \...
\UNTIL{B} \end{algorithmic} \end{algorithm} 在编译之后,显示为: 使用algorithmic包时,关键字全部大写,如果使用的是algorithmicx包,那么关键字首字母大写,后面小写。 例2 第二个例子更加详细的展示了缩进的控制,可以自己编译一下: \begin{algorithm}
\begin{algorithm}[htb] \caption{ Framework of ensemble learning for our system.} \label{alg:Framwork} \begin{algorithmic}[1] %这个1 表示每一行都显示数字 \REQUIRE ~~\\ %算法的输入参数:Input The set of positive samples for current batch, $P_n$;\\ The set of unlabelled samples for...
\begin{algorithm}[htb] \caption{ Framework of ensemble learning for our system.} \label{alg:Framwork} \begin{algorithmic}[1] %这个1 表示每一行都显示数字 \REQUIRE ~~\\ %算法的输入参数:Input The set of positive samples for current batch, $P_n$;\\ The set of unlabelled samples for...
一般会接触到的包有algorithm、algorithmic、algorithmicx、algorithm2e这四种包。 algorithm用于给伪代码提供一个浮动体环境,防止其换页或其他因素导致的内容中断,从而跨页显示。 algorithmic用于编辑伪代码的内容,一些for、while、if等语句通过该包中的命令进行编写。
Algorithm2e本身不支持Do-While结构(支持的是While-Do),需要自行定义。不过自行定义并不难,因为宏包中内置了Repeat-Until结构,在Algorithm2e中是“宏指令(Repeat macros)”的一种[1] 自定义宏指令 \SetKwRepeat{Do}{do}{while} 定义完之后,就可以在伪代...
\Repeat<text>\Until{<condition>} \Loop<text>\EndLoop \Require<text> \Ensure<text> \Function{<name>}{<params>}\EndFunction \State \Return<text> \Comment{<text>} 另外,还有3个修改algorithm标签,require标签,ensure标签显示的三个命令: \floatname...