第一步,安装latex,可以选择很多版本。
如文中所说的,texlive。
当然其它还有很多,没有试用过......
来自王越主页(安装texlive完整版):
http://mailboxpublic.googlepages.com/texlive2007cjkchinesehowto
方法一. Install TeXLive
_________________
First, install TeXLive.
unzip texlive2007-live-20070212.iso.zip
mount -o loop texlive2007-live-20070212.iso /mnt
cd /mnt
sudo ./install-tl
Setup System Path
_________________
Set the path. Take debian GNU/Linux as example, modify your /etc/environment like this and make a reboot:
PATH="/usr/local/texlive/2007/bin/i386-linux:/usr/local/matlab/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games"
方法二 打开终端,执行下述命令安装TexLive和常用的一些Latex宏包(可以根据自己的需要增改):
sudo apt-get install texlive texlive-math-extra texlive-latex-base texlive-latex-extra texlive-latex-recommended texlive-pictures texlive-science texlive-bibtex-extra texlive-common latex-beamer
如果硬盘充裕的话,直接完整安装也可以:
sudo apt-get install texlive-full latex-beamer
安装完后,就可以安装CJK的相关软件包了,如果只需要获得中文支持,那么执行:
sudo apt-get install latex-cjk-chinese ttf-arphic-* hbf-*
否则,建议安装latex-cjk-all以获取完整支持。
Copy The Files Needed
_________________
make a dir called font, copy the font here.
mkdir ~/font
cd ~/font
cp /media/sda/windows/Fonts/simhei.ttf .
copy all the files needed.
sudo apt-get install fontforge
cp /usr/local/texlive/2007/texmf-dist/source/latex/CJK/utils/subfonts/* ~/font/
cp /usr/local/texlive/2007/texmf/fonts/sfd/*.sfd ~/font/
步骤二 。生成字体(可选,或者进行步骤三)
方法一 Generate Font
______________
Then, make the font. It is a good way to test how fast your computer is :) it takes me 3 minutes to generate the fonts[Core Duo 2].
time fontforge -script subfonts.pe simhei.ttf hei Unicode.sfd
create a file name makemap like this:
for i in *.tfm
do
cat >> hei.map <<>
Make map file:
chmod +x makemap
./makemap
create a file name c70hei.fd for CJK package:
% This is c70hei.fd for CJK package.
% created by Edward G.J. Lee
% modify by Yue Wang
\ProvidesFile{c70hei.fd}
\DeclareFontFamily{C70}{hei}{\hyphenchar \font\m@ne}
\DeclareFontShape{C70}{hei}{m}{n}{<-> CJK * hei}{}
\DeclareFontShape{C70}{hei}{bx}{n}{<-> CJKb * hei}{\CJKbold}
\endinput
Copy Fonts into TEXMF
_________________
create the local directory to save the font
cd ~/.texlive2007
cd texmf-var
mkdir -p fonts/map/dvips/CJK
mkdir -p fonts/tfm/CJK/hei
mkdir -p fonts/type1/CJK/hei
mkdir -p tex/latex/CJK/UTF8
cp ~/font/hei.map fonts/map/dvips/CJK/
cp ~/font/*.tfm fonts/tfm/CJK/hei
cp ~/font/*.pfb fonts/type1/CJK/hei
cp ~/font/c70hei.fd tex/latex/CJK/UTF8
Update The System and Test
_____________________
Just run:
texhash
updmap --enable Map hei.map
create a test file to test your work.
\documentclass{article}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK}{UTF8}{hei}
你好!
\end{CJK}
\end{document}
latex test.tex
xdvi test.dvi
dvipdfm test.dvi
xpdf test.pdf
pdflatex test.pdf
......
http://linuxdesktop.cn/2008/02/26/config-texlive-cjk-under-ubuntu.html
简易安装
方法二、生成中文字体包
安装好TexLive+CJK以后,还需要安装一个软件──fontforge用于生成字体:
sudo apt-get install fontforge
好了,前面所做的,都是标准的Debian式安装,假如哪天你不需要了,直接remove安装即可。
生成字体前,请自己准备你需要生成的字体文件:simsun.ttc,simhei.ttf等,这里以simsun.ttc(宋体)为例。
准备好后下载下面这个包,解压到一个地方,如自己的主目录~/font:
然后把simsun.ttc也复制到~/font里去,执行下面的命令生成字体地图:
cd ~/font
time fontforge -script subfonts.pe simsun.ttc song Unicode.sfd
加time是为了计算时间,因为比较耗时,在我的Core 2 Duo T5500下,生成song花了40分钟,生成hei花了24分钟,仅供参考。
字体生成好了,再建立一个描述文件吧。
在~/font下,建立一个makemap文件,内容如下:
for i in *.tfm
do
cat >> song.map <<>
然后在终端下执行:chmod +x makemap让文件加上执行权限,最后执行:
./makemap
再建立一个一个c70song.fd文件:
% This is c70song.fd for CJK package.
% created by Edward G.J. Lee
% modify by Yue Wang
\ProvidesFile{c70song.fd}
\DeclareFontFamily{C70}{song}{\hyphenchar \font\m@ne}
\DeclareFontShape{C70}{song}{m}{n}{<-> CJK * song}{}
\DeclareFontShape{C70}{song}{bx}{n}{<-> CJKb * song}{\CJKbold}
\endinput
好的,相关文件都已生成,开始复制字体使其生效。
执行下面的命令,在你的主目录下生成隐藏的个人Tex配置,如果你哪天不需要了,也可以删除:
mkdir -p ~/.texmf-var/fonts/map/dvips/CJK
mkdir -p ~/.texmf-var/fonts/tfm/CJK/song
mkdir -p ~/.texmf-var/fonts/type1/CJK/song
mkdir -p ~/.texmf-var/tex/latex/CJK/UTF8
建立完这层层叠叠的目录以后,就把刚刚生成的字体复制进去吧。
cp ~/font/song.map ~/.texmf-var/fonts/map/dvips/CJK
cp ~/font/*.tfm ~/.texmf-var/fonts/tfm/CJK/song
cp ~/font/*.pfb ~/.texmf-var/fonts/type1/CJK/song
cp ~/font/c70song.fd ~/.texmf-var/tex/latex/CJK/UTF8
复制完后就执行命令刷新缓存,让它生效:
sudo texhash
updmap --enable Map song.map
假如一切顺序的话, 就测试一下我们安装的song体是否能用吧。
在任意位置编辑这个文件,然后保存为test.tex,支持UTF-8格式:
\documentclass{article}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK}{UTF8}{song}
你好!这里是Ubuntu下的TexLive+CJK环境!
\end{CJK}
\end{document}
执行分别生成pdf文档和用evince来查看文档:
pdflatex test.tex
evince test.pdf
看看你的过程顺不顺利,生成的PDF档也是下面这样吗?
用同样的方法搞定hei和kai等常用中文标准字体,开始享受你的Tex吧!
但是我在OpenSuse 11下此二方法均不可行。
看到解决方法一:
cp ~/font/song.map ~/.texmf-var/fonts/map/dvips/CJK
cp ~/font/*.tfm ~/.texmf-var/fonts/tfm/CJK/song
cp ~/font/*.pfb ~/.texmf-var/fonts/type1/CJK/song
cp ~/font/c70song.fd ~/.texmf-var/tex/latex/CJK/UTF8
改成:
su
cp ~/font/song.map /usr/share/texmf/fonts/map/dvips/CJK
cp ~/font/*.tfm /usr/share/texmf/fonts/tfm/CJK/song
cp ~/font/*.pfb /usr/share/texmf/fonts/type1/CJK/song
cp ~/font/c70song.fd /usr/share/texmf/tex/latex/CJK/UTF8
把
updmap –enable Map song.map
改成
sudo updmap –enable Map song.map
如果仍然不能出现中文,可以这么做,不保证好,只保证可以用!!
cp ~/font/song.map ~/.texmf-var/fonts/map/dvips/CJK
cp ~/font/*.tfm ~/.texmf-var/fonts/tfm/CJK/song
cp ~/font/*.pfb ~/.texmf-var/fonts/type1/CJK/song
cp ~/font/c70song.fd ~/.texmf-var/tex/latex/CJK/UTF8
and
cp ~/font/song.map /usr/share/texmf/fonts/map/dvips/CJK
cp ~/font/*.tfm /usr/share/texmf/fonts/tfm/CJK/song
cp ~/font/*.pfb /usr/share/texmf/fonts/type1/CJK/song
cp ~/font/c70song.fd /usr/share/texmf/tex/latex/CJK/UTF8
同时存在,应该就可以了。
步骤三:安装中文字体
这个东西我在网上翻腾了好久,终于在 http://bj.soulinfo.com/~hugang/tex/找到了 YueWang-zhfonts-final_1.01.tar.bz2 ,下载放到/home/yourname/目录下
$mv ~/.texlive2007 ~/.texlive2007.bak
$ tar jxvf ~/YueWang-zhfonts-final_1.01.tar.bz2
$ texhash
0 评论:
发表评论