【Latex】IEEE的Latex模板中使用algorithm
 发布时间 
 阅读量: 
 阅读量 
在IEEEtran模板中, 仅限于采用图和表的浮动体环境, 并非算法的浮动体环境能够应用.

然而采用`figure浮动体环境后发现算法标题采用了图片样式,并未设置上下三条明显的分隔线而显得不够规范美观。
解决办法是:
在\figure环境中放置一个\algorithm环境,并以 [H]  选项避免 \ algorithm  自动浮动;之后再采用 \ algorithmic  或 \ algorithm2e  环境。
下面提供几个模板
首先,导言区添加
 %for algorithmic.sty
    
 \usepackage{algorithm}
    
 \usepackage{algorithmic}
    
  
    
 % or for algorithmicx.sty
    
 %\usepackage{algorithmicx}
    
 %\usepackage{algpseudocode}
    
  
    
 %\floatname{algorithm}{Protocol} %Customize to your needs
    
 \renewcommand{\algorithmicrequire}{\textbf{Input:}}  % Use Input in the format of Algorithm  
    
 \renewcommand{\algorithmicensure}{\textbf{Output:}} % Use Output in the format of Algorithm 
    
  
    
 \makeatletter
    
 \newcommand{\removelatexerror}{\let\@latex@error\@gobble}
    
 \makeatother

        1. 对于algorithmic.sty 排版样式
 \begin{figure}[!t]
    
     \label{alg:LSB}
    
     \removelatexerror
    
     \begin{algorithm}[H]
    
     \caption{Local Search Based Algorithm}
    
     \begin{algorithmic}[1]
    
         \REQUIRE Candidate set $\mathbb{S}$, Initial set $\mathbb{X} = \varnothing$          %%input
    
         \ENSURE Optimum set $\mathbb{X}$  %%output
    
         \STATE {set $r(t)=x(t)$}  
    
     \end{algorithmic}
    
     \end{algorithm}
    
 \end{figure}

        排版效果

2. 对于algorithmicx.sty 排版样式
 \begin{figure}[!t]
    
   \label{alg:LSB}
    
   \removelatexerror
    
   \begin{algorithm}[H]
    
     \caption{Local Search Based Algorithm}
    
     \begin{algorithmic}[1]
    
       \Require Candidate set $\mathbb{S}$, Initial set $\mathbb{X} = \varnothing$
    
       \Ensure Optimum set $\mathbb{X}$
    
       \State Let $\mathbb{X} \leftarrow r$, if $\widetilde u({v})$ is the maximum over all singletons $r \in \mathbb{S}$.
    
     \end{algorithmic}
    
   \end{algorithm}
    
 \end{figure}

        排版效果

参考
该方法详细说明了如何在IEEEtran类文档中成功集成algorithm2e包以实现浮点运算功能。
<>
如何在IEEE LaTeX模板中使用algorithm
https://www.codenong.com/cs106069328
全部评论 (0)
 还没有任何评论哟~ 
