如何使用 LaTeX 生成中文 PDF 文件
李 亚民(Li Yamin) yamin@computer.org
- 下载中文向量字库 (.ttf), 宋体, 仿宋, 黑体, 楷体等等, 假设放在 /home/yamin/cpdf/ 目录下
- 安装以下软件, 假设全部在 /home/yamin/cpdf/ 目录下完成
- cjk-4.5.1.tar.gz, Werner Lemberg 编写
- gbpfb-1.1.tar.gz, 陈向阳编写 (需要 freetype 软件包)
- 把 cjk 链接到 /usr/share/texmf/tex/latex/
# cd /usr/share/texmf/tex/latex/
# ln -s /home/yamin/cpdf/cjk-4.5.1/texinput cjk
- 生成向量字库的 tfm 和 pfb 文件, 例如
$ cd /home/yamin/cpdf/gbpfb-1.1/
$ gbpfb -c ../some-song-ti.ttf song
- 把 tfm 文件拷贝到 /usr/share/texmf/fonts/tfm/chinese/gbsong/ 目录
# cd /usr/share/texmf/fonts/tfm
# mkdir chinese
# cd chinese
# mkdir gbsong
# cd gbsong
# cp /home/yamin/cpdf/gbpfb-1.1/tfm/gbsong??.tfm .
- 把 pfb 文件拷贝到 /usr/share/texmf/fonts/type1/chinese/gbsong 目录
# cd /usr/share/texmf/fonts/type1
# mkdir chinese
# cd chinese
# mkdir gbsong
# cd gbsong
# cp /home/yamin/cpdf/gbpfb-1.1/fonts/gbsong??.pfb .
- 编写 gbsong.map 文件 (付录 1)
# cd /usr/share/texmf/vtex/config
# emacs gbsong.map &
- 把 gbsong.map 加到 pdftex.cfg 中 (付录 2)
# /usr/share/texmf/pdftex/config
# emacs pdftex.cfg &
- 参考 c19song.fd 编写 c19gbsong.fd
- 刷新 LaTeX 目录
# mktexlsr
- 编辑中文 tex 文件 (付录 3)
$ cd /home/yamin/cpdf/
$ emacs cpdf.tex &
- 编译中文 tex 文件
$ pdflatex cpdf.tex
- 显示中文 PDF 文件
$ acroread cpdf.pdf &
- 大功告成!
- 如果你还想要加入其它字库, 例如仿宋、楷体、黑体、隶书, 做法与上类似。
- 如果你想用它做 slides, 使用 slides.cls 及 pdfslides.sty (付录 4)。
- 付录 1: gbsong.map
gbsong01 GB-Song01 < gbsong01.pfb
gbsong02 GB-Song02 < gbsong02.pfb
... 中间自己填 ...
gbsong93 GB-Song93 < gbsong93.pfb
gbsong94 GB-Song94 < gbsong94.pfb
- 付录 2: pdftex.cfg
% Thomas Esser, 1998, 1999, public domain.
output_format 1
compress_level 9
decimal_digits 3
page_width 210truemm
page_height 297truemm
horigin 1truein
vorigin 1truein
% pdftex.map is set up by texmf/dvips/config/updmap
map pdftex.map
% This shows how to add your own map file.
% Remove the comment and adjust the name:
map +gbsong.map
- 付录 3: cpdf.tex
\documentclass[12pt]{article}
\usepackage{CJK}
\begin{document}
\CJKtilde
\begin{CJK*}{GBK}{gbsong}
\Huge 标准宋体
\end{CJK*}
\end{document}
- 付录 4: pdfslides.sty
%% pdfslides.sty for pdflatex slides.cls
\setlength\pdfpageheight{210mm}
\setlength\pdfpagewidth{280mm}
\setlength\textheight{175mm}
\setlength\textwidth {240mm}
\setlength\topmargin{-20mm}
\setlength\oddsidemargin{-6.3mm}
\setlength\leftmargini{25\p@}
\def\@listi{\leftmargin\leftmargini%
\topsep 3\p@ \@plus 1\p@ \@minus 1\p@%
\parsep\topsep%
\itemsep\parsep%
}
\let\@listii\@listi
\let\@listiii\@listii
%% End of file `pdfslides.sty'.
- 两个PDF文件的例子: chinese-latex.pdf 和 chinese-latex-slides.pdf