Netkiller Docbook 手札

Docbook, EPUB and Latex

Mr. Neo Chan, 陈景峰(BG7NYT)

中国广东省深圳市龙华新区民治街道溪山美地
518131
+86 13113668890
+86 755 29812080
<netkiller@msn.com>

文档始创于2008-5-24

版权 © 2008, 2009, 2010, 2011, 2012, 2013 Netkiller(Neo Chan). All rights reserved.

版权声明

转载请与作者联系，转载时请务必标明文章原始出处和作者信息及本声明。
文档出处:
http://netkiller.github.io
http://netkiller.sourceforge.net

$Date: 2013-04-10 15:03:49 +0800 (Wed, 10 Apr 2013) $

我的系列文档

Netkiller Architect 手札 | Netkiller Developer 手札 | Netkiller PHP 手札 | Netkiller Python 手札 | Netkiller Testing 手札 | Netkiller Cryptography 手札
Netkiller Linux 手札 | Netkiller CentOS 手札 | Netkiller FreeBSD 手札 | Netkiller Security 手札 | Netkiller Version 手札 | Netkiller Web 手札
Netkiller Monitoring 手札 | Netkiller Storage 手札 | Netkiller Mail 手札 | Netkiller Shell 手札 | Netkiller Network 手札 | Netkiller Database 手札
Netkiller PostgreSQL 手札 | Netkiller MySQL 手札 | Netkiller NoSQL 手札 | Netkiller LDAP 手札 | Netkiller Cisco IOS 手札 | Netkiller H3C 手札
Netkiller Multimedia 手札 | Netkiller Docbook 手札 | Netkiller 开源软件 手札 |  |  |

您可以使用iBook阅读当前文档

QQ群：128659835 请注明“读者”

目录

自述
1. 系列文档
2. 作者简介
3. 写给读者
I. Docbook
1. Open Document Licenses
2. Document Tools
2.1. SGML
2.2. XML 转换
2.2.1. xsltproc - XSLT command line processor
2.2.2. docbook-ebnf - EBNF module for the XML version of the DocBook DTD
2.2.3. docbook-xsl-saxon
2.3. XML 校验
2.4. PDF
2.5. CHM
2.6. docbook2odf - Convert docbook document to Oasis Open Document
2.7. docbook-website - XML Website DTD and XSL Stylesheets
2.8. EPUB
2.8.1. 创建.epub文件
2.8.2. Reader
3. DOCTYPE
3.1. SYSTEM
3.2. Docbook参数
3.2.1. 字符集
3.2.2. Filename prefix
3.3. DTD 引用
3.3.1. 引用本地DTD
3.3.2. oasis-open.org
3.4. article
3.5. book
3.6. include
3.7. Docbook HTML 输出选项
3.7.1. 指定多页输出时html文档名
3.7.2. 指定输出路径
3.7.3. 包含HTML文件
3.7.4. 包含HTML节点
3.7.5. 图标
3.7.6. dbhtml-include
4. book / article
4.1. info
4.1.1. affiliation
4.1.2. address
4.1.3. reference
4.1.4. author
4.1.5. 出版信息
4.1.6. copyright
4.1.7. keyword
4.1.8. dedication
4.1.9. abstract
4.1.10. legalnotice
5. preface
6. Part / Chapter / Section
6.1. part
6.2. chapter
6.2.1. chapterinfo
6.2.2. epigraph
6.3. section
6.4. title
6.4.1. subtitle
6.4.2. titleabbrev
7. appendix
8. 术语表 glossary
9. Paragraphs
9.1. para
9.2. simpara
9.3. formalpara
9.4. bridgehead
9.5. blockquote
9.6. sidebar
9.7. TM 商标
9.8. epigraph 题词
9.9. Font Formatting Codes
9.9.1. strong
9.9.2. bold
9.9.3. italic
9.9.4. literal
9.9.5. remark
10. Lists 项目符号与编号
10.1. itemizedlist
10.2. orderedlist
10.3. simplelist
10.4. variablelist
10.5. segmentedlist
10.6. procedure 过程
10.7. question/answer 问答
10.8. glosslist 注解
11. Table
12. Images
12.1. figure
12.2. mediaobject
12.3. screenshot
13. Admonition
13.1. caution
13.2. important
13.3. note
13.4. tip
13.5. warning
14. Computer terminal
14.1. literallayout
14.2. programlisting
14.2.1. Callouts
14.3. userinput
14.4. Keyboard Input
15. Cross references
15.1. link
15.2. ulink
15.3. xreflabel / xref
16. The DocBook HTML Forms Document Type
II. Tex
17. Document Tools
17.1. texlive - TeX Live: A decent selection of the TeX Live packages
17.2. latex2html
17.3. texi2html
17.4. XeTeX
17.4.1. install usage apt-get
17.4.2. test.tex
17.5. LuaTeX
17.6. tex2page
17.7. CJK
17.8. TeXstudio(LaTeX 编辑器)
18. 编码转换
19. 排版
20. 文章的组成元素
21. Fonts
21.1. Sizes
21.2. Styles
22. 项目符号和编号
23. 表格
24. 图片
25. 分割章节
26. Markdown
26.1. Section
26.2. Lists
27. Sphinx
28. pandoc - general markup converter
28.1. Docbook to Markdown
29. 写作团队的运作
29.1. Docbook 环境初始化
29.1.1. FreeBSD
29.1.2. Ubuntu/Debian
29.2. Subversion 版本控制
29.3. GIT

表格清单

11.1. 表格标题

范例清单

3.1. article
3.2. book
10.1. SimpleList
17.1. example.latex
20.1. article.latex
20.2. book.latex


自述

目录

1. 系列文档
2. 作者简介
3. 写给读者

目前技术书籍的价格一路飙升，动则80，100，少则50，60. 技术书籍有时效性，随着技术的革新或淘汰，大批书记成为废纸垃圾。并且这些书技术内容雷同，相互抄袭，质量越来越差，甚至里面给出的例子错误百出，只能购买影印版，或者翻译的版本。

在这种背景下我便萌生了自己写书的想法，资料主要来源是我的笔记与例子。我并不想出版，只为分享，所有我制作了基于CC License 发行的系列电子书。

本书注重例子，少理论，只要你对这例子一步一步操作，就会成功，会让你有成就感并能坚持学下去，因为很多人遇到障碍就会放弃，其实我就是这种人，只要让他看到希望，就能坚持下去。

为什么写这篇文章

有很多想法,工作中也用不到所以未能实现，所以想写出来,和大家分享.有一点写一点,写得也不好,只要能看懂就行,就当学习笔记了.

开始零零碎碎写过一些文档，也向维基百科供过稿，但维基经常被ZF封锁，后来发现sf.net可以提供主机存放文档，便做了迁移。并开始了我的写作生涯。

这篇文档是作者10年来对工作的总结,是作者一点一滴的积累起来的，有些笔记已经丢失，所以并不完整。

因为工作太忙整理比较缓慢。目前的工作涉及面比较窄所以新文档比较少。

我现在花在技术上的时间越来越少，兴趣转向摄影，无线电。也想写写摄影方面的心得体会。

写作动力:

曾经在网上看到外国开源界对中国的评价，中国人对开源索取无度，但贡献却微乎其微.这句话一直记在我心中，发誓要为中国开源事业做我仅有的一点微薄贡献

另外写文档也是知识积累，还可以增加在圈内的影响力.

人跟动物的不同,就是人类可以把自己学习的经验教给下一代人.下一代在上一代的基础上再创新,不断积累才有今天.

所以我把自己的经验写出来,可以让经验传承

没有内容的章节:

