Netkiller Document 手札

netkiller Neo Chan, 陈景峰

修订版本 2008-5-24


目录

I. Docbook
1. Document Tools
SGML
XML
xsltproc - XSLT command line processor
2. DOCTYPE
article
book
3. include
4. bookinfo / info
affiliation
address
reference
author
出版紀錄
出版者
5. Part
6. appendix
7. 术语表
8. Paragraphs
para
formalpara
bridgehead
9. Font Formatting Codes
strong
bold
italic
literal
remark
10. Lists
itemizedlist
orderedlist
variablelist
procedure
11. Table
12. Images in DocBook Tools
13. Admonition
caution
important
note
tip
warning
14. literallayout
15. programlisting
16. userinput
17. blockquote
18. TM
19. link
link
ulink
II. Tex
20. Document Tools
latex2html
xetex
tex2page
21. 编码转换
22. 排版
23. 文章的组成元素
24. Fonts
Sizes
Styles
25. 项目符号和编号
26. 表格
27. 图片
28. 分割章节

表格清单

11.1. 表格标题

范例清单

2.1. article
2.2. book
10.1. SimpleList
20.1. example.latex
23.1. article.latex
23.2. book.latex

部分 I. Docbook

第 1 章 Document Tools

Docbook SGML,XML 转换程序

SGML

sudo apt-get install docbook-utils
		

XML

docbook-xsl-1.73.2.tar.gz

docbook-dsssl-1.79.tar.gz

rxp - A validating XML parser

rxp -s file.xml

To validate file.xml, use the command:

$ rxp -s -V file.xml

xsltproc - XSLT command line processor

xsltproc --stringparam html.stylesheet docbook.css ../../docbook-xsl-1.73.2/xhtml/chunk.xsl ../book.xml

$ sudo apt-get install docbook-xsl		
$ export DSSSL=/usr/share/xml/docbook/stylesheet/nwalsh/xhtml/chunk.xsl
$ /usr/bin/xsltproc --stringparam html.stylesheet docbook.css ${DSSSL} ../book.xml

			

第 2 章 DOCTYPE

article

例 2.1. article

			
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.1//EN">

<article>
  <articleinfo>
    <title>An example article</title>

    <author>
      <firstname>Your first name</firstname>
      <surname>Your surname</surname>
      <affiliation>
        <address><email>foo@example.com</email></address>
      </affiliation>
    </author>

    <copyright>
      <year>2000</year>
      <holder>Copyright string here</holder>
    </copyright>

    <abstract>
      <para>If your article has an abstract then it should go here.</para>
    </abstract>
  </articleinfo>

  <sect1>
    <title>My first section</title>

    <para>This is the first section in my article.</para>

    <sect2>
      <title>My first sub-section</title>

      <para>This is the first sub-section in my article.</para>
    </sect2>
  </sect1>
</article>
			
			

book

例 2.2. book

			
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.1//EN">

<book>
  <bookinfo>
    <title>An Example Book</title>

    <author>
      <firstname>Your first name</firstname>
      <surname>Your surname</surname>
      <affiliation>
        <address><email>foo@example.com</email></address>
      </affiliation>
    </author>

    <copyright>
      <year>2000</year>
      <holder>Copyright string here</holder>
    </copyright>

    <abstract>
      <para>If your book has an abstract then it should go here.</para>
    </abstract>
  </bookinfo>

  <preface>
    <title>Preface</title>

    <para>Your book may have a preface, in which case it should be placed
      here.</para>
  </preface>

  <chapter>
    <title>My first chapter</title>

    <para>This is the first chapter in my book.</para>

    <sect1>
      <title>My first section</title>

      <para>This is the first section in my book.</para>
    </sect1>
  </chapter>
</book>
			
			

