## ACM模板字库未嵌入问题的解决方案

4 Responses » 10,326 Views
302010

Error Font Helvetica-Bold is not embedded (86x)
Error Font Helvetica is not embedded (404x)
Error Font Times-Bold is not embedded (246x)
Error Font Times-Roman is not embedded (427x)
Error Font Times-Italic is not embedded (125x)

dvips -t letter -Pdownload35 -o <file>.ps <file>.dvi

acm给的解释是This option 'forces' the embedding of all the fonts.
(Note: This option is not available in all dvips versions.)


#
# fonts be used from the ps interpreter / printer?
# Whatever the default is, the user can override it by specifying
# the LW35 fonts resp. use the build-in fonts.
#
# Valid settings are true / false:

http://www.ams.org/publications/amsfonts.html

http://www.aifont.com/post/?p=15

http://www.artec.cn/resource/font/2198-font.html

## LaTeX 的对参考文献的处理

No Responses » 36,458 Views
252010
    LaTeX 的对参考文献的处理实在是非常的方便，我用过几次，有些体会，写出来供大家

LaTeX 对参考文献的处理有这么一些优点：

1. 可以维护一个 bib 文件，在你的整个研究生涯可以只维护这样一个文件，就象一个数

@article{MartinDSP00,
author = "A. Martin and M. Przybocki",
title = "The {NIST} 1999 speaker recognition evaluation --- an overview",

journal = "Digital Signal Processing",
volume = "10",
pages = "1--18",
year = "2000",}

其中 {NIST} 中的大括号不会被显示，它的作用是保证将来的生成的参考文献中 NIST
四个字保持原样，不会被小写。

2. 需要引用文献的时候，在正文里加入：

ibliographystyle{ieeetr}
ibliography{myreference}

就可以用 cite{} 来引用文献库中的论文了，如 cite{MartinDSP00}。上面第一行是

3. 编译正文之后，生成 aux 文件，然后用 bibtex 在当前目录生成 bbl 文件，再编译正

ocite 命令，LaTeX 还保证所有列出的参考文

4. 关于 bib 文件
前面提到 bib 文件的维护问题。我一般不对里面的文献排序，如果文献比较多，需要

ex 是不会关心的，就当它不存在。所以我就把文献的关键字写在这里，将来通过搜索关键

ocite{*} 命令，然后

另外，很多 journal（学术期刊）或者 booktitle（国际会议）都是重复的，为了规范