目前我自己一人维护所有文档，写作时间有限，当我发现一个好主题就会加入到文档中，待我有时间再完善章节，所以你会发现很多章节是空无内容的.

文档目前几乎是流水帐试的写作，维护量很大，先将就着看吧.

我想到哪写到哪,你会发现文章没一个中心,今天这里写点,明天跳过本章写其它的.
文中例子绝对多,对喜欢复制然后粘贴朋友很有用,不用动手写,也省时间.
理论的东西,网上大把,我这里就不写了,需要可以去网上查.
我爱写错别字,还有一些是打错的,如果发现请指正.
文中大部分试验是在Debian/Ubuntu/Redhat AS上完成.

1. 系列文档

下面是我多年积累下来的经验总结，整理成文档供大家参考:

HTML 格式

http://netkiller.github.com/home/technology.html

http://netkiller.sourceforge.net/home/technology.html

PDF 格式

Download PDF Document 下载PDF文档1

Download PDF Document 下载PDF文档2

EPUB 格式

http://netkiller.sourceforge.net/technology.html

通过 GIT 镜像整个网站

https://github.com/netkiller/netkiller.github.com.git

$ git clone https://github.com/netkiller/netkiller.github.com.git

其他方式

获得光盘介质，RPM包，DEB包，如有特别需要，请联系我


2. 作者简介

陈景峰 (ㄔㄣ ㄐ丨ㄥ ㄈㄥ)

Nickname：netkiller | English name: Neo chen | Nippon name: ちんけいほう (音訳) | Korean name: 천징봉 | Thailand name: ภูมิภาพภูเขา

Callsign: BG7NYT | QTH: ZONE CQ24 ITU44 ShenZhen, China

程序猿，攻城狮，挨踢民工， UNIX like Evangelist, 业余无线电爱好者（呼号：BG7NYT）,户外运动，山地骑行以及摄影爱好者。

《Netkiller 系列 手札》的作者

1981年1月19日(庚申年腊月十四)出生于黑龙江省青冈县建设乡双富大队第一小队

1989年9岁随父母迁居至黑龙江省伊春市

1996年第一次接触UNIX操作系统，BSD UNIX, Microsoft Xinux(盖茨亲自写的微软Unix，知道的人不多)

1997年第自学BASIC语言，Turbo C语言，苦于没有电脑，后来学校建了微机室才第一次使用QBASIC(DOS 6.22 自带命令)，那个年代只能通过软盘拷贝转播Trubo C编译器始终没有搞到，

1997年第一次上Internet网速只有9600Bps, 当时全国兴起各种信息港域名格式是www.xxxx.info.net, 访问的第一个网站是NASA下载了很多火星探路者拍回的照片，还有“淞沪”sohu的前身

1998~2000年在哈尔宾学习计算机，充足的上机时间，但老师让我们练打字（明伦五笔/WT）打字不超过80个/每分钟还要强化训练，不过这个给我的键盘功夫打了好底。

1999年学校的电脑终于安装了光驱，在一张工具盘上终于找到了Turbo C与Quick Basic编译器，当时对VGA图形编程非常感兴趣，通过INT33中断控制鼠标，使用绘图函数模仿windows界面。还有操作 UCDOS 中文字库，绘制矢量与点阵字体。

2000年沉迷于Windows NT与Back Office各种技术，神马主域控制器，DHCP，WINS，IIS，域名服务器，Exchange邮件服务器，MS Proxy, NetMeeting...以及ASP+MS SQL开发

职业生涯

2001年来深圳进城打工,成为一名外来务工者. 在一个4人公司做PHP开发，当时PHP的版本是2。0, 开始使用Linux Redhat 6.2.当时很多门户网站都是用FreeBSD,但很难搞到安装盘，在网易社区认识了一个网友,从广州给我寄了一张光盘，FreeBSD 3.2

2002年我发现不能埋头苦干,还要学会"做人".同住辗转广州工作了半年。

2003年这年最惨,公司拖欠工资16000元,打过两次官司2005才付清.

2004年开始加入分布式计算团队,目前成绩

2004-10月开始玩户外和摄影

2005-6月成为中国无线电运动协会会员,呼号BG7NYT,进了一部Yaesu FT-60R手台。

2006年单身生活了这么多年,终于找到归宿.

2007物价上涨,金融危机，休息了4个月（其实是找不到工作）,关外很难上439.460中继，搞了一台Yaesu FT-7800.

2008终于找到英文学习方法，， 《Netkiller Developer 手札》，《Netkiller Document 手札》

2008-8-8 08:08:08 结婚,后全家迁居湖南省常德市

2009《Netkiller Database 手札》,年底拿到C1驾照

2010对电子打击乐产生兴趣，计划学习爵士鼓

2011 平凡的一年，户外运动停止，电台很少开，中继很少上，摄影主要是拍女儿与家人，年末买了一辆山地车

2012 对油笔画产生了兴趣，活动基本是骑行银湖山绿道，

2013开始学习民谣吉他，同时对电吉他也极有兴趣；最终都放弃了。这一年深圳开始推数字中继2013-7-6日入手Motorola MOTOTRBO XIR P8668

职业生涯路上继续打怪升级

联系作者

http://netkiller.github.io/

http://netkiller.sourceforge.net/

Mobile: +86 13113668890

Tel: +86 755 2981-2080

Callsign: BG7NYT QTH: Shenzhen, China

注：请不要问我安装问题！

Email: netkiller@msn.com

MSN: netkiller@msn.com

ICQ: 101888222

QQ: 13721218

Yahoo/AIM/GTalk: bg7nyt

IRC: irc://irc.freenode.net /nickname netkiller or neo

CQ CQ CQ DE BG7NYT

写给火腿:

欢迎无线电爱好者和我QSO,我的QTH在深圳宝安区龙华镇溪山美地12B7CD,设备YAESU FT-50R,FT-60R,FT-7800 144-430双段机, ,拉杆天线/GP天线 Nagoya MAG-79EL-3W/Yagi

如果这篇文章对你有所帮助,请寄给我一张QSL卡片,qrz.cn or qrz.com or hamcall.net

Personal Amateur Radiostations of P.R.China

ZONE CQ24 ITU44 ShenZhen, China

Best Regards, VY 73! OP. BG7NYT

Blogger

Twitter: http://twitter.com/bg7nyt

Digg: http://www.digg.com/netkiller

Facebook: https://www.facebook.com/bg7nyt

LinkedIn: http://cn.linkedin.com/in/netkiller

Flickr: http://www.flickr.com/photos/bg7nyt/

Disqus: http://disqus.com/netkiller/

solidot: http://solidot.org/~netkiller/

ITEYE: http://netkiller-github-com.iteye.com

51CTO: http://bg7nyt.blog.51cto.com/|http://g.51cto.com/netkiller

pengyou: http://www.pengyou.com/netkiller

weibo: http://weibo.com/bg7nyt

163 Blog: http://t.163.com/netkiller

Mailing List

http://groups.google.com/group/netkiller

Send email to this group: netkiller@googlegroups.com

RSS http://groups.google.com/group/netkiller/feed/rss_v2_0_topics.xml?num=50


3. 写给读者

写给读者

欢迎提出宝贵的建议,如有问题请到 邮件列表 讨论

至读者：
我不知道什么时候，我不再更新文档或者退出IT行业去从事其他工作，我必须给这些文档找一个归宿，让他能持续更新下去。
我想捐赠给某些基金会继续运转，或者建立一个团队维护它。
我用了10年时间坚持不停地写作，持续更新，才有今天你看到的《Netkiller 手扎》系列文档，在中国能坚持10年，同时没有任何收益的技术类文档，是非常不容易的。
有很多时候想放弃，看到外国读者的支持与国内社区的影响，我坚持了下来。
中国开源事业需要各位参与，不要成为局外人，不要让外国人说：中国对开源索取无度，贡献却微乎其微。
我们参与内核的开发还比较遥远，但是进个人能力，写一些文档还是可能的。


