Home | 簡體中文 | 繁體中文 | 雜文 | 知乎專欄 | Github | OSChina 博客 | 雲社區 | 雲棲社區 | Facebook | Linkedin | 視頻教程 | 打賞(Donations) | About
知乎專欄多維度架構 | 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者”

第 15 章 Document Tools

目錄

15.1. texlive - TeX Live: A decent selection of the TeX Live packages
15.1.1. 安裝 XeTeX
15.1.1.1. install usage apt-get
15.1.2. XeLaTeX
15.1.3. 安裝字型
15.1.4. LuaTeX
15.1.5. FAQ
15.1.5.1. ! LaTeX Error: File `fontspec.sty' not found.
15.2. latex2html
15.3. texi2html
15.4. tex2page
15.5. CJK
15.6. TeXstudio(LaTeX 編輯器)

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

sudo apt-get install texlive
	

15.1.1. 安裝 XeTeX

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

xeTex是與tex平級的,都是排版引擎,而xeLatex和Latex剛分別基于兩者的宏包。不同的是xeTex支持Unicode, 可以直接支持中文。

XeLaTeX是使用LaTeX的排版引擎

15.1.1.1. install usage apt-get

http://scripts.sil.org/xetex

$ sudo apt-get install texlive-xetex lmodern
$ sudo apt-get install texlive-latex-extra texlive-latex-recommended
			

15.1.2. XeLaTeX

安裝XeTeX後現在我們嘗試創建一個PDF文檔

演示怎麼創建文檔

\documentclass[12pt,a4paper]{article}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\setmainfont[Mapping=tex-text]{WenQuanYi Micro Hei}
\begin{document}
\XeTeX 可以使用系統自帶的字型,而不需要再另外生成。
\end{document}
		

xelatex a.tex

15.1.3. 安裝字型

查看已經安裝的字型

$ fc-list :lang=zh
/usr/share/fonts/truetype/droid/DroidSansFallbackFull.ttf: Droid Sans Fallback:style=Regular
		

安裝字型,將字型複製到/usr/share/fonts目錄中,然後運行下面的命令。

$ sudo mkdir /usr/share/fonts/windows
$ sudo cp /media/Windows/Fonts/{SIM,sim}* /usr/share/fonts/windows/
		

安裝免費字型

$ sudo apt-get install xfonts-wqy ttf-wqy-microhei ttf-wqy-zenhei
		

更新字型

$ sudo mkfontscale
$ sudo mkfontdir
$ sudo fc-cache -fv		
		

查看字型

$ fc-list :lang=zh
/usr/share/fonts/windows/msyh.ttf: Microsoft YaHei,微軟雅黑:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/windows/FZYTK.TTF: FZYaoTi,方正姚體:style=Regular
/usr/share/fonts/windows/STXIHEI.TTF: STXihei,華文細黑:style=Regular
/usr/share/fonts/windows/simhei.ttf: SimHei,黑體:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/truetype/wqy/wqy-microhei.ttc: WenQuanYi Micro Hei,文泉驛微米黑,文泉驛微米黑:style=Regular
/usr/share/fonts/windows/simsun.ttc: NSimSun,新宋體:style=Regular
/usr/share/fonts/windows/simsun.ttc: SimSun,宋體:style=Regular
/usr/share/fonts/X11/misc/wenquanyi_10ptb.pcf: WenQuanYi Bitmap Song:style=Bold
/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc: WenQuanYi Zen Hei,文泉驛正黑,文泉驛正黑:style=Regular
/usr/share/fonts/X11/misc/wenquanyi_12pt.pcf: WenQuanYi Bitmap Song:style=Regular
/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc: WenQuanYi Zen Hei Sharp,文泉驛點陣正黑,文泉驛點陣正黑:style=Regular
/usr/share/fonts/windows/STXINWEI.TTF: STXinwei,華文新魏:style=Regular
/usr/share/fonts/X11/misc/wenquanyi_10pt.pcf: WenQuanYi Bitmap Song:style=Regular
/usr/share/fonts/windows/simkai.ttf: KaiTi,楷體:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/X11/misc/wenquanyi_9pt.pcf: WenQuanYi Bitmap Song:style=Regular
/usr/share/fonts/truetype/droid/DroidSansFallbackFull.ttf: Droid Sans Fallback:style=Regular
/usr/share/fonts/X11/misc/wenquanyi_11pt.pcf: WenQuanYi Bitmap Song:style=Regular
/usr/share/fonts/windows/mingliu.ttc: PMingLiU,新細明體:style=Regular
/usr/share/fonts/windows/simfang.ttf: FangSong,仿宋:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/windows/STFANGSO.TTF: STFangsong,華文仿宋:style=Regular
/usr/share/fonts/windows/msjh.ttf: Microsoft JhengHei,微軟正黑體:style=Normal,Regular,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/X11/misc/wenquanyi_9ptb.pcf: WenQuanYi Bitmap Song:style=Bold
/usr/share/fonts/windows/STLITI.TTF: STLiti,華文隷書:style=Regular
/usr/share/fonts/windows/msjhbd.ttf: Microsoft JhengHei,微軟正黑體:style=Negreta,Bold,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,Lodia
/usr/share/fonts/windows/STZHONGS.TTF: STZhongsong,華文中宋:style=Regular
/usr/share/fonts/windows/msyhbd.ttf: Microsoft YaHei,微軟雅黑:style=Bold,Negreta,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,Lodia
/usr/share/fonts/X11/misc/wenquanyi_11ptb.pcf: WenQuanYi Bitmap Song:style=Bold
/usr/share/fonts/windows/FZSTK.TTF: FZShuTi,方正舒體:style=Regular
/usr/share/fonts/windows/STSONG.TTF: STSong,華文宋體:style=Regular
/usr/share/fonts/windows/STXINGKA.TTF: STXingkai,華文行楷:style=Regular
/usr/share/fonts/windows/STHUPO.TTF: STHupo,華文琥珀:style=Regular
/usr/share/fonts/windows/SIMLI.TTF: LiSu,隷書:style=Regular
/usr/share/fonts/windows/kaiu.ttf: DFKai\-SB,標楷體:style=Regular
/usr/share/fonts/windows/ARIALUNI.TTF: Arial Unicode MS:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc: WenQuanYi Zen Hei Mono,文泉驛等寬正黑,文泉驛等寬正黑:style=Regular
/usr/share/fonts/windows/SIMYOU.TTF: YouYuan,幼圓:style=Regular
/usr/share/fonts/truetype/wqy/wqy-microhei.ttc: WenQuanYi Micro Hei Mono,文泉驛等寬微米黑,文泉驛等寬微米黑:style=Regular
/usr/share/fonts/windows/mingliu.ttc: MingLiU_HKSCS,細明體_HKSCS:style=Regular
/usr/share/fonts/windows/STCAIYUN.TTF: STCaiyun,華文彩雲:style=Regular
/usr/share/fonts/windows/mingliu.ttc: MingLiU,細明體:style=Regular
/usr/share/fonts/windows/STKAITI.TTF: STKaiti,華文楷體:style=Regular
/usr/share/fonts/X11/misc/wenquanyi_12ptb.pcf: WenQuanYi Bitmap Song:style=Bold		
		

測試Unicode檔案 xetex.tex

%!Tex Program = xelatex
\documentclass[a4paper]{article}
\usepackage{xltxtra}
\setmainfont[Mapping=tex-text]{WenQuanYi Micro Hei}
\begin{document}\pagestyle{empty}
\section{Unicode support}
 
\subsection{English}
All human beings are born free and equal in dignity and rights.
 
\subsection{Íslenska}
Hver maður er borinn frjáls og jafn öðrum að virðingu og réttindum.
 
\subsection{Русский}  
Все люди рождаются свободными
и равными в своем достоинстве и 
правах.
 
\subsection{Tiếng Việt}
Tất cả mọi người sinh ra đều được tự do và bình đẳng về nhân phẩm và 
quyền lợi.
 
\subsection{簡體中文}
每個人生來平等,享有相同的地位和權利。
 
\subsection{繁體中文}
每個人生來平等,享有相同的地位和權利。
 
\subsection{日本語}
すべての人間は自由であり、かつ、尊厳と権利とについて平等である。
 
\section{Legacy syntax}
When he goes---``Hello World!''\\
She replies—“Hello dear!”
 
\section{Ligatures}
\fontspec[Ligatures={Common, Historical}]{Linux Libertine O Italic}
\fontsize{12pt}{18pt}\selectfont Questo è strano assai!
 
\section{Numerals}
\fontspec[Numbers={OldStyle}]{Linux Libertine O}Old style: 1234567\\
\fontspec[Numbers={Lining}]{Linux Libertine O}Lining: 1234567
 
\end{document}		
		

測試字型

		
\documentclass[12pt,a4paper]{article}
\usepackage{fontspec,xunicode,xltxtra}
\usepackage{titlesec}
\usepackage[top=1in,bottom=1in,left=1.25in,right=1.25in]{geometry}

\titleformat{\section}{\Large\xbsong}{\thesection}{1em}{}

\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt

\newfontfamily\song{Simsun (Founder Extended)}
\newfontfamily\bwei{FZBeiWeiKaiShu-S19S}
\newfontfamily\zbhei{FZZhanBiHei-M22T}
\newfontfamily\xzt{FZXiaoZhuanTi-S13T}
\newfontfamily\xbsong{FZXiaoBiaoSong-B05}
\newfontfamily\dbsong{FZDaBiaoSong-B06}
\newfontfamily\gulif{FZGuLi-S12T}
\newfontfamily\gulij{FZGuLi-S12S}
\newfontfamily\kai{FZKai-Z03}
\newfontfamily\hei{FZHei-B01}
\newfontfamily\whei{WenQuanYi Zen Hei}
\newfontfamily\fsong{FZFangSong-Z02}
\newfontfamily\lanting{FZLanTingSong}
\newfontfamily\boya{FZBoYaSong}
\newfontfamily\lishu{FZLiShu-S01}
\newfontfamily\lishuII{FZLiShu II-S06}
\newfontfamily\yao{FZYaoTi-M06}
\newfontfamily\zyuan{FZZhunYuan-M02}
\newfontfamily\xhei{FZXiHei I-Z08}
\newfontfamily\xkai{FZXingKai-S04}
\newfontfamily\ssong{FZShuSong-Z01}
\newfontfamily\bsong{FZBaoSong-Z04}
\newfontfamily\nbsong{FZNew BaoSong-Z12}
\newfontfamily\caiyun{FZCaiYun-M09}
\newfontfamily\hanj{FZHanJian-R-GB}
\newfontfamily\songI{FZSongYi-Z13}
\newfontfamily\hcao{FZHuangCao-S09}
\newfontfamily\wbei{FZWeiBei-S03}
\newfontfamily\huali{FZHuaLi-M14}
\setmainfont{FZLanTingSong}

\renewcommand{\baselinestretch}{1.25}

\begin{document}

\title{\whei XeTeX使用小結}
\author{\fsong 何勃亮}
\date{\kai2009年6月21日}

\maketitle

\section{簡介}
以前使用CJK進行中文的排版,需要自己生成字型庫,近日,出現了XeTeX,可以比較好的解決中文字型問題,不需要額外
生成LaTeX字型庫,直接使用計算機系統裡的字型。

\section{字型列表}
本文使用了大量本機自帶的字型。


\begin{table}[htbp]
\caption{字型列表}

\centering
\begin{tabular}{|l|c|r|}
\hline
\hei 字型 & \hei 命令 & \hei 字型效果 \\
\hline
\kai 宋體 & \verb+\song+ & \song 宋體 \\
\kai 楷體 & \verb+\kai+ & \kai 楷體 \\
\kai 黑體 & \verb+\hei+ & \hei 黑體 \\
\kai 仿宋體 & \verb+\fsong+ & \fsong 仿宋體 \\
\kai 文泉驛黑體 & \verb+\whei+ & \whei 文泉驛黑體 \\
\kai 書宋體 & \verb+\ssong+ & \ssong 書宋體 \\
\kai 報宋體 & \verb+\bsong+ & \bsong 報宋體 \\
\kai 新報宋體 & \verb+\nbsong+ & \nbsong 新報宋體 \\
\kai 蘭亭宋體 & \verb+\lanting+ & \lanting 蘭亭宋體 \\
\kai 博雅宋體 & \verb+\boya+ & \boya 博雅宋體 \\
\kai 宋體一 & \verb+\songI+ & \songI 宋體一 \\
\kai 隷書 & \verb+\lishu+ & \lishu 隷書 \\
\kai 隷書二 & \verb+\lishuII+ & \lishuII 隷書二 \\
\kai 古隷簡體 & \verb+\gulij+ & \gulij 古隷簡體 \\
\kai 古隷繁體 & \verb+\gulif+ & \gulif 古隷繁體 \\
\kai 華隷書 & \verb+\huali+ & \huali 華隷書 \\
\kai 小標宋 & \verb+\xbsong+ & \xbsong 小標宋 \\
\kai 大標宋 & \verb+\dbsong+ & \dbsong 大標宋 \\
\kai 小篆體 & \verb+\xzt+ & \xzt 小篆體 \\
\kai 姚體 & \verb+\yao+ & \yao 姚體 \\
\kai 準圓 & \verb+\zyuan+ & \zyuan 準圓 \\
\kai 細黑一 & \verb+\xhei+ & \xhei 細黑一 \\
\kai 行楷書 & \verb+\xkai+ & \xkai 行楷書 \\
\kai 彩雲體 & \verb+\caiyun+ & \caiyun 彩雲體 \\
\kai 漢簡書 & \verb+\hanj+ & \hanj 漢簡書 \\
\kai 魏碑體 & \verb+\wbei+ & \wbei 魏碑體 \\
\hline
\end{tabular}
\end{table}

\end{document}
		
		

xelatex xetex.tex

15.1.4. LuaTeX

http://www.luatex.org/

		
sudo apt-get install texlive-luatex
		
		

15.1.5. FAQ

15.1.5.1. ! LaTeX Error: File `fontspec.sty' not found.

$ texdoc fontsepc
Sorry, no documentation found for fontsepc.
If you are unsure about the name, try searching CTAN's TeX catalogue at
http://ctan.org/search.html#byDescription.