【Latex学习】在IEEEtran模板中使用algorithm环境

【Latex学习】在IEEEtran模板中使用algorithm环境

参考链接:How to use the algorithm2e package with IEEEtran class?

根据IEEEtran模板的要求,IEEEtran只能使用figuretable环境,而不能使用algorithm环境。

IEEE publications use the figure environment to contain
algorithms that are not to be a part of the main text flow.
Peter Williams’ and Rogerio Brito’s algorithmic.sty package
[26] or Szász János’ algorithmicx.sty package [27] (the latter is
designed to be more customizable than the former) may be of
help in producing algorithm-like structures (although authors
are of course free to use whatever L A TEX commands they are
most comfortable with in this regard). However, do not use
the floating algorithm environment of algorithm.sty (also by
Williams and Brito) or algorithm2e.sty (by Christophe Fiorio)
as the only floating structures IEEE uses are figures and tables.
Furthermore, IEEEtran will not be in control of the (non-IEEE)
caption style produced by the algorithm.sty or algorithm2e.sty
float environments.

可以在\figure环境中调用\algorithm环境并使用[H]取消\algorithm的float属性,然后再使用\algorithmic\algorithm2e环境。

\usepackage{algorithmic}
\usepackage{algorithm}
\makeatletter
\newcommand{\removelatexerror}{\let\@latex@error\@gobble}
\makeatother

\begin{figure}[!t]
  \label{alg:LSB}
  \renewcommand{\algorithmicrequire}{\textbf{Input:}}
  \renewcommand{\algorithmicensure}{\textbf{Output:}}
  \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}$.
      \WHILE {there exists an element $a \in R\backslash S$ such that $\widetilde u(S \cup \left\{ a \right\}) > \left( {1 + \frac{\varepsilon }{{{n^2}}}} \right)\widetilde u(S)$}
      \STATE let $S \leftarrow S \cup \left\{ a \right\}$.
      \ENDWHILE
      \WHILE{there exists an element $a \in S$ such that $\widetilde u(S\backslash \left\{ a \right\}) > \left( {1 + \frac{\varepsilon }{{{n^2}}}} \right)\widetilde u(S)$}
      \STATE let $S \leftarrow S\backslash \left\{ a \right\}$.
      \ENDWHILE
      \STATE Return the maximum of $\widetilde u(S)$ and $\widetilde u(R\backslash S)$, where the local optimal set is $S$ or $R\backslash S$.
    \end{algorithmic}
  \end{algorithm}
\end{figure}
  • 7
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值