部分 I. Docbook

目录

1. Open Document Licenses
2. Document Tools
2.1. SGML
2.2. XML 转换
2.2.1. xsltproc - XSLT command line processor
2.2.2. docbook-ebnf - EBNF module for the XML version of the DocBook DTD
2.2.3. docbook-xsl-saxon
2.3. XML 校验
2.4. PDF
2.5. CHM
2.6. docbook2odf - Convert docbook document to Oasis Open Document
2.7. docbook-website - XML Website DTD and XSL Stylesheets
2.8. EPUB
2.8.1. 创建.epub文件
2.8.2. Reader
3. DOCTYPE
3.1. SYSTEM
3.2. Docbook参数
3.2.1. 字符集
3.2.2. Filename prefix
3.3. DTD 引用
3.3.1. 引用本地DTD
3.3.2. oasis-open.org
3.4. article
3.5. book
3.6. include
3.7. Docbook HTML 输出选项
3.7.1. 指定多页输出时html文档名
3.7.2. 指定输出路径
3.7.3. 包含HTML文件
3.7.4. 包含HTML节点
3.7.5. 图标
3.7.5.1. Admonition graphics
3.7.5.2. 导航图标
3.7.5.3. Callout icons
3.7.6. dbhtml-include
4. book / article
4.1. info
4.1.1. affiliation
4.1.2. address
4.1.3. reference
4.1.4. author
4.1.4.1. contrib
4.1.4.2. affiliation
4.1.4.3. editor
4.1.4.4. othercredit
4.1.5. 出版信息
4.1.5.1. publisher
4.1.5.2. printhistory
4.1.5.3. 出版紀錄
4.1.6. copyright
4.1.7. keyword
4.1.8. dedication
4.1.9. abstract
4.1.10. legalnotice
5. preface
6. Part / Chapter / Section
6.1. part
6.2. chapter
6.2.1. chapterinfo
6.2.2. epigraph
6.3. section
6.4. title
6.4.1. subtitle
6.4.2. titleabbrev
7. appendix
8. 术语表 glossary
9. Paragraphs
9.1. para
9.2. simpara
9.3. formalpara
9.4. bridgehead
9.5. blockquote
9.6. sidebar
9.7. TM 商标
9.8. epigraph 题词
9.9. Font Formatting Codes
9.9.1. strong
9.9.2. bold
9.9.3. italic
9.9.4. literal
9.9.5. remark
10. Lists 项目符号与编号
10.1. itemizedlist
10.2. orderedlist
10.3. simplelist
10.4. variablelist
10.5. segmentedlist
10.6. procedure 过程
10.7. question/answer 问答
10.8. glosslist 注解
11. Table
12. Images
12.1. figure
12.2. mediaobject
12.3. screenshot
13. Admonition
13.1. caution
13.2. important
13.3. note
13.4. tip
13.5. warning
14. Computer terminal
14.1. literallayout
14.2. programlisting
14.2.1. Callouts
14.3. userinput
14.4. Keyboard Input
15. Cross references
15.1. link
15.2. ulink
15.3. xreflabel / xref
16. The DocBook HTML Forms Document Type

http://www.docbook.org/

http://docbook.org/tdg51/en/html/docbook.html


第 1 章 Open Document Licenses

Creative Commons Attribution 3.0

GNU Free Documentation License

Open Publication License

The FreeBSD Documentation License


第 2 章 Document Tools

目录

2.1. SGML
2.2. XML 转换
2.2.1. xsltproc - XSLT command line processor
2.2.2. docbook-ebnf - EBNF module for the XML version of the DocBook DTD
2.2.3. docbook-xsl-saxon
2.3. XML 校验
2.4. PDF
2.5. CHM
2.6. docbook2odf - Convert docbook document to Oasis Open Document
2.7. docbook-website - XML Website DTD and XSL Stylesheets
2.8. EPUB
2.8.1. 创建.epub文件
2.8.2. Reader

Docbook SGML,XML 转换程序

2.1. SGML

sudo apt-get install docbook-utils

CentOS

# yum install docbook*


2.2. 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

2.2.1. 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.2.2. docbook-ebnf - EBNF module for the XML version of the DocBook DTD

docbook-ebnf - EBNF module for the XML version of the DocBook DTD

$ sudo apt-get install docbook-ebnf

2.2.3. docbook-xsl-saxon

$ sudo apt-get install docbook-xsl-saxon

创建一个test.xml的测试文件

SRCS = test.xml

DESTDIR = .

all: html

html: $(SRCS:.xml=.noext.html) $(SRCS:.xml=.html)

%.png : %.png.uu
    [ -d ${DESTDIR} ] || mkdir -p ${DESTDIR}
    uudecode -o /dev/stdout < $< > ${DESTDIR}/$@

%.html : %.xml
    [ -d ${DESTDIR} ] || mkdir -p ${DESTDIR}
    java -cp "/usr/share/java/saxon.jar:/usr/share/java/xslthl.jar:/usr/share/java/docbook-xsl-saxon.jar" \
      -Dhighlight.xslthl.config="/usr/share/xml/docbook/stylesheet/docbook-xsl/highlighting/xslthl-config.xml" \
      com.icl.saxon.StyleSheet \
      -u -o ${DESTDIR}/$@ $< db2html.xsl \
      highlight.source=1

%.noext.html : %.xml
    [ -d ${DESTDIR} ] || mkdir -p ${DESTDIR}
    xsltproc --xinclude --nonet -o ${DESTDIR}/$@ \
            --stringparam highlight.source 1 \
            --stringparam xslthl.config /usr/share/xml/docbook/stylesheet/docbook-xsl/highlighting/xslthl-config.xml \
            --param use.extensions 0 \
            --stringparam  paper.type A4 \
            db2html.xsl $<

validate: check

check:
    xmllint --xinclude --nonet --noout --postvalid $(SRCS)