第 3 章 include

	
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V5.0//EN"
	"http://www.oasis-open.org/docbook/xml/5.0b5/dtd/docbook.dtd" [

	<!ENTITY chapter.database SYSTEM "chapter.database.xml">
]>
<book xml:base="http://netkiller.mefound.com/book/publish/"
	xmlns="http://docbook.org/ns/docbook" xml:lang="zh-cn">
	<info>
		<title>Netkiller Document 手札</title>
		<author>
			<firstname>netkiller</firstname>
			<surname>Neo Chan</surname>
			<affiliation>
				<address>
					<email>openunix(at)163(dot)com</email>
				</address>
			</affiliation>
		</author>
		<copyright>
			<year>2008</year>
			<holder>Copyright netkiller</holder>
		</copyright>
		<releaseinfo>
			<para>修订版本 2008-5-24</para>
		</releaseinfo>

		<abstract>
			<title></title>
			<para></para>
		</abstract>
	</info>

	<preface>
		<title></title>
		<para></para>
	</preface>

	&chapter.database;

</book>	
	
	

chapter.database.xml

	
<chapter>
	<title>Chapter 1</title>
</chapter>
	
	

第 4 章 bookinfo / info

affiliation

		
  <affiliation>
    <shortaffil>IBM</shortaffil>
    <jobtitle>Senior LAMP Engineer</jobtitle>
    <orgname>ArborText, Inc.</orgname>
    <orgdiv>Application Developement</orgdiv>
  </affiliation>		
				
		

address

		
<address>
  <street>162 Guelph Street</street>
  <city>Georgetown</city>
  <state>ON</state>
  <country>Canada</country>
  <postcode>L7G 5X7</postcode>
  <phone>1-888-628-2028</phone>
  <fax>(905) 702-7851</fax>
  <email>info@cogent.ca</email>
  <otheraddr>www.cogent.ca</otheraddr>
</address>		
		
		

reference

		
<reference>
    <title>Reference</title>
    <refentry>
(The content here is shown in the Reference Entries appendix.)
    </refentry>
</reference>
		
		

author

		
<authorgroup>
	<author>
		<FirstName>Bert</FirstName><Surname>Hubert</Surname>
		<affiliation>
	  		<orgname>Netherlabs BV</orgname>
	  		<address><email>bert.hubert@netherlabs.nl</email></address>
		</affiliation>
	</author>

    <collab>
		<collabname>Thomas Graf (Section Author)</collabname>
        <affiliation>
        	<address><email>tgraf%suug.ch</email></address>
		</affiliation>
	</collab>
</authorgroup>		
		
		

出版紀錄

		
  <revhistory>                     <!-- 出版紀錄,可以有很多版本。 -->
    <revision>                     <!-- 某一版本 -->
      <revnumber>1.0.0</revnumber> <!-- 版本編號 -->
      <date>2006-11-14</date>  <!-- 發佈出版日期 -->
      <authorinitials></authorinitials>  <!-- 作者簡稱識別 -->
      <revremark></revremark>  <!-- 版本發佈簡述 -->
    </revision>
  </revhistory>
		
		

出版者

		
<publisher>                      <!-- 出版者 -->
    <publishername>广州市一方信息咨询有限公司</publishername>  <!-- 出版機構名稱 -->
    <address>
        <street>xxx道xxx巷12号204</street>
        <postcode>518000</postcode>
        <city>深圳</city>
        <state>广东</state>
        <country>中国</country>
        <phone>+86 755 xxxxxxxx</phone>
        <fax>+86 755 xxxxxxxx</fax>
        <email>your@domain.com</email>
      </address>
  </publisher>
		
		

第 5 章 Part

	
<part>
	<title>Part</title>
	<chapter>
		<title>Chapter</title>
	</chapter>
	<chapter>
		<title>Chapter</title>
	</chapter>
</part>	

<part>
	<title>Part</title>
	<chapter>
		<title>Chapter</title>
	</chapter>
	<chapter>
		<title>Chapter</title>
	</chapter>
</part>		
	
	

第 6 章 appendix

	
<appendix>
    <title>Appendix One</title>
    <para>Appendix content.</para>
</appendix>
	
	
	