@string(ICASSP = "Proc. of the International Conference on Acoustics, Speech,
and Signal Processing (ICASSP)")

然后

@conference{QL.ICA98,
author = "Qi Li and Biing-Hwang Juang",
title   = "Speaker Verification Using Verbal Information Verification for A
utomatic Enrollment",
booktitle = ICASSP,
year = "1998",}

这样在执行 bibtex 之后，ICASSP 会被替换成它的全称。

5. bib 中的中文文献
中文文献和英文的格式不同，并且使用全角的标点符号，有一点难办。我的解决办法是

@misc{Xie.1995,
note = "谢锦辉，《隐 {Markov} 模型及其在语音处理中的应用》，华中理工大学出

key = "Xie",}

唯一的缺陷是参考文献中最后是以英文的 "." 而不是 "。" 结束的。还好我的中文文

6. 关于参考文献的显示格式、排序，及其他
前面提到参考文献的排序问题，以及引用序号是 LaTeX 提供的 ID 还是数字的问题。

st 格式，可通过 bibliographystyle 命令控制。LaTeX 默认提供了这么几种格式，如：
plain、alpha、unsrt等。具体意义见相关文档，这些 bst 在 texmfibtexstase 可

bst 控制的格式非常细致，除了上面讲过的排序方式等，还有：作者名字是否用缩写，

ion Using ..." 还是 "Speaker verification using "），title 用什么区分（用不用引

给个例子：采用 IEEE 给出的 bst 格式（即 ieeetr.bst），声明：

ibliographystyle{ieeetr}

就可以使用了。最终格式是这样的（按正文引用顺序排序）：
[4] D. A. Reynolds, "Comparison of background normalization
methods for text-independent speaker verication," in
EUROSPEECH, 1997.

7. 如何定制参考文献的显示格式
其实 bst 文件有很多，总能找到自己需要的。如果这些还不能满足，可以通过生成自

，便会进行交互式的 bst 定制过程，具体过程我就不讲了。把生成的自定义的 bst 放到
LaTeX 相应目录下，刷新文件名数据库就可以使用了。



## Latex：表格制作全攻略

8 Responses » 74,806 Views
212010

\begin{table*}

\begin{tabular}{|c|c|c|c|c|}

hline hline

multirow{2}{*}{Multi-Row} & multicolumn{2}{|c|}{Multi-Column} & multicolumn{2}{|c|}{multirow{2}{*{Multi-Row and Col}} \

cline{2-3}

& column-1 & column-2 & multicolumn{2}{|c|}{} \

hline

label-1 & label-2 & label-3 & label-4 & label-5 \

hline

end{tabular}

end{table*}

multicolumn与multicolumn类似，功能是跨多列， multicolumn{2}{|c|}{text}表示跨2行，文字采用中心对齐的方式，text是要写入的文字。

multicolumn和multirow可以组合使用，跨多行多列，只需要将multirow作为multicolumn的text即可。

hline画一整条横线。

multicolumn使用比较简单，因为latex的表格本来就是按行组织的。下面附上multirow的使用文档：

http://www.ctex.org/documents/packages/table/multirow.htm

## LaTeX：Figures, Tables, and Equations

6 Responses » 43,988 Views
132010

## Figures

To insert a figure in a LaTeX document, you write lines like this:

\begin{figure}
\centering
\includegraphics[width=3.0in]{imagefile1}
\caption{Caption for figure}
\label{fig:sample_figure}
\end{figure}


The whole block is enclosed between \begin{figure} and \end{figure}. The command \includegraphics does the actual insertion of the image. Here the file name of the inserted image is imagefile1. If you are using LaTeX to process your document, .eps extension is appended automatically to the file name. If you are using pdfLaTeX, it appends .pdf, .png, or .jpg when searching for the image file.

By default, figures are looked for in the current directory (the one in which your .tex file is located). If you want to specify a path for the \includegraphics command, remember to use forward slashes (/) as directory separators, not backslashes. For example, if your figures are in a sub-directory named “figures” inside the current directory, you write something like this: \includegraphics[width=3.0in]{figures/imagefile1}.

You can also specify the width of the image. The height of the figure is scaled proportionally so the image doesn’t get distorted. Specify the width as a parameter (enclosed in brackets [ ]) to the \includegraphics command. Acceptable measurement units are for example in, mm, and cm. You can make the figure’s width equal to the width of paragraph text lines by using [width=\linewidth], or, for example, three quarters of the text width by using [width=0.75\linewidth].

Here we have used a \centering command to center the figure in the column. The \caption command gives a caption for the figure. We have also added a \label, which is useful when you want to refer to the figure in your text (see References).

Remember to always keep the commands in this order: First \includegraphics, then \caption, and finally \label. This way you get figure references right and captions underneath figures. Additionally, keep the \label and \caption commands always inside the \begin{figure}\end{figure} structure.

You can specify the locations where the figure (or table) is allowed to be placed by using placement parameters. For example, to put a figure at the bottom of page, you type \begin{figure}[b]. To allow a figure to be placed only at the top of page, write \begin{figure}[t]. To allow both locations, use [tb]. Other options are described, for instance, in Chapter 9 of Online tutorials on LaTeX.

If you don’t yet know how to create EPS images for LaTeX documents, read the Creating figures tutorial.

## Subfigures

If you want to divide a figure into many smaller parts, use the \subfigure command. First, you have to add this in the beginning of your .tex file:

\usepackage{subfigure}


Let’s add three small figures in place of one normal figure:

\begin{figure}
\centering
\subfigure[First caption]
{
\includegraphics[width=1.0in]{imagefile2}
\label{fig:first_sub}
}
\\
\subfigure[Second caption]
{
\includegraphics[width=1.0in]{imagefile2}
\label{fig:second_sub}
}
\subfigure[Third caption]
{
\includegraphics[width=1.0in]{imagefile2}
\label{fig:third_sub}
}
\caption{Common figure caption.}
\label{fig:sample_subfigures}
\end{figure}


The result is:

Write as many \subfigure commands as you need. \subfigure takes an argument (enclosed in brackets [ ]) which specifies the caption for that subfigure. You don’t need to write the labels (a), (b), (c), etc., because LaTeX adds them automatically. Then put the \includegraphics and \label commands between { and } of the subfigure. Here we use an image file named imagefile2.eps. We have also specified a width for each image using the optional width parameter of the \includegraphics command.

Note the \\ after the first subfigure. This command creates a line break. In this case, it separates the three subfigures into two rows. Without the \\ all the three subfigures may end up in just one row. You can try the \\ also in other places and see its effect.

Finally, we put one more \caption and \label. These are for the whole three-part figure element.

## Tables

A table in LaTeX may look a bit scary bunch of code at first. But you can copy and paste the basic lines that are needed. Then inserting your own text into the table is a piece of cake. Here we go:

\begin{table}
\renewcommand{\arraystretch}{1.3}
\caption{Simple table}
\label{tab:example}
\centering
\begin{tabular}{c|c}
\hline
\hline
\hline

Three   &   Four\\
\hline

Five    &   Six\\
\hline
\end{tabular}
\end{table}


The result will look like this (using IEEE’s style):

Hence it’s a table with two columns and three rows. Here is how you organize the text in a table: In each table cell write the the text that you want to appear in the cell. Then type & when you want to jump to the next column. A new table row begins when you type \\. You can insert horizontal lines using the command \hline.

Here we have specified the column format like this: \begin{tabular}{c|c}. Every letter c, l, or r denotes a column and | represents a vertical line between columns. c creates a column with centered text, l is for left aligned text, and r for right aligned. Thus, c|c creates two columns with centered text and a vertical line between them.

To get double lines between columns, use || instead of single |. To get no line between columns, omit the |. More columns can be added by using more c, l, or r letters. For example, this produces four columns with no vertical lines: lccc. Now the leftmost column is left aligned and the others are centered.

You may wonder about the strange line \renewcommand{\arraystretch}{1.3}. This is needed for adjusting the white space around text in the table cells. The value 1.3 produces quite a pleasing look.

If you want to have the caption underneath the table, move the \caption and \label lines after the \end{tabular} line. Remember that the \caption command must be before \label.

## Double column figures and tables

If you are writing a two column document and you would like to insert a wide figure or table that spans the whole page width, use the “starred” versions of the figure and table constructs. Like this:

\begin{figure*}
\centering
\includegraphics[width=\textwidth]{imagefile1}
\caption{This is a wide figure}
\label{fig:large}
\end{figure*}


You can use also subfigures inside figure*. An adequate width specifier for a double column figure is width=\textwidth. This makes the figure wide enough to span the whole body width (all columns) of the page.

A double column table is created in a similar way by using \begin{table*} and \end{table*}. Write the contents of the table in the usual way.

Note that double column figures and tables have some limitations. They can’t be placed at the bottom of pages. Additionally, they will not appear on the same page where they are defined. So you have to define them prior to the page on which they should appear.

## Equations

Short mathematical expressions can be inserted within paragraph text by putting the math between $signs. For example: ... angle frequency$\omega = 2\pi f$...  This is called an inline equation. The result is: . In equations, the normal text symbols are written as such, for example 2 and f. Greek symbols are named for example \alpha, \beta and so on. You don’t need to remember these because in WinEdt and TeXnicCenter you can use symbol toolbars, which have buttons for Greek letters and other math symbols. Numbered equations are separate from paragraph text and LaTeX numbers them automatically. The contents are written using the same ideas as inline equations but now we write and instead of$ signs. For example:

$$\label{eq:kinetic_energy} E_{k} = \frac{1}{2}mv^{2}$$


The result is:

Here we learn some structures which are often used in equations: The \frac command creates a fraction. Write the contents of the numerator and denominator inside the curly braces. Subscripts and superscripts are created using _{} and ^{}. (If the content of the subscript or superscript is a single symbol, you can omit the curly braces like this: E_k and v^2.)

Remember that an empty text line produces a paragraph break. Thus, omit empty lines before and after your equations, unless you really need a paragraph break there. This way you can easily explain the meaning of the variables (“where m is the mass and v is…”) so that the word “where” won’t start a new paragraph and won’t become indented.

You can freely type spaces in equations. LaTeX ignores extra spaces and determines automatically where (and how wide) space is needed (for example, on both sides of the = sign). However, line breaks are not allowed. Spaces are needed also to separate LaTeX commands. For instance, if you want to print , you must type \beta A, not \betaA. The latter one won’t compile because LaTeX is looking for a command named betaA.

Occasionally spaces in equations may need some fine adjustment. For example, consider the following two equations:

Equation (1) has been created by simply typing f_{res} = 500 MHz. It seems to have several problems:

• The unit “MHz” and the subscript “res” have an incorrect spacing between letters. This is a common problem in variable names, subscripts, and units that consist of several letters. LaTeX understands “res” as a product of variables r, e, and s. Thus it adds a small space between each multiplicand. To fix the problems, write \mathrm{res} and \mathrm{MHz} . The “mathrm” stands for math “roman” (upright) font style.
• The unit “MHz” and the subscript “res” should be typed with upright font, not italic. The aforementioned \mathrm command fixes this problem. If you, instead, want to use italic font, replace \mathrm with \mathit.
• In equation (1), there is hardly any space between the number and the unit. LaTeX has thought that you want to multiply 500 times “MHz” and thus it removes all spaces you write here. To force a visible space, use command \,.

Here is the final fixed content of the equation, which produces the result (2) as shown above:

f_{\mathrm{res}} = 500 \, \mathrm{MHz}


If you have problems with a long equation that is wider than the space available on the page, you can split your math on several lines like this: First put \usepackage{amsmath} in the beginning of your LaTeX file. Then use \begin{split}...\end{split}:

$$\label{eq:long_equation} \begin{split} F &= a + b + c + d + e + f + g \\ &+ h + i + j + k + l + m \\ &= a + \ldots + m \\ &= 0 \end{split}$$


The result looks like this:

To start a new line in your equation, add \\ to the end of the line. Additionally, put an & before the signs that should be aligned in a straight vertical line. Here we have aligned the = and + symbols.

Like shown above, amsmath can often provide a LaTeX solution to more demanding math problems. See the documentation of amsmath at TeX Catalogue Online or at CTAN.

## LaTex数学宏包汇总集锦

No Responses » 29,199 Views
122010

algorithm2e

Christophe Fiorio

algorithms

Rogério Brito

amsbsy

Frank Mittelbach

amscd

Frank Mittelbach

amscls

AMS

AMSFonts

eucal 可修改 LaTeX 的数学字体命令 \mathcal 。当加载该宏包后，使用 \mathcal 命令，调出的是欧拉书写体，而不是通常的计算机现代书写体。它还有一个 mathscr 选项，使其可与数学字体命令 \mathscr 结合使用。

eufrak 设置了哥特字体，这是一种书写或印刷字体，外观非常华丽，多见于中世纪时的神学文献。如果已加载了 amsfonts 宏包，该宏包就是多余的。

AMS

amsfonts

AMS

AMSLaTeX

1982年，美国数学学会根据其刊物出版要求，委托开发了用于排版数学刊物的 TeX 系统：AMSTeX，1987年又将其移植到 LaTeX，成为 AMSLaTeX。现在它已成为 LaTeX-2e 的一个数学宏包套件。

AMSLaTeX 套件包括有：amsbsyamscd、amsgen、amsmath、amsopn、ams-text、amsxtra、amsthm 、upref 和 amscls 等宏包。

AMS

amsmath

AMS

amsopn

Michael Downes

amssymb

 希腊字母： 其他字母： 各种普通符号: 二元运算符号： 量关系符号： 箭头关系符号： 其他关系符号： 累积符号： 成对界限符号： 单界限符号： 垂直箭头符号： 声调符号： 函数符号：

AMS

amstext

Frank Mittelbach

amsthm

AMS

bm

bm 的是黑体数学符号的英文缩写，该宏包可使数学公式以粗体的方式来显示。它提供一个 \bm{数学式} 命令，在数学模式中，只要把数学符号或数学式置于大括号中就会由粗体来显示。

David Carlisle

calc

TeX 中的算数运算通常是由 \advance 和 \multiply 这样的底层命令来完成的，一般只用来开发新宏包，难以为普通用户所使用。

Kresten Krab Thorup

delarray

David Carlisle

easybmat

Enrico Bertolazzi

eqnarray

Roland Winkler

exscale

Frank Mittelbach

mathdesign

Paul Pichaureau

mathenv

F. Bosisio

mathptmx

Walter Schmidt

mdwmath

Mark Wooding

ntheorem

Wolfgang May

subeqn

Donald Arseneau

subeqnarray

Johannes L. Braams

theorem

Frank Mittelbach

tmmaths

Times；可选用 MicroPress TM-Math 字体编排数学公式；\mathbold 命令可以排印斜粗体字母，包括希腊字母。

Walter Schmidt

vector

vector 宏包定义了一组新命令，用于排版各种式样的向量符号，包括粗体的、带下划线的以及戴帽子的单位向量等，并可成组横\竖排列，成为隐式或显式向量序列。向量符号的字体可以是 boldface roman 或 sans serif ；下划线可以是直线或波浪线。

Nick Efford

yhmath

Yannis Haralambousy

youngtab

Volker Börchers

## 《Word排版艺术》读后感，兼谈LaTeX

1 Response » 15,095 Views
162010

Word 和 LaTeX 都是排版软件，但在我看来，却都不是专业排版软件——尽管用它们可以排出非常专业的效果。我的观点是，所谓专业排版，是指为专门为别人排版。（好比给别人 开车的叫司机，自己驾车代步的则不算）。例如杂志社的美工用 PageMaker 或者 QuarkXpress 排版杂志或海报，或者电路板厂的排线工人用 PowerPCB 或 Allegro 为客户排布印刷电路板，或者半导体厂的排线工人为客户排布集成电路的内部连线。这种专业工作往往只关心形式（排版效果），不关心内容（半导体厂的排线工作 常常不知道自己排布的芯片是做什么用的J）。而 Word 和 LaTeX 设计来都是给作者用的，作者（特别是技术作者）既要关心内容取舍，也要关心版面安排，以求最好地表达自己的想法，利于读者领会吸收。（注：尽管也有人使用 Word或LaTeX专为别人排版，但这毕竟不是这两款软件的设计初衷。）侯捷先生在不同的场合多次提到“作者应该自己排版”这一观点，我非常赞同。国外 很多著名的技术作家如Knuth、Tanenbaum、Stevens等人的书都是自己排版的。

LaTeX是基于TeX的一套宏包（macro packages），而TeX是Knuth教授开发的排版系统。在《The TeX Book》一书的前言中，Knuth用一句话概括了TeX的功能：”(TeX is) a new typesetting system intended for the creation of beautiful books — and especially for books that contain a lot of mathematics.” LaTeX在TeX的基础上大大改善了易用性，也就是说，LaTeX能排成什么样，只用TeX也能排成那样，不过LaTeX用起来方便得多。

Word是一款办公/文字处理软件，非常易用。但“好用”不意味着“用好”，有多少人被本不复杂的版面安排搞得焦头烂额？如果用Word排十来页的文章报 告，是不用看任何Word书籍的，任何问题都可以暴力解决J。不过，如果想充分发挥Word的作用，为文章（书籍）的写作过程带来便利，《Word排版艺 术》是很好（惟一？）的选择。

LaTeX和Word都不适合处理过于复杂的版面，例如报纸、招贴画、复杂的分栏等等，毕竟那是专业排版软件的生存空间。个人感觉Word和LaTeX适合作者用来排版技术书籍和文章，而LaTeX排的版面总体上看更朴素一些，但细微之处处理得更好。

Word在多人协作方面能力更强一些，例如可以追踪修订。另外Word排表格比LaTeX要方便一些。

p.s. 我所谓“正式出版物”，是指要拿给很多人看的那种东西，例如毕业论文、印刷发行的杂志文章、书籍等等。换一种说法是，从用打印机＋复印机印十几二十份到用照排机＋印刷机印几千上万份，都算“正式出版物”。自己留着看的不算，打印一份交给老师的也不算。

《Word排版艺术》一书着眼于“排版”，先介绍排版基础知识，然后介绍Word的“正规军作业模式”以及侯先生自己的“版面美学观”。这是前两章的内容（这部分内容是这本书独有的），可从www.jjhou.com免费下载阅读。这可看作这本书的第一部分。

## Latex：图片及子图排版

No Responses » 32,098 Views
102010

graphics 图形宏包套件主要有两个宏包：早期标准的 graphics 宏包和在其基础上扩展增强的 graphicx 宏包。它们可用以引入外部图形，旋转或缩放文字、图表等等；对不同的DVI 驱动，它们提供了对 EPS、PS、PDF、TIFF 和 JPEG 等图形格式的支持。这两个宏包的功能很相近，提供的命令名称相同，只是参数格式有所不同。目前一般都使用功能较完善的 graphicx。实际上，在调用 graphicx 时，其基础文件 graphics 也自动被加载了。

graphicx 宏包具有多种驱动程序选项，常用的有 dvips、dvipdf 和 pdftex；还有多个功能控制选项，如 draft，为草稿模式，只显示图形的边框及其名称。

graphicx 提供了一组控制命令，其中最常用的是插图命令：

includegraphics[选项]{图形名}，

 选项 说明 angle 图形旋转角度，正值表示逆时针旋转 height 图形高度 width 图形宽度 scale 图形缩放因数
psfrag，在 CJK 和 CCT 等中文环境中，可用该宏包将 EPS 图形中的外文字符替换为相应的中文字符。那些不支持中文输入的绘图软件如 Gauss 等，就可用它来再处理。

egin{figure}[!htbp]

enewcommand{captionlabeldelim}{ }
centering
includegraphics[width=6cm,height=4cm，engle=90]{eps图的名字.eps}
caption{图片标题}
end{figure}

enewcommand{captionlabeldelim}{ }命令用来定义标题的标号后面是空格，而不是“：”。

begin{figure}[!htbp]

enewcommand{captionlabeldelim}{ }
centering
subfigure[子图1]{
label{fig:subfig:a} %% label for first subfigure
includegraphics[width=3.2cm,height=3.5cm]{bian.eps}}
hspace{0.5in}
subfigure[子图2]{
label{fig:subfig:b} %% label for second subfigure
includegraphics[width=3.2cm,height=3.5cm]{jing.eps}}
hspace{0.5in}
subfigure[子图3]{
label{fig:subfig:c} %% label for second subfigure
includegraphics[width=3.2cm,height=3.5cm]{jia.eps}}
caption{大标题}
label{fig:subfig} %% label for entire figure
end{figure}

## 在LaTeX文档中插入图片的几种常用的方法

No Responses » 25,526 Views
102010

LaTeX中一般只直接支持插入eps(Encapsulated PostScript)格式的图形文件, 因此在图片插入latex文档之前应先设法得到图片的eps格式的文件.

1. 用includegraphics宏命令(graphicx包):

usepackage{graphicx}

includegraphics[height=高度]{图片文件名}

includegraphics[height=高度][angle=旋转角度]{图片文件名}
2. 用psfig宏命令:

usepackage{psfig}

psfig{figure=图片文件名,height=高度}

3. 用epsfig宏命令:
epsfig宏命令的使用方法和psfig完全相同, 具体方法是: 首先需在latex文档的文件说明部分加上:

usepackage{epsfig}

epsfig{figure=图片文件名,height=高度}

4. 用epsf宏命令:

usepackage{epsf}

epsfxsize=宽度epsffile{图片文件名}

## LaTex：图片排版

2 Responses » 20,979 Views
102010

%% if you use PostScript figures in your article

%% use the graphics package for simple commands

%% usepackage{graphics}

%% or use the graphicx package for more complicated commands

%% usepackage{graphicx}

%% or use the epsfig package if you prefer to use the old commands

%% usepackage{epsfig}

eps格式图片的排版举例：

%Latex排版之图片排版

begin{figure*}[!htbp]

centering

psfig{file=pic/Ex4-20ga.eps,width=1.5in,origin=br,angle=-90}

psfig{file=pic/Ex4-20gb.eps,width=1.5in,origin=br,angle=-90}

%psfig{file=pic/Ex4-20gc.eps,width=1.5in,origin=br,angle=-90}

caption {Experiment result for uneven data distribution.}

label{fig:ex4}

end{figure*}

## LaTex：算法排版

5 Responses » 62,528 Views
092010

usepackage{algorithm} //format of the algorithm

usepackage{algorithmic} //format of the algorithm

usepackage{multirow} //multirow for format of table

usepackage{amsmath}

usepackage{xcolor}

DeclareMathOperator*{argmin}{argmin} //argmin或argmax公式的排版

enewcommand{algorithmicrequire}{ extbf{Input:}} //Use Input in the format of Algorithm

enewcommand{algorithmicensure}{ extbf{Output:}} //UseOutput in the format of Algorithm

usepackage{graphics}

usepackage{graphicx}

usepackage{epsfig}

\begin{algorithm}[htb] %算法的开始

caption{ Framework of ensemble learning for our system.} %算法的标题

label{alg:Framwork} %给算法一个标签，这样方便在文中对算法的引用

\begin{algorithmic}[1] %这个1 表示每一行都显示数字

REQUIRE ~~\ %算法的输入参数：Input

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 ~~\ %算法的输出：Output

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} %算法的一个陈述，对应算法的一个步骤或公式之类的； 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}