clean:
    rm -f ${DESTDIR}/*.html ${DESTDIR}/*.png

.PHONY: all check clean html validate

生成html

cp  /usr/share/doc/docbook-xsl-saxon/examples/db2html.xsl 。

make html


2.3. XML 校验

$ xmllint book.xml


2.4. PDF

sudo apt-get install docbook-xml docbook-xsl xsltproc fop

安装字体

sudo mkdir /usr/share/fonts/microsoft

将 C:\Windows\Fonts 目录中的字体复制到 /usr/share/fonts/microsoft

$ java -cp /usr/share/java/fop.jar  org.apache.fop.fonts.apps.TTFReader /usr/share/fonts/microsoft/simhei.ttf simhei.xml
$ java -cp /usr/share/java/fop.jar  org.apache.fop.fonts.apps.TTFReader -ttcname "SimSun" /usr/share/fonts/microsoft/simsun.ttc simsun.xml

sudo vim /usr/share/xml/docbook/stylesheet/docbook-xsl/fo/param.xsl
<xsl:param name="callout.unicode.font">simsun</xsl:param>
<xsl:param name="symbol.font.family">simsun</xsl:param>
<xsl:param name="callout.unicode.font">simsun</xsl:param>

$ vim fop.conf

<?xml version="1.0"?>
<fop version="1.0">
<base>.</base>

<renderers>
    <renderer mime="application/pdf">
     <filterList>
         <value>flate</value>
     </filterList>
      <fonts>
        <font metrics-url="simhei.xml" kerning="yes" embed-url="/usr/share/fonts/microsoft/simhei.ttf">
          <font-triplet name="simhei" style="normal" weight="normal"/>
          <font-triplet name="simhei" style="normal" weight="bold"/>
          <font-triplet name="simhei" style="italic" weight="normal"/>
          <font-triplet name="simhei" style="italic" weight="bold"/>
          </font>
          <font metrics-url="simsun.xml" kerning="yes" embed-url="/usr/share/fonts/microsoft/simsun.ttc">
          <font-triplet name="simsun" style="normal" weight="normal"/>
          <font-triplet name="simsun" style="normal" weight="bold"/>
          <font-triplet name="simsun" style="italic" weight="normal"/>
          <font-triplet name="simsun" style="italic" weight="bold"/>
          </font>
        </fonts>
    </renderer>
</renderers>
</fop>

xsltproc -o helloworld.fo /usr/share/xml/docbook/stylesheet/docbook-xsl/fo/docbook.xsl helloworld.xml
fop -c fop.conf helloworld.fo -pdf helloworld.pdf


2.5. CHM

下载HTML Help Wordshop工具，并安装

copy “c:\Program Files\HTML Help Workshop\hhc.exe” d:\docbook\example
xsltproc –xinclude docbook_chm.xsl docbook.xml
hhc.exe htmlhelp.hhp

set PATH=C:\Program Files (x86)\HTML Help Workshop;%PATH%
hhc htmlhelp.hhp


2.6. docbook2odf - Convert docbook document to Oasis Open Document

sudo apt-get install docbook2odf

docbook2odf book.xml


2.7. docbook-website - XML Website DTD and XSL Stylesheets

sudo apt-get install docbook-website

#!/bin/bash
export DSSSL=/usr/share/xml/docbook/stylesheet/nwalsh/xhtml/onechunk.xsl
mkdir tmp
cd tmp
xsltproc --stringparam html.stylesheet docbook.css ${DSSSL} ../book.xml


2.8. EPUB

2.8.1. 创建.epub文件

<?xml version="1.0" encoding="utf-8"?`>
<book>
  <bookinfo>
    <title>My EPUB book</title>
    <author><firstname>Liza</firstname>
            <surname>Daly</surname></author>
    <volumenum>1234</volumenum>
  </bookinfo>
  <preface id="preface">
    <title>Title page</title>
    <figure id="cover-image">
      <title>Our EPUB cover image icon</title>
      <graphic fileref="cover.png"/>
    </figure>
  </preface>
  <chapter id="chapter1">
    <title>This is a pretty simple DocBook example</title>
    <para>
      Not much to see here.
    </para>
  </chapter>
  <chapter id="end-notes">
    <title>End notes</title>
    <para>
      This space intentionally left blank.
    </para>
  </chapter>
</book>

$ xsltproc /usr/share/xml/docbook/stylesheet/docbook-xsl/epub/docbook.xsl docbook.xml
$ echo "application/epub+zip" > mimetype
$ zip -0Xq  my-book.epub mimetype
$ zip -Xr9D my-book.epub *

2.8.2. Reader

http://calibre-ebook.com/


第 3 章 DOCTYPE

目录

3.1. SYSTEM
3.2. Docbook参数
3.2.1. 字符集
3.2.2. Filename prefix
3.3. DTD 引用
3.3.1. 引用本地DTD
3.3.2. oasis-open.org
3.4. article
3.5. book
3.6. include
3.7. Docbook HTML 输出选项
3.7.1. 指定多页输出时html文档名
3.7.2. 指定输出路径
3.7.3. 包含HTML文件
3.7.4. 包含HTML节点
3.7.5. 图标
3.7.5.1. Admonition graphics
3.7.5.2. 导航图标
3.7.5.3. Callout icons
3.7.6. dbhtml-include

3.1. SYSTEM

在线引用DOCTYPE头，这样在创建文档的时候速度会比较慢。

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

我们也可使使用本地的DTD文件

<!DOCTYPE subject SYSTEM "/usr/share/xml/docbook/schema/dtd/4.5/docbookx.dtd" [
    <!ENTITY book.info.author.xml			SYSTEM "../common/book.info.author.xml">
    <!ENTITY book.info.legalnotice.xml		SYSTEM "../common/book.info.legalnotice.xml">
    <!ENTITY book.info.abstract.xml			SYSTEM "../common/book.info.abstract.xml">
    <!ENTITY book.preface.xml           	SYSTEM "../common/book.preface.xml">
    <!ENTITY preface.about.me.xml       	SYSTEM "../common/about.me.xml">

    <!ENTITY chapter.docbook 			 	SYSTEM "chapter.docbook.xml">
    <!ENTITY chapter.docbook.doctype.xml 	SYSTEM "chapter.docbook.doctype.xml">
    <!ENTITY chapter.docbook.list.xml	 	SYSTEM "chapter.docbook.list.xml">
    <!ENTITY chapter.docbook.paragraphs.xml	SYSTEM "chapter.docbook.paragraphs.xml">
    <!ENTITY chapter.docbook.admonition.xml	SYSTEM "chapter.docbook.admonition.xml">
    <!ENTITY chapter.docbook-website.xml	SYSTEM "chapter.docbook-website.xml">
    <!ENTITY chapter.docbook.epub.xml	 	SYSTEM "chapter.docbook.epub.xml">
]>

<!DOCTYPE article PUBLIC "-//FreeBSD//DTD DocBook XML V4.5-Based Extension//EN" "../../../share/xml/freebsd45.dtd">


3.2. Docbook参数

/usr/share/xml/docbook/stylesheet/nwalsh/xhtml/param.xsl

默认HTML格式输出文件中的章内小节是没有自动编号功能的，如果要实现小节自动编号需要设置HTML格式的两个转换参数。

section.autolabel参数为1代表章内小节可自动编号，为0表示不会自动编号；

section.label.includes.component.label参数为1表示章内小节编号包含章节编号,为0表示不包含章节编号。

设置这两个参数可通过命令行方式，也可通过修改XSL转换文件方法。下面分别介绍这两种方法：

通过命令行方式：

$ xsltproc --stringparam  section.autolabel 1 \
           --stringparam  section.label.includes.component.label 1 \
           docbook.xsl  myfile.xml>myfile.htm
修改XSL转换文件方式：

DocBook文档的HTML格式转换样式文件一般位于/usr/share/sgml/docbook/docbook-xsl-1.65.1/html/目录下。通过查看docbook.xsl文件可知，在docbook.xsl中引用param.xsl作为参数设置文件，所有的参数都在这里设置。我们打开param.xsl文件，找到以下两行，再把参数置成1就可以了。

<xsl:param name="section.autolabel" select="1"/>
<xsl:param name="section.label.includes.component.label" select="1"/>

另一种方法

cat my_docbook.xsl
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version='1.0'>
<xsl:include href="/usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl"/>
<xsl:output method="html"
            encoding="UTF-8"
            indent="no"/>
</xsl:stylesheet>

xsltproc -o docbook.html my_docbook.xsl docbook.xml

3.2.1. 字符集

--stringparam chunker.output.encoding UTF-8

3.2.2. Filename prefix

base.dir parameter value	Description	Example 					chunk filename
base.dir="htmlout/"			Output directory only.					htmlout/chap1.html
base.dir="refbook-"			Filename prefix only.					refbook-chap1.html
base.dir="htmlout/refbook-"	Output directory and filename prefix.	htmlout/refbook-chap1.html

base.dir parameter

xsltproc --stringparam base.dir /usr/apache/htdocs/ chunk.xsl myfile.xml


3.3. DTD 引用

3.3.1. 引用本地DTD

<!DOCTYPE subject SYSTEM "/usr/share/xml/docbook/schema/dtd/4.5/docbookx.dtd" [
...
]>

3.3.2. oasis-open.org

<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V5.0//EN" "http://www.oasis-open.org/docbook/xml/5.0b5/dtd/docbook.dtd" [
...
]>


3.4. article

例 3.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>


3.5. book

例 3.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.6. 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>


3.7. Docbook HTML 输出选项

HTML output options

3.7.1. 指定多页输出时html文档名

我们把docbook文档转换成html文档时，可以转换成一个大的html文档，也可以转换成多页的html文档。当转换成多页是，默认的文件是以ch01.html、ch02.html方式命名的，较不直观。我们可在docbook文档中添加一个属性，使它输出时按我们指定的文件名输出。

方法一：
<chapter><?dbhtml filename="first.html" ?>
<title>Introduction</title>
...

方法二：
<chapter id="first">
<title>Introduction</title>
...

xsltproc --stringparam  use.id.as.filename 1 chunk.xsl myfile.xml

3.7.2. 指定输出路径

默认转换后的文档是保存在当前目录的，我们可在xsltproc命令行用-o选项指定转换后文档的输出路径，另外一种是在docbook中指定。

<book><?dbhtml dir="neo" ?>
<title>Docbook Guide</title>
...
<chapter id="first"><?dbhtml dir="technic" ?>
...
<chapter id="second">
...
<appendix id="three"><?dbhtml dir="read" ?>
...

输出后的路径：
jims/index.html
jims/technic/first.html
jims/second.html
jims/read/three.html

3.7.3. 包含HTML文件

...
</para>
<?dbhtml-include href="mycode.html"?>
<para>
...

3.7.4. 包含HTML节点

<xsl:template name="user.header.content">
   <xsl:variable name="codefile" select="document('mycode.html',/)"/>
   <xsl:copy-of select="$codefile/htmlcode/node()"/>
</xsl:template>

3.7.5. 图标

Docbook icon graphics

3.7.5.1. Admonition graphics

admon.graphics 1

xsltproc  --stringparam admon.graphics 1 docbook.xsl myfile.xml

3.7.5.2. 导航图标

Navigational icons
xsltproc --stringparam  navig.graphics 1  chunk.xsl  myfile.xml

3.7.5.3. Callout icons

If you use callout graphics, then there are three parameters that give you more control over the generated img tag.

callout.graphics.extension
Use this parameter to change the icon file extension from .png to something else. Of course, you must have the graphics that match that extension.

callout.graphics.path
Use this parameter to change the generated directory name from the default images/callouts/. Be sure to include the trailing slash.

callout.graphics.number.limit
Use this parameter to set the highest number for which you have a callout graphic. The stylesheets are distributed with callout graphics files with numbers up to 15, but you could create graphics with additional numbers if you need them. If you have more numbers but you do not reset this parameter, then any numbers over 15 will still format like (16).

3.7.6. dbhtml-include

包含html文件到当前页面

<?dbhtml-include href="file:///www/freebsd/faq.html"?>
<?dbhtml-include href="http://www.example.org/freebsd/faq.html"?>

注意：需要开启下面两个选项才能生效

    <xsl:param name="use.extensions" select="1"/>
    <xsl:param name="textinsert.extension" select="1"/>


第 4 章 book / article

目录

4.1. info
4.1.1. affiliation
4.1.2. address
4.1.3. reference
4.1.4. author
4.1.4.1. contrib
4.1.4.2. affiliation
4.1.4.3. editor
4.1.4.4. othercredit
4.1.5. 出版信息
4.1.5.1. publisher
4.1.5.2. printhistory
4.1.5.3. 出版紀錄
4.1.6. copyright
4.1.7. keyword
4.1.8. dedication
4.1.9. abstract
4.1.10. legalnotice

4.1. info

bookinfo / articleinfo

4.1.1. affiliation

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

4.1.2. 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>

4.1.3. reference

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

4.1.4. 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>

4.1.4.1. contrib

<authorgroup>
    <author>
    <firstname>Jordan</firstname>
    <surname>Hubbard</surname>
    <contrib>原著</contrib>
    </author>
</authorgroup>

4.1.4.2. affiliation

<!DOCTYPE author PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
          "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<author>
  <honorific>Mr</honorific>
  <firstname>Norman</firstname>
  <surname>Walsh</surname>
  <othername role='mi'>D</othername>
  <affiliation>
    <shortaffil>ATI</shortaffil>
    <jobtitle>Senior Application Analyst</jobtitle>
    <orgname>ArborText, Inc.</orgname>
    <orgdiv>Application Developement</orgdiv>
  </affiliation>
</author>

4.1.4.3. editor

<!DOCTYPE authorgroup PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
<authorgroup>
  <author>
    <honorific>Dr.</honorific>
    <firstname>Lois</firstname>
    <surname>Common-Demoninator</surname>
    <affiliation>
      <shortaffil>Director, M. Behn School of Coop. Eng.</shortaffil>
      <jobtitle>Director of Cooperative Efforts</jobtitle>
      <orgname>The Marguerite Behn International School of
               Cooperative Engineering</orgname>
    </affiliation>
  </author>

  <editor>
    <firstname>Peter</firstname>
    <surname>Parker</surname>
    <lineage>Sr.</lineage>
    <othername>Spiderman</othername>
    <authorblurb>
      <para>
      Peter's a super hero in his spare time.
      </para>
    </authorblurb>
  </editor>
</authorgroup>

4.1.4.4. othercredit

<article xmlns='http://docbook.org/ns/docbook'>
<info>
  <title>Example othercredit</title>
  <author>
    <personname>
      <firstname>Norman</firstname>
      <surname>Walsh</surname>
    </personname>
  </author>
  <othercredit>
    <personname>
      <firstname>John</firstname>
      <surname>Doe</surname>
    </personname>
    <contrib>Extensive review and rough drafts of Section 1.3, 1.4, and 1.5
    </contrib>
  </othercredit>
  <biblioid>5</biblioid>
</info>

<para>…</para>

</article>

<!DOCTYPE articleinfo PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
          "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<articleinfo>
  <title>Something Snappy</title>
  <author>
    <firstname>Norman</firstname>
    <surname>Walsh</surname>
  </author>
  <othercredit>
    <firstname>John</firstname>
    <surname>Doe</surname>
    <contrib>Extensive review and rough drafts of Section 1.3, 1.4, and 1.5
      </contrib>
  </othercredit>
  <pubsnumber>5</pubsnumber>
</articleinfo>

4.1.5. 出版信息

4.1.5.1. publisher

<publisher>                      <!-- 出版者 -->
    <publishername>XXXXXX有限公司</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>

4.1.5.2. printhistory

<printhistory>
<para>
   June 2000: First Printed Edition.
</para>
</printhistory>

4.1.5.3. 出版紀錄

    <edition>User's Guide version 1.0 for DocBook V3.0</edition>
    <pubdate>1997</pubdate>
    <releaseinfo></releaseinfo>
    <isbn>ISBN xx-xxxxxx-x-x</isbn>
    <revhistory>                     	<!-- 出版紀錄，可以有很多版本。 -->
        <revision>                     	<!-- 某一版本 -->
            <revnumber>1.0.0</revnumber> <!-- 版本編號 -->
            <date>2006-11-14</date>  	<!-- 發佈出版日期 -->
            <authorinitials></authorinitials>  <!-- 作者簡稱識別 -->
            <revremark></revremark>  	<!-- 版本發佈簡述 -->
        </revision>
    </revhistory>

4.1.6. copyright

    <copyright>
        <year>2008</year>
        <year>2009</year>
        <year>2010</year>
        <year>2011</year>
        <holder>Netkiller(Neo Chan). All rights reserved.</holder>
    </copyright>

4.1.7. keyword

    <keywordset>
        <keyword>Linux</keyword>
        <keyword>Beginners</keyword>
        <keyword>linux</keyword>
        <keyword>start</keyword>
        <keyword>Getting started</keyword>
        <keyword>guide</keyword>
        <keyword>Guide</keyword>
        <keyword>Exercises</keyword>
        <keyword>exercises</keyword>
    </keywordset>

4.1.8. dedication

<book>
    <info>
        <dedication><title>鸣谢</title>
            <para></para>
            <para></para>
            <para></para>
            <para></para>
        </dedication>
    </info>
</book>

4.1.9. abstract

<book>
    <info>
        <abstract><title>Abstract</title>
            <para></para>
            <para></para>
            <para></para>
            <para></para>
        </abstract>
    </info>
</book>

4.1.10. legalnotice

<book>
    <info>
        <legalnotice><title>Legalnotice</title>
            <para></para>
            <para></para>
            <para></para>
            <para></para>
        </legalnotice>
    </info>
</book>


第 5 章 preface

<preface id="svn.foreword">
  <prefaceinfo>
    <author>
      <firstname>Neo</firstname>
      <surname>Chan</surname>
    </author>
    <pubdate>Chicago, March 14, 2004.</pubdate>
  </prefaceinfo>

  <title>Preface</title>
  <para>...</para>
</preface>


第 6 章 Part / Chapter / Section

目录

6.1. part
6.2. chapter
6.2.1. chapterinfo
6.2.2. epigraph
6.3. section
6.4. title
6.4.1. subtitle
6.4.2. titleabbrev

6.1. part

<part>
    <title>Part</title>
    <partintro>
        <para></para>
    </partintro>
</part>

<?xml version="1.0" encoding="UTF-8"?>
<book version="5.0" xmlns="http://docbook.org/ns/docbook"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xmlns:xi="http://www.w3.org/2001/XInclude">
  <info>
    <title>The Gallio Book</title>
    <authorgroup>
      <author><personname>The Gallio Documentation Team</personname></author>
    </authorgroup>
    <copyright>
      <year>2009</year>
      <holder>Gallio Project</holder>
    </copyright>
    <address>http://www.gallio.org/</address>
    <xi:include href="ReleaseInfo.docbook"/>
  </info>

  <xi:include href="Preface.docbook" />
  <part label="I" xml:id="part_Using">
    <title>Using MbUnit and Gallio</title>
    <xi:include href="Installation/Installation.docbook" />
  </part>

  <part label="II" xml:id="part_Developing">
    <title>Developing MbUnit and Gallio</title>
    <xi:include href="GallioDevelopmentBasics/GallioDevelopmentBasics.docbook" />
  </part>

  <part label="III" xml:id="appendices">
    <title>Appendices</title>
    <xi:include href="Appendices/MigrationGuide.docbook" />
  </part>

</book>


6.2. chapter

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

6.2.1. chapterinfo

    <chapterinfo>
        <abstract>
          <para>Kickstart 无人值守安装</para>
        </abstract>
        <keywordset>
            <keyword>ISO</keyword>
            <keyword>kickstart</keyword>
            <keyword>ks</keyword>
        </keywordset>
    </chapterinfo>

<chapterinfo>
    <authorgroup>
      <author>
        <firstname>Tom</firstname>
        <surname>Rhodes</surname>
        <contrib>Written by </contrib>
      </author>
    </authorgroup>
</chapterinfo>

<chapterinfo>
<keywordset>
  <keyword>images</keyword>
  <keyword>illustrations</keyword>
</keywordset>
<itermset>
  <indexterm zone="figures"><primary>Figures</primary></indexterm>
  <indexterm zone="figures"><primary>Pictures</primary></indexterm>
  <indexterm zone="notreal">
    <primary>Sections</primary><secondary>Not Real</secondary>
  </indexterm>
</itermset>
</chapterinfo>

6.2.2. epigraph

<epigraph>

<attribution>
   <ulink url="http://www.margepiercy.com/">Marge Piercy</ulink>
</attribution>

<para>
   Life is the first gift, love is the second, and understanding is the third.
</para>

</epigraph>


6.3. section

<part>
    <title>Part I</title>
    <chapter>
        <title>Chapter 1</title>
        <section>
            <title>Section 1</title>
        </section>
    </chapter>
</part>


6.4. title

<part>
    <title>Part I</title>
    <chapter>
        <title>Chapter 1</title>
        <section>
            <title>Section 1</title>
        </section>
    </chapter>
</part>

6.4.1. subtitle

<part>
    <title>Part I</title>
    <subtitle>Part I subtitle</subtitle>
    <chapter>
        <title>Chapter 1</title>
        <subtitle>Chapter 1 subtitle</subtitle>
        <section>
            <title>Section 1</title>
            <subtitle>Section 1 subtitle</subtitle>
        </section>
    </chapter>
</part>

6.4.2. titleabbrev

<part>
    <title>Part I</title>
    <subtitle>Part I subtitle</subtitle>
    <titleabbrev>Part I titleabbrev</titleabbrev>
    <chapter>
        <title>Chapter 1</title>
        <subtitle>Chapter 1 subtitle</subtitle>
        <titleabbrev>Chapter I titleabbrev</titleabbrev>
        <section>
            <title>Section 1</title>
            <subtitle>Section 1 subtitle</subtitle>
            <titleabbrev>Section I titleabbrev</titleabbrev>
        </section>
    </chapter>
</part>


第 7 章 appendix

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


第 8 章 术语表 glossary

<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…


第 9 章 Paragraphs

目录

9.1. para
9.2. simpara
9.3. formalpara
9.4. bridgehead
9.5. blockquote
9.6. sidebar
9.7. TM 商标
9.8. epigraph 题词
9.9. Font Formatting Codes
9.9.1. strong
9.9.2. bold
9.9.3. italic
9.9.4. literal
9.9.5. remark

9.1. para

<para>helloworld</para>


9.2. simpara

<simpara>
    Just the text, ma'am.
</simpara>

Just the text, ma'am.


9.3. 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.


9.4. 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.5. blockquote

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

This text should be indented.


9.6. sidebar

<sidebar>
    <title>A Sidebar</title>
    <para>
    Sidebar content.
    </para>
</sidebar>

A Sidebar

Sidebar content.


9.7. TM 商标

<trademark>Microsoft</trademark>

Microsoft™


9.8. epigraph 题词

<epigraph>
    <attribution>William Safire</attribution>
    <para>
        Knowing how things work is the basis for appreciation, and is
        thus a source of civilized delight.
    </para>
</epigraph>

Knowing how things work is the basis for appreciation, and is thus a source of civilized delight.

—William Safire


9.9. Font Formatting Codes

9.9.1. strong

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

Note

9.9.2. bold

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

9.9.3. italic

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

9.9.4. literal

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

literal

Code

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

9.9.5. remark

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

Some details are still a bit shaky


第 10 章 Lists 项目符号与编号

目录

10.1. itemizedlist
10.2. orderedlist
10.3. simplelist
10.4. variablelist
10.5. segmentedlist
10.6. procedure 过程
10.7. question/answer 问答
10.8. glosslist 注解

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

10.1. 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

<itemizedlist mark='opencircle'>
<listitem>
<para>
Item 1
</para>
</listitem>
<listitem override='bullet'>
<para>
Item 2
</para>
</listitem>
<listitem>
<para>
Item 3
</para>
</listitem>
</itemizedlist>

  • Item 1

  • Item 2

  • Item 3


10.2. 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.3. simplelist

例 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:

A | B | C
D | E | F
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:

A | D | G
B | E |
C | F |


10.4. 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.


10.5. segmentedlist

<segmentedlist>
    <segtitle>Name</segtitle>
    <segtitle>Occupation</segtitle>
    <segtitle>Favorite Food</segtitle>
    <seglistitem>
        <seg>Tux</seg>
        <seg>Linux mascot</seg>
        <seg>Herring</seg>
    </seglistitem>
    <seglistitem>
        <seg>Konqui</seg>
        <seg>The KDE Dragon</seg>
        <seg>Gnomes</seg>
    </seglistitem>
</segmentedlist>
Name: Tux
Occupation: Linux mascot
Favorite Food: Herring
Name: Konqui
Occupation: The KDE Dragon
Favorite Food: Gnomes


10.6. 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.


10.7. question/answer 问答

<qandaset>
    <qandaentry>
        <question>
            <para>What are little boys made of?</para>
        </question>
        <answer>
            <para>Snips and snails and puppy dog tails.</para>
        </answer>
    </qandaentry>
    <qandaentry>
        <question>
            <para>What are little girls made of?</para>
        </question>
        <answer>
            <para>Sugar and spice and everything nice.</para>
        </answer>
    </qandaentry>
</qandaset>
10.7.1. What are little boys made of?
10.7.2. What are little girls made of?
10.7.1. | What are little boys made of?
 | Snips and snails and puppy dog tails.
10.7.2. | What are little girls made of?
 | Sugar and spice and everything nice.


10.8. glosslist 注解

<glosslist>
    <glossentry>
        <glossterm>C</glossterm>
        <glossdef>
            <para>
                A procedural programming language invented by K&amp;R.
            </para>
        </glossdef>
    </glossentry>
    <glossentry>
        <glossterm>Pascal</glossterm>
        <glossdef>
            <para>
                A procedural programming language invented by Niklaus Wirth.
            </para>
        </glossdef>
    </glossentry>
</glosslist>
C

A procedural programming language invented by K&R.

Pascal

A procedural programming language invented by Niklaus Wirth.


第 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

目录

12.1. figure
12.2. mediaobject
12.3. screenshot

12.1. figure

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


12.2. mediaobject

<figure>
    <title>OpenOffice MS-compatible Spreadsheet</title>
    <mediaobject>
        <imageobject>
            <imagedata fileref="images/openoffice.png" format="PNG"></imagedata>
        </imageobject>
        <imageobject>
            <imagedata fileref="images/openoffice.eps" format="EPS"></imagedata>
        </imageobject>
        <textobject>
            <phrase>OpenOffice spreadsheet looks just like MS Office .xls file.</phrase>
        </textobject>
    </mediaobject>
</figure>


12.3. screenshot

<figure id="app-FIG-shot1">
 <title>Screenshot</title>
 <screenshot>
  <mediaobject>
   <imageobject>
    <imagedata fileref="figures/example_screenshot.png" format="PNG"/>
   </imageobject>
   <textobject>
     <phrase>Shows the application screenshot with several buttons.</phrase>
   </textobject>
   <caption>
    <para>Screenshot of a program</para>
   </caption>
  </mediaobject>
 </screenshot>
</figure>


第 13 章 Admonition

目录

13.1. caution
13.2. important
13.3. note
13.4. tip
13.5. warning

caution, important, note, tip, warning

13.1. caution

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

小心

Text goes here.


13.2. important

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

重要

Text goes here.


13.3. note

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

注意

Text goes here.


13.4. tip

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

提示

Text goes here.


13.5. warning

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

警告

Text goes here.


第 14 章 Computer terminal

目录

14.1. literallayout
14.2. programlisting
14.2.1. Callouts
14.3. userinput
14.4. Keyboard Input

14.1. literallayout

<literallayout>
1
2
3
</literallayout>


14.2. programlisting

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

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

<programlisting language="java">
</programlisting>

<programlisting linenumbering="numbered" startinglinenumber="12">

</programlisting>

<programlisting linenumbering="numbered" >
<?dbhtml linenumbering.everyNth="2" linenumbering.separator=" &gt;" linenumbering.width="2" ?>
<?dbfo linenumbering.everyNth="2" linenumbering.separator=" &gt;" linenumbering.width="2" ?>
<textobject><textdata  fileref="mycode.c" /></textobject>
</programlisting>

<example><title>My program listing</title>
  <programlisting><textobject><textdata
     fileref="mycode.c" /></textobject></programlisting>
</example>

Using XInclude for text inclusions
<example><title>My program listing</title>
  <programlisting><xi:include  href="mycode.c"  parse="text"
      xmlns:xi="http://www.w3.org/2001/XInclude"/></programlisting>
</example>

<programlisting linenumbering="numbered" startinglinenumber="12">
<![CDATA[
#include <stdio.h>

int main(void)
{
   printf("Hello, world!\n");
   return 0;
}
]] >
</programlisting>

<programlisting linenumbering="numbered" >
    <?dbhtml linenumbering.everyNth="2" linenumbering.separator=" &gt;" linenumbering.width="2"?>
    <?dbfo linenumbering.everyNth="2"   linenumbering.separator=" &gt;" linenumbering.width="2"?>
    <textobject><textdata  fileref="mycode.c" /></textobject>
</programlisting>

<?php

class foo
{
    private $bar;

    public function __construct($bar)
    {
        $this->bar = $bar;
    }

    /**
     * getFoo
     *
     * Returns bar if $this->bar is foo else foo .. Oo ;D
     *
     * @return string
     */
    public function getFoo()
    {
        if($this->bar == 'foo')
        {
            return 'bar';
        }
        else
        {
            return 'foo';
        }
    }
}