第 7 章 术语表

	
<glossary><title>词汇表的例子</title>
⋮
	<glossdiv><title>E</title>

		<glossentry id="xml"><glossterm>Extensible Markup Language</glossterm>
			<acronym>XML</acronym>
			<glossdef>
			<para>关于XML的定义...</para>
			<glossseealso otherterm="sgml">
			</glossdef>
		</glossentry>

	</glossdiv>
</glossary>
	
	

引用

	
<glossterm linkend="xml">Extensible Markup Language</glossterm> is a new standard…
	
	

第 8 章 Paragraphs

para

		
<para>helloworld</para>		
		
		

formalpara

		
<formalpara>
  <title>A Formal Paragraph</title>
  <para>has a title that appears in bold, and a body paragraph.
  The title paragraph is incorporated into the body paragraph in HTML,
  and is separate in PDF.  The body paragraph is a regular &lt;para&gt;
  paragraph, and there is only one body paragraph allowed per formal
  paragraph.</para>
</formalpara>		
		
		

A Formal Paragraph.  has a title that appears in bold, and a body paragraph. The title paragraph is incorporated into the body paragraph in HTML, and is separate in PDF. The body paragraph is a regular <para> paragraph, and there is only one body paragraph allowed per formal paragraph.

bridgehead

		
<bridgehead renderas="sect3">Topic Heading</bridgehead>
<para>You can use the Bridgehead element to create a heading
between paragraphs, without creating a new section or
sub-section.</para>		
		
		

Topic Heading

You can use the Bridgehead element to create a heading between paragraphs, without creating a new section or sub-section.

第 9 章 Font Formatting Codes

strong

		
<para><emphasis role="strong">Note</emphasis></para>
		
		

Note

bold

		
<emphasis role="bold">text</emphasis>
		
		
text

italic

		
<emphasis role="italic">text</emphasis>
		
		
text

literal

		
<para><literal>literal</literal></para>
		
		

literal

Code

		
<literal role="code">< ! [ CDATA [ code ] ] ></literal>
		
		
code

remark

		
<remark>Some details are still a bit shaky</remark>		
		
		

Some details are still a bit shaky

第 10 章 Lists

calloutlist, glosslist, itemizedlist, listitem, orderedlist, segmentedlist, simplelist, variablelist

itemizedlist

itemizedlist

		
<itemizedlist>
	<listitem><para>item 1</para></listitem>
	<listitem><para>item 2</para></listitem>
	<listitem><para>item 3</para></listitem>
</itemizedlist>
			
		
  • item 1

  • item 2

  • item 3

orderedlist

orderedlist

		
<orderedlist>
	<listitem><para>列表内容 1</para></listitem>
	<listitem><para>列表内容 2</para></listitem>
	<listitem><para>列表内容 3</para></listitem>
</orderedlist>
			
		
  1. 列表内容 1

  2. 列表内容 2

  3. 列表内容 3

例 10.1. SimpleList

			
<para>Here is a <tag>SimpleList</tag>, rendered inline:
<simplelist type='inline'>
<member>A</member>
<member>B</member>
<member>C</member>
<member>D</member>
<member>E</member>
<member>F</member>
<member>G</member>
</simplelist>
</para>
			
			

Here is a SimpleList, rendered inline: A, B, C, D, E, F, G

			
<para>Here is the same <tag>SimpleList</tag> rendered horizontally with
three columns:
<simplelist type='horiz' columns='3'>
<member>A</member>
<member>B</member>
<member>C</member>
<member>D</member>
<member>E</member>
<member>F</member>
<member>G</member>
</simplelist>
</para>
			
			

Here is the same SimpleList rendered horizontally with three columns:

ABC
DEF
G  

			
<para>Finally, here is the list rendered vertically:
<simplelist type='vert' columns='3'>
<member>A</member>
<member>B</member>
<member>C</member>
<member>D</member>
<member>E</member>
<member>F</member>
<member>G</member>
</simplelist>
</para>
			
			

Finally, here is the list rendered vertically:

