Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1324568
  • 博文数量: 334
  • 博客积分: 10302
  • 博客等级: 上将
  • 技术积分: 2986
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-12 10:17
文章分类

全部博文(334)

文章存档

2013年(1)

2012年(9)

2011年(4)

2010年(10)

2009年(24)

2008年(64)

2007年(72)

2006年(150)

我的朋友

分类: LINUX

2007-01-25 09:17:49

tex中文自动配置脚本,适用于ubuntu系列
关键字: tex shellscript 原创哦,照ubuntu.cn坛子上的置顶贴写的,自用一直没有问题,分享一下
在ubuntu dubuntu hiweed下测试通过
在家目录新建文本文件texconf.sh并写入如下代码:

#!/bin/bash
# apt-get and config latex+CJK+CCT 自动安装latex+CJK+CCT脚本
# Author: if
# Version: 0.1.0 (testing version)
# update: 21/11/2006
#-----------------------------------------------------------------------------
# This program is a free software, you can redistribute it and/or modify
# it under the eterms of the GNU General Public Liscence as published by
# the Free Software Foundation; either version 2 or (at your option) any
# later version.
#
# This program is being distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public Liscence for more details.
# -----------------------------------------------------------------------------
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#>>脚本使用方法如下:
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#确定你已经联网,copy windows下的字体simsun.ttc,simhei.ttf,simfang.ttf,simkai.ttf到~/.fonts
#如果你是hiweed,这样已经实现了添加字体,只需要配置tex字体了。其他版本要在除tex外的程序中使用这些字体,还要另行配置。
#使用方法:
#$sudo chmod +x texconf.sh
#$sh texconf.sh
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
sudo apt-get install tetex-base tetex-bin tetex-extra cjk-latex
sudo apt-get install dvipdfm dvipdfm-cjk dvipdfmx fontforge
wget ftp://ftp.cc.ac.cn/pub/cct/Linux/cct_0.6180.2_i386.deb
sudo dpkg -i cct_0.6180.2_i386.deb
wget
tar -zxvf gbkfonts.tar.gz
chmod +x gbkfonts
sudo cp -p gbkfonts /usr/bin
sudo mkdir -p /usr/share/texmf/fonts/truetype/chinese
cd /usr/share/texmf/fonts/truetype/chinese/
#创建到~/.fonts目录下字体的联接档
ln -s ~/.fonts/simsun.ttc
ln -s ~/.fonts/simhei.ttf
ln -s ~/.fonts/simfang.ttf
ln -s ~/.fonts/simkai.ttf
cd /usr/share/texmf/
sudo gbkfonts fonts/truetype/chinese/simfang.ttf fs
sudo gbkfonts fonts/truetype/chinese/simsun.ttc song
sudo gbkfonts fonts/truetype/chinese/simkai.ttf kai
sudo gbkfonts fonts/truetype/chinese/simhei.ttf hei
sudo texhash
sudo updmap-sys --enable Map cjk.map
#end


保存
确定你已经联网,因为我的脚本要apt和wget,copy windows下的字体simsun.ttc,simhei.ttf,simfang.ttf,simkai.ttf到~/.fonts
如果你是hiweed,这样已经实现了添加字体,只需要配置tex字体了。其他版本要在除tex外的程序中使用这些字体,还要另行配置。
使用方法:
$sudo chmod +x texconf.sh
$sh texconf.sh
然后sh texconf.sh

然后就等着把

配置完之后,我们来测试一下。
用gedit写如下内容

\documentclass{article}
\usepackage{CJK}
\begin{document}
\begin{CJK}{GBK}{song}
这是latex
\end{CJK}
\end{document}

保存为gbk编码,注意是gbk哦,gedit里有选项的。
安装完成后用latex *.tex来编译cjk的TeX文件,用ctex *.tex来编译cct文件。然后用dvipdfmx *.dvi或者dvipdfm *.dvi(看看结果中哪个没有乱码)来转换成pdf
也可以一条命令出pdf:pdflatex *.tex

关于编辑器,vi和emacs都有插件,一搜就知道乐。如果这两个都不熟,可以使用kile,功能非常强大而且很好上手,还能像一般IDE一样补全代码,非常方便。但注意一定要保存为gbk编码,否则看不见汉字


阅读(1651) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~