14.2.1. Callouts

<screen>
bash@host:~/cvs/newbiedoc$ ls -l
total 48
<co id="perm">drwxr-sr-x    2 jesse    jesse        4096 May  4 16:26 CVS<co id="cvs">
drwxr-sr-x    3 jesse    jesse        4096 Mar 29 03:29 dev
drwxr-sr-x    3 jesse    jesse        4096 Apr  8 19:31 general
drwxr-sr-x    3 jesse    jesse        4096 Apr  9 00:15 images
</screen>

<calloutlist>
   <callout arearefs="cvs">
      <para>
      This is the CVS directory.  CVS files are stored here.
      </para>
   </callout>

   <callout arearefs="perm">
      <para>
      These are the permissions for the CVS directory.
      </para>
   </callout>
</calloutlist>


14.3. 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>


14.4. Keyboard Input

<keycombo>
 <keycap>Ctrl</keycap>
 <keycap>Alt</keycap>
 <keycap>F1</keycap>
</keycombo>

<menuchoice>
 <shortcut>
  <keycombo><keycap>Ctrl</keycap><keycap>q</keycap></keycombo>
 </shortcut>
 <guimenuitem> Quit</guimenuitem>
</menuchoice>


第 15 章 Cross references

目录

15.1. link
15.2. ulink
15.3. xreflabel / xref