ADG
BE 
CF 


variablelist

		
<variablelist>
  <title>A variable list</title>
  <varlistentry>
    <term>First term</term>
    <listitem>
      <para>Definition or explanation.</para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>Second term</term>
    <listitem>
      <para>Definition or explanation.</para>
    </listitem>
  </varlistentry>
</variablelist>		
		
		

A variable list

First term

Definition or explanation.

Second term

Definition or explanation.

procedure

procedure

		
<procedure>
  <step>
    <para>Do this.</para>
  </step>

  <step>
    <para>Then do this.</para>
  </step>

  <step>
    <para>And now do this.</para>
  </step>
</procedure>

<procedure>
  <title>A procedure</title>
  <step>
    <para>Step 1.</para>
  </step>
  <step>
    <para>Step 2.</para>
    <substeps>
      <step>
        <para>Substep a.</para>
      </step>
      <step>
        <para>Substep b.</para>
      </step>
    </substeps>
  </step>
  <step>
    <para>Step 3.</para>
  </step>
</procedure>
		
		
  1. Do this.

  2. Then do this.

  3. And now do this.

过程 10.1. A procedure

  1. Step 1.

  2. Step 2.

    1. Substep a.

    2. Substep b.

  3. Step 3.

第 11 章 Table

	
<table>
   <title>表格标题</title>
   <tgroup cols="2">
     <thead>
       <row>
          <entry>列标题1</entry>
          <entry>列标题2</entry>
       </row>
     </thead>
    <tbody>
       <row>
          <entry>列内容1</entry>
          <entry>列内容2</entry>
       </row>
       ...
    </tbody>
   </tgroup>
</table>
		
	

表 11.1. 表格标题

列标题1列标题2
列内容1列内容2

第 12 章 Images in DocBook Tools

	
<figure>
 <title>My Image</title>
 <screenshot>
  <screeninfo>Sample GNOME Display</screeninfo>
  <graphic  format="png" fileref="myfile" srccredit="me">
  </graphic>
 </screenshot>
</figure>
	
	

第 13 章 Admonition

caution, important, note, tip, warning

caution

		
<para><caution>Text goes here.</caution></para>		
		
		

小心

Text goes here.

important

		
<para><important>Text goes here.</important></para>		
		
		

重要

Text goes here.

note

		
<para><note>Text goes here.</note></para>		
		
		

注意

Text goes here.

tip

		
<para><tip>Text goes here.</tip></para>		
		
		

提示

Text goes here.

warning

		
<para><warning>Text goes here.</warning></para>		
		
		

警告

Text goes here.

第 14 章 literallayout

	
<literallayout>
1
2
3
</literallayout>
	
	

第 15 章 programlisting

	
<programlisting role="c">
#include &lt;stdio.h&gt;

int
main(void)
{
    printf("hello, world\n");
}
</programlisting>
	
	

第 16 章 userinput

ls -l $KDEDIR

	
<userinput><command>ls</command>
<option>-l</option>
<parameter>$<envar>KDEDIR<envar></parameter>
</userinput>
	
	

export $KDEDIR=/usr/local/kde

	
<userinput>
<command>export</command>
<parameter>$<envar>KDEDIR</envar>=<filename>
/usr/local/kde</filename></parameter></userinput>
	
	

第 17 章 blockquote

	
 <blockquote>
    <para>
      This text should be indented.
    </para>
</blockquote>
	
	

This text should be indented.

第 18 章 TM

	
<trademark>Microsoft</trademark>
	
	


Microsoft

第 19 章 link

目录

link
ulink

link

		
<link linkend="table">Table</link>
<link linkend="article-My-Article-sec"><quote>sec</quote></link>
				
		
Table font

ulink

		
<ulink url="http://netkiller.hikz.com">homepage</ulink>		
		
		

部分 II. Tex

第 20 章 Document Tools

CJK

$ sudo apt-get install texlive cjk-latex freetype1-tools
$ sudo apt-get install latex-cjk-all
$ sudo mkdir -p  /usr/share/texmf/fonts/tfm /usr/share/texmf/fonts/truetype
		

