LaTeX354:latex中algorithm2e包的用法示例

标签:
latexalgorithm2e示例去掉竖线 |
分类: 小技巧 |
QQ群:91940767/145316219/141877998/80300084/194770436
淘宝店:http://latexstudio.taobao.com
技巧续篇:http://latexstudio.net/
常见数学公式问题集下载
\usepackage[linesnumbered,boxed]{algorithm2e}
2.然后正文中添加如下示例:
\begin{algorithm}
\caption{identifyRowContext}
\KwIn{$r_i$ , $Backgrd(T_i)$=${T_1,T_2,\ldots,T_n}$ and similarity threshold $\theta_r$}
\KwOut{$con(r_i)$}
$con(r_i)= \Phi$\;
\For{$j=1;j \le n;j \ne i$}
{
$con(r_i)=con(r_i) \cup {r^{maxSim}}$\;
}
return $con(r_i)$\;
\end{algorithm}
3.效果运行可知。

扩展:
一、如何修改算法的标题为中文“算法”?
\renewcommand{\algorithmcfname}{算法} 即可
二、如何去掉算法中的竖线?
\SetAlgoNoLine 放在算法中即可。
三、若是使用其他标题样式,可以使用:
\usepackage[ruled,vlined]{algorithm2e}
这些默认参数来定制标题,caption宏包并不能对其进行修改。其他样式
参看:http://mirror.bjtu.edu.cn/CTAN/macros/latex/contrib/algorithm2e/algorithm2e.pdf