ef{code:fram:extract} of algorithm
ef{alg:Framwork}, we extract $T_n$, a set of reliable negative samples

1、 For和While循环语句的排版举例

（1） 排版效果图

（2）排版代码

\begin{algorithm}[h]

caption{An example for format For & While Loop in Algorithm}

\begin{algorithmic}[1]

FOR{each $iin [1,9]$}

STATE initialize a tree $T_{i}$ with only a leaf (the root);\

STATE $T=Tigcup T_{i};$\

ENDFOR

FORALL {$c$ such that $cin RecentMBatch(E_{n-1})$} label{code:TrainBase:getc}

STATE $T=T cup PosSample(c)$; label{code:TrainBase:pos}

ENDFOR;

FOR{$i=1$; $i<n$; $i++$ }

STATE $//$ Your source here;

ENDFOR

FOR{$i=1$ to $n$}

STATE $//$ Your source here;

ENDFOR

STATE $//$ Reusing recent base classifiers. label{code:recentStart}

WHILE {$(|E_n| leq L_1 )and( D eq phi)$}

STATE Selecting the most recent classifier $c_i$ from $D$;

STATE $D=D-c_i$;

STATE $E_n=E_n+c_i$;

ENDWHILE label{code:recentEnd}

end{algorithmic}

end{algorithm}

 © 2009 - 2016 冰河的博客 | 蜀ICP备16015572号