15.1. link

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

<link linkend="font"><quote>font</quote></link>


15.2. ulink

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


15.3. xreflabel / xref

<para  id="ChooseSCSIid"  xreflabel="choosing a SCSI id">The methods
for choosing a <acronym>SCSI</acronym> id are ...
</para>
...
<para>
See the paragraph on <xref  linkend="ChooseSCSIid"/>.
</para>

<para  id="ChooseSCSIid"  >The methods
for <phrase  id="SCSIxref">choosing a <acronym>SCSI</acronym> id</phrase>
are ...
</para>
...
<para>
See the paragraph on <xref  linkend="ChooseSCSIid"  endterm="SCSIxref"/>.
</para>


第 16 章 The DocBook HTML Forms Document Type

$ sudo apt-get install docbook-html-forms

To use this module, specify the public and system identifiers of this module in your document type declaration. For example, to use this module to write a book, use the following document type declaration:

<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook HTML Forms Module V1.2CR1//EN"
               "http://www.oasis-open.org/docbook/xml/htmlforms/1.2CR1/dbforms.dtd">

Naturally, you can include an internal subset if you wish.

To incorporate this module into a higher-level customization layer, use the public and system identifiers of this module in your customization layer. For example:

<!DOCTYPE % docbookforms PUBLIC "-//OASIS//DTD DocBook HTML Forms Module V1.2CR1//EN"
                        "http://www.oasis-open.org/docbook/xml/htmlforms/1.2CR1/dbforms.dtd">
