加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

latex 伪代码:【转载】

(2013-12-26 23:46:54)

原文:http://blog.sina.com.cn/s/blog_5e16f1770100lp7u.html

1.首先添加如下内容:
\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$}
{
 float $maxSim=0$\;
 $r^{maxSim}=null$\;
  \While{not end of $T_j$}
 {
     compute Jaro($r_i,r_m$)($r_m \in T_j$)\;
     \If{$(Jaro(r_i,r_m) \ge \theta _r) \wedge ((Jaro(r_i,r_m) \ge r^{maxSim}) $}
      {
           replace $r^maxSim$ with $r_m$\;
        
 }
$con(r_i)=con(r_i) \cup {r^{maxSim}}$\;
}
return $con(r_i)$\;
\end{algorithm}
3.效果运行可知。
http://s10/middle/5e16f177h91109650f1e9&690
扩展:
一、如何修改算法的标题为中文“算法”?
\renewcommand{\algorithmcfname}{算法} 即可
二、如何去掉算法中的竖线?
\SetAlgoNoLine 放在算法中即可。
三、若是使用其他标题样式,可以使用:
\usepackage[ruled,vlined]{algorithm2e}
这些默认参数来定制标题,caption宏包并不能对其进行修改。其他样式
参看:http://mirror.bjtu.edu.cn/CTAN/macros/latex/contrib/algorithm2e/algorithm2e.pdf

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有