例 20.1. example.latex

\documentclass{article}
\usepackage{CJK}
\begin{document}
\begin{CJK*}{UTF8}{simsun}
中文
\end{CJK*}
\end{document}
			

生成html文件

latex2html -split 0 example.latex
			

Fonts

neo@master:~$ cd /usr/share/fonts/		
neo@master:/usr/share/fonts$ cp -r /home/neo/Fonts .
neo@master:/usr/share/fonts$ sudo cp -r /home/neo/Fonts .

neo@master:/usr/share/fonts$ cd Fonts/
neo@master:/usr/share/fonts/Fonts$ sudo mkfontscale
neo@master:/usr/share/fonts/Fonts$ sudo mkfontdir
neo@master:/usr/share/fonts/Fonts$ sudo fc-cache
		

latex2html

install latex2html

sudo apt-get install latex2html
			

latex2html charset='utf-8'

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">

latex2html -html_version 4.0,gb18030,unicode index.latex
			

Icons

latex2html -local_icons index.latex
			

xetex

http://scripts.sil.org/xetex

$ sudo apt-get install texlive-xetex lmodern		
			

test.tex

\documentclass[12pt,a4paper]{article}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\setromanfont{AR PL ShanHeiSun Uni}
\begin{document}
\XeTeX 可以使用系统自带的字体,而不需要再另外生成。
\end{document} 			
			

xelatex a.tex

tex2page

install tex2page

sudo apt-get install mzscheme
			

reference http://docs.huihoo.com/homepage/shredderyin/tex2page/intro.html

第 21 章 编码转换

gb2312转utf-8

		
for f in `find .`; do [ -f $f ] && perl -MEncode -pi -e '$_=encode_utf8(decode(gb2312=>$_))' $f; done;
		
		

第 22 章 排版

选择A4纸

\documentclass[a4paper,12pt]{book}
			

设置页边距

Word中默认的页边距为 上边距=2.54cm, 下边距=2.54cm, 左边距=3.17cm, 右边距=3.17cm

\usepackage[top=1in,bottom=1in,left=1.25in,right=1.25in]{geometry}
			

我的习惯 2cm

\usepackage[top=20mm,bottom=20mm,left=20mm,right=20mm]{geometry}
			

第 23 章 文章的组成元素

标题

\title{文章的题目}
\author{作者姓名}
\date{2005/09/23}
\maketitle
			

abstract

\begin{abstract}
	put your abstract here...
\end{abstract}

			

目录

\tableofcontents
			

章节

\chapter{章的名称}
\section{节的名称}
\subsection{小节的名称}
\subsubsection{子节的名称}
			

索引

\printindex
			

参考文献

\begin{thebibliography}
\bibitem{}参考文献1
\bibitem{}参考文献2
\end{thebibliography}
			

例 23.1. article.latex

% This is a comment line

\documentclass{article}

\begin{document}

% Note to self:
%    I must change this title later!
\title{Hello World}

\author{Your Name\\
	Department of Computer Science\\
	Courant Institute, NYU}
\maketitle

\begin{abstract}
	...put your abstract here...
\end{abstract}

\section{First Section}
	...text...
\subsection{First subsection}
	...text...
\subsection{Second subsection}
	...text...
\section{Second Section}
	...text...

...and so on...
\end{document}
				

例 23.2. book.latex

% This is a comment line

\documentclass{article}

\begin{document}

% Note to self:
%    I must change this title later!
\title{Hello World}

\author{Your Name\\
	Department of Computer Science\\
	Courant Institute, NYU}
\maketitle

\begin{abstract}
	...put your abstract here...
\end{abstract}

\chapter{First Chapter}
	...text...
\section{First Section}
	...text...
\subsection{First subsection}
	...text...
\subsection{Second subsection}
	...text...

\chapter{Second Chapter}
	...text...
\section{Second Section}
	...text...

...and so on...
\end{document}
				