%docbookforms;


部分 II. Tex

目录

17. Document Tools
17.1. texlive - TeX Live: A decent selection of the TeX Live packages
17.2. latex2html
17.3. texi2html
17.4. XeTeX
17.4.1. install usage apt-get
17.4.2. test.tex
17.5. LuaTeX
17.6. tex2page
17.7. CJK
17.8. TeXstudio(LaTeX 编辑器)
18. 编码转换
19. 排版
20. 文章的组成元素
21. Fonts
21.1. Sizes
21.2. Styles
22. 项目符号和编号
23. 表格
24. 图片
25. 分割章节


第 17 章 Document Tools

目录

17.1. texlive - TeX Live: A decent selection of the TeX Live packages
17.2. latex2html
17.3. texi2html
17.4. XeTeX
17.4.1. install usage apt-get
17.4.2. test.tex
17.5. LuaTeX
17.6. tex2page
17.7. CJK
17.8. TeXstudio(LaTeX 编辑器)

17.1. texlive - TeX Live: A decent selection of the TeX Live packages

sudo apt-get install texlive


17.2. 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


17.3. texi2html

$ sudo apt-get install texi2html


17.4. XeTeX

http://zh.wikipedia.org/wiki/XeTeX

17.4.1. install usage apt-get

http://scripts.sil.org/xetex

