作为一名计算机专业的学生,在写学术论文的时候,不可避免的需要在论文中书写相关的算法。如果自己一点点调格式,可能会比较麻烦,而且显得非常不专业。在Latex中用相关的算法包,可以格式化我们的算法模块。
方式1
方式3
latex 写algorithm的方法:algorithm排版可能需要的套件
\documentclass[journal]{IEEEtran}
\usepackage{algorithm}
%\usepackage{algorithmic}
\usepackage{algpseudocode}
\usepackage{amsmath}
\usepackage{graphics}
\usepackage{epsfig}
其中algorithmic在compile时会出现错误
! LaTex Error: Command \algorithm already defined.
Or name \end... illegal, see p.192 of the manual
原因不是很清楚,所以只好先mark掉.
在算法中显示Input 和Output 关键字:
\renewcommand{\algorithmicrequire}{\textbf{Input:}} % Use Input in the format of Algorithm
\renewcommand{\algorithmicensure}{\textbf{Output:}} % Use Output in the format of Algorithm
样式1:
\begin{algorithm}[htb]
\caption{ Framework of ensemble learning for our system.}
\label{alg:Framwork}
\begin{algorithmic}[1]
\Require
The set of positive samples for current batch, $P_n$
The set of unlabelled samples for current batch, $U_n$
Ensemble of classifiers on former batches, $E_{n-1}$
\Ensure
Ensemble of classifiers on the current batch, $E_n$
\State Extracting the set of reliable negative and/or positive samples $T_n$ from $U_n$ with help of $P_n$
\label{code:fram:extract}
\State Training ensemble of classifiers $E$ on $T_n \cup P_n$, with help of data in former batches
\label{code:fram:trainbase}
\State $E_n=E_{n-1}cup E$
\label{code:fram:add}
\State Classifying samples in $U_n-T_n$ by $E_n$
\label{code:fram:classify}
\State Deleting some weak classifiers in $E_n$ so as to keep the capacity of $E_n$
\label{code:fram:select} \\
\Return $E_n$
\end{algorithmic}
\end{algorithm}
\begin{minipage}{.45\textwidth}...
\end{minipage}
\begin{minipage}{.45\textwidth}
...
\end{minipage}
这样就能把内容排版在一行内。
注意两个 minipage 之间不能有空格。
如果你觉得对不齐,可以加一个 \hfill 什么的。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)