第 24 章 Fonts

you can have bold font, italics font, etc as follows:

{\bf This is in bold} and
{\it this is in italics}
and this is in default roman
{\rm as is this}.
			

Sizes

\tiny
\scriptsize
\footnotesize
\small
\normalsize
\large
\Large
\LARGE
\huge
\Huge
				

Styles

Here is a simple example that will probably show you all you need to know about bold, italics, and underlining.

When something is \emph{really}, \textbf{really} important, you can \underline{underline it}, \emph{italicize it}, \textbf{bold it}. If you \underline{\textbf{\emph{must do all three}}}, then you can nest them.
				

第 25 章 项目符号和编号

项目符号

\begin{itemize}
\item 我的第一个项目
\item 我的第二个项目
\item 我的第三个项目
\end{itemize}
			

项目编号

\begin{enumerate}
\item 我的第一个项目
\item 我的第二个项目
\item 我的第三个项目
\end{enumerate}
			

修改 \enumerate 的编号格式

\usepackage{enumerate}

然后enumerate环境就可以使用一个可选参数,像这样:

\begin{enumerate}[(a)]
\item $(p\rightarrow(q\rightarrow p))$;
\item $((q\lor r)\rightarrow((\neg r)\rightarrow q))$;
\end{enumerate}

[]里面的 (a) 出来的结果是 (a)(b)(c)(d)这样子的。还可以用如下的:
1,得到1,2,3,4....
i,得到i,ii,iii.....
I,得到I,II,III....
a,得到a,b,c,d.....
A,得到A,B,C,D....

还可以加各种修饰,比如
[Exer. i],得到 Exer. i,Exer. ii,Exer. iii, Exer. iv,等等

你要的这种结果稍微麻烦一点,要把[]用花括号括起来
\begin{enumerate}[{[}1{]}]
\item $(p\rightarrow(q\rightarrow p))$;
\item $((q\lor r)\rightarrow((\neg r)\rightarrow q))$;
\end{enumerate}
			

无符号

\begin{description}
\item 我的第一个项目
\item 我的第二个项目
\item 我的第三个项目
\end{description}

\begin{description}
\item[(a)] First item...
\item[(b)] Second item...
\end{description}

			

第 26 章 表格

使用tabular 环境可以生成表格,见下面这个例子:


\begin{tabular}{|c|c|c|c|c|c|}
\hline\\
编号 & 姓名 & 性别 & 年龄 & 地址 & 电话号码\\
\hline\\
1    & 张三 & 男 & 45 & 重庆工学院 &12345678\\
\hline\\
2 & 李四 & 女 & 29 & 重庆杨家坪 & 654321\\
\hline
\end{tabular}

			

这里要注意了,我们在第一行中,有几个 c 就表示有几列, c 表示你的列是居中对齐的,如果你想居左或居右,请用 l 或 r 。 如果你的某行中的某一列是空的,你也要列出来,放个空格在那里就行了,你甚至可以什么都不放,在要空的那里前后各放一个 & 符号就行。 在这里看到,对齐是用& 来实现的,我们前面说过。竖线是用 c 两边的那些竖杠实现的,横线是用命令\hline来实现的。如果你不想要这些线,你可以把它们去掉。

第 27 章 图片

\documentclass[12pt]{article} 下面加入

\usepackage{graphicx}
			

插入图片

\includegraphics[width=0.8\textwidth]{fig1.eps}
			

第 28 章 分割章节

main.tex

\documentclass{article}
\usepackage{amsmath}
\usepackage{CJK}
\begin{document}
\begin{CJK*}{GBK}{song}

\input{sec1.tex}
\include{sec2.tex}
\end{CJK*}
			

sec1.tex

\section{第一节}
恭承嘉惠兮,俟罪长沙。侧闻屈原兮,自沉汩罗。造托湘流兮,敬吊先生。
			

sec2.tex

\section{第一节}
贾生名谊,洛阳人也。年十八,以能诵诗属书闻于郡中。