$ sudo apt-get install texlive-xetex lmodern

17.4.2. 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


17.5. LuaTeX

http://www.luatex.org/


17.6. tex2page

install tex2page

sudo apt-get install mzscheme

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


17.7. CJK

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

例 17.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


17.8. TeXstudio(LaTeX 编辑器)

http://texstudio.sourceforge.net/


第 18 章 编码转换

gb2312转utf-8

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


第 19 章 排版

选择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}


第 20 章 文章的组成元素

标题

\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}

例 20.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}

例 20.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}


第 21 章 Fonts

目录

21.1. Sizes
21.2. Styles

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}.

21.1. Sizes

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


21.2. 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.


第 22 章 项目符号和编号

项目符号

\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}


第 23 章 表格

使用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来实现的。如果你不想要这些线，你可以把它们去掉。


第 24 章 图片

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

\usepackage{graphicx}

插入图片

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


第 25 章 分割章节

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{第一节}
贾生名谊，洛阳人也。年十八，以能诵诗属书闻于郡中。


第 26 章 Markdown

目录

26.1. Section
26.2. Lists

http://daringfireball.net/projects/markdown/

26.1. Section

A First Level Header
====================

A Second Level Header
---------------------


26.2. Lists

*   Candy.
*   Gum.
*   Booze.

+   Candy.
+   Gum.
+   Booze.

-   Candy.
-   Gum.
-   Booze.


第 27 章 Sphinx

http://sphinx-doc.org/


第 28 章 pandoc - general markup converter

目录

28.1. Docbook to Markdown

http://johnmacfarlane.net/pandoc/

28.1. Docbook to Markdown

pandoc -f docbook -t markdown -s howto.xml -o example.text


第 29 章 写作团队的运作

目录

29.1. Docbook 环境初始化
29.1.1. FreeBSD
29.1.2. Ubuntu/Debian
29.2. Subversion 版本控制
29.3. GIT

前提条件： subversion 服务器一台,或者使用sf.net, github.com, code.google.com 等等提供的服务，团队人员需要懂得docbook以及配置docbook环境

29.1. Docbook 环境初始化

29.1.1. FreeBSD

# pkg_add -r vim
# pkg_add -r git
# pkg_add -r libxml2 libxslt
# pkg_add -r docbook-xsl

创建 book.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE subject SYSTEM "/usr/local/share/xml/docbook/5.0/dtd/docbook.dtd">
<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>

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

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

    </chapter>
</book>

生成文档

$ xsltproc /usr/local/share/xsl/docbook/xhtml/docbook.xsl book.xml > book.html

29.1.2. Ubuntu/Debian

$ sudo apt-get install docbook-xsl
$ sudo apt-get install xsltproc xmlto
$ sudo apt-get install make
$ sudo apt-get install git

创建 book.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE subject SYSTEM "/usr/share/xml/docbook/schema/dtd/4.5/docbookx.dtd">
<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>

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

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

    </chapter>
</book>

生成文档

$ xsltproc /usr/share/xml/docbook/stylesheet/docbook-xsl/xhtml/docbook.xsl book.xml > book.html


29.2. Subversion 版本控制

  1. subversion 初始化

    1. trunk

    2. branches

    3. releases

    4. tags

    svn co svn://127.0.0.1/document
cd project
mkdir trunk
mkdir tags
mkdir branches
mkdir releases
svn ci -m "Initialized empty subversion repository in your_project"

  2. 创建docbook文档，安排章节

    将章节拆分成独立文件，并在主文档头部声明

    <!ENTITY chapter.system SYSTEM "chapter.system.xml">
    <!ENTITY chapter.system.harddisk SYSTEM "chapter.system.harddisk.xml">
    <!ENTITY chapter.network SYSTEM "chapter.network.xml">

    完成后导入subversion的trunk中

  3. 创建版本分支

    $ svn copy svn://netkiller.8800.org/document/trunk svn://netkiller.8800.org/document/branches/system
$ svn copy svn://netkiller.8800.org/document/trunk svn://netkiller.8800.org/document/branches/network

  4. 开始写作

    我们假设jam负责system章节

    1. checkout

      $ svn checkout svn://netkiller.8800.org/document/branches/system

    2. 编辑文件

      vim chapter.system.xml

    3. 校验XML

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

    4. 提交文件

      $ svn ci -m "I have finished this chapter."

    其他编辑人员操作类似checkout自己branche上的network章节等等

  5. tags运作

    当jam完成了指派的任务的第一个阶段后，可以创建一个tags

    svn copy svn://netkiller.8800.org/document/branches/system svn://netkiller.8800.org/document/tags/system_phase_I

    tags 一旦建立，以后不会在更改

    然后jam可以在/document/branches/system继续写作

  6. 合并tags到主干

    当tags完成后主编将其合并到trunk

    svn merge svn://netkiller.8800.org/document/tags/system_phase_I

    然后发行unstable版本，你也可以每天产生一个快照。等待用户反馈。

    反馈结果由负责人在/document/branches/system上修改，等待下一次发布在下一个阶段。

  7. 发行文档

    当一切OK时,我就可以把trunk 复制到 releases 中，随你怎命名。

    $ svn copy svn://netkiller.8800.org/document/trunk svn://netkiller.8800.org/document/release/document_v1.0

    这个版本/document/release/document_v1.0就可以提供给读者了。


29.3. GIT

配置GIT环境

git config --global user.name "Neo Chan"
git config --global user.email netkiller@msn.com

克隆仓库
git clone https://github.com/freebook/PHP.git

...
编辑文件
...

提交文件
git add *
git commit -a

推送文件
git push origin master