使用Aurora+Algorithm2e在word中输入伪码
准备工作
- 选择插入—对象—Aurora Equation,确定。
- 导入所需库[1]
\makeatletter
\newif\if@restonecol
\makeatother
\let\algorithm\relax
\let\endalgorithm\relax
\usepackage[linesnumbered,ruled]{algorithm2e}%[ruled,vlined]{
\usepackage{algpseudocode}
\usepackage{amsmath}
\renewcommand{\algorithmicrequire}{\textbf{Input:}} % Use Input in the format of Algorithm
\renewcommand{\algorithmicensure}{\textbf{Output:}} % Use Output in the format of Algorithm
语法
if
\If{conditions}{
sentences
}
if-else
\eIf{conditions}{
sentences
}{
else-sentences
}
if-elseif-else
for循环
\For{condition}{
...
}
foreach循环
\lForEach{element $e$ of the line $i$}{\FindCompress{p}}
while循环
\While{not at end of this document}{
a while loop including a repeat--until loop\;
}
begin-end
\Begin{
......
}
带有repeat的while循环
\While{not at end of this document}{
a while loop including a repeat--until loop\;
\Repeat{this end condition}{
do this things\;
}
}
小技巧
-
算法不自动编号
在
\begin{algorithm}
前加上\setcounter{algocf}{1}
-
\Return
好像与\Begin{block}
冲突
未完待续
前五句是防止与其他包冲突 ↩︎
评论