CentOS6.5 下安装 texlive2015 并设置 ctex 中文套装
写在前面:用红色字体标出的是CentOS7 下安装 TexLive2017 的记录,参考自《Linux 下安装 TeXLive 2017》。
-1 参考资料
[1] http://www.tug.org/texlive/doc/texlive-zh-cn/texlive-zh-cn.pdf 《TEX Live 指南—2015》
[2] http://www.cnblogs.com/lienhua34/p/3675027.html 《ubuntu 下安装 texlive 并设置 ctex 中文套装》
[3] http://seisman.info/install-texlive-under-linux.html 《Linux下安装TeXLive 2015》
[4] http://seisman.info/install-texlive-under-linux.html 《Linux 下安装 TeXLive 2017》
0 卸载旧版本的 texlive
0.1 卸载 texlive2007
如果系统没有安装过texlive,则跳过第0步。
可以在终端中使用如下命令查询本机已经安装的tex和latex版本:
[She@She LaTex_test]$ tex --version
TeX 3.141592 (Web2C 7.5.)
kpathsea version 3.5.6
Copyright D.E. Knuth.
Kpathsea is copyright Karl Berry and Olaf Weber.
...
[She@She LaTex_test]$ latex --version
pdfTeX using libpoppler 3.141592-1.40.-2.2 (Web2C 7.5.)
kpathsea version 3.5.6
Copyright Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Kpathsea is copyright Karl Berry and Olaf Weber.
...
通常,采用系统命令 1 sudo yum install texlive-latex ,自动安装的texlive的版本都比较旧。
如果查到的版本太旧,则手动卸载和删除它们,在终端中依次执行如下命令:
1 sudo yum remove texlive-latex
2 sudo rm -rf /usr/local/texlive/2015
3 sudo rm -rf ~/.texlive2015
4 sudo rm -rf /usr/local/share/texmf
5 sudo rm -rf /var/lib/texmf
6 sudo rm -rf /etc/texmf
7 sudo rm -rf /usr/share/texmf
8 sudo rm -rf /usr/share/texmf-errata
9 sudo yum remove tex-common
10 sudo rm -rf ~/.texlive
至此,系统上的texlive清除完毕,重启电脑之后,就可以开始新版本的安装工作。
1 安装 texlive2015
1.1 下载 texlive2015
下载地址: http://mirror.hust.edu.cn/CTAN/systems/texlive/Images/texlive2015-20150523.iso,这是来自华中科技大学的镜像。
CentOS7 下安装 TexLive2017:华中科技大学的镜像下载速度太慢,改为下载官方镜像。
1.2 挂载 iso并安装texlive2015
将下载的 texlive2015-20150523.iso 挂载到/mnt 目录下并运行 install-tl 进行安装
sudo mount -o loop texlive2015-.iso /mnt/tmp
cd /mnt/tmp
sudo ./install-tl
出现选项之后,输入 I 直接安装即可,几分钟即可安装完毕。
[She@She tmp]$ sudo ./install-tl
Loading ./tlpkg/texlive.tlpdb
Installing TeX Live 2015 from: .
Platform: x86_64-linux => 'GNU/Linux on x86_64'
Distribution: inst (compressed)
Directory for temporary files: /tmp ======================> TeX Live installation procedure <===================== ======> Letters/digits in <angle brackets> indicate <=======
======> menu items for commands or options <======= Detected platform: GNU/Linux on x86_64 <B> binary platforms: 1 out of 14 <S> set installation scheme (scheme-full) <C> customizing installation collections
47 collections out of 48, disk space required: 4044 MB <D> directories:
TEXDIR (the main TeX directory):
/usr/local/texlive/2015
TEXMFLOCAL (directory for site-wide local files):
/usr/local/texlive/texmf-local
TEXMFSYSVAR (directory for variable and automatically generated data):
/usr/local/texlive/2015/texmf-var
TEXMFSYSCONFIG (directory for local config):
/usr/local/texlive/2015/texmf-config
TEXMFVAR (personal directory for variable and automatically generated data):
~/.texlive2015/texmf-var
TEXMFCONFIG (personal directory for local config):
~/.texlive2015/texmf-config
TEXMFHOME (directory for user-specific files):
~/texmf <O> options:
[ ] use letter size instead of A4 by default
[X] allow execution of restricted list of programs via \write18
[X] create all format files
[X] install macro/font doc tree
[X] install macro/font source tree
[ ] create symlinks to standard directories
[X] after install, use tlnet on CTAN for package updates <V> set up for portable installation Actions:
<I> start installation to hard disk
<H> help
<Q> quit Enter command: I
安装完成之后, 提示如下:
...
Installing [3051/3056, time/total: 06:07/06:07]: zlmtt [56k]
Installing [3052/3056, time/total: 06:07/06:07]: zwgetfdate [242k]
Installing [3053/3056, time/total: 06:07/06:07]: zwpagelayout [587k]
Installing [3054/3056, time/total: 06:07/06:07]: zxjafbfont [3k]
Installing [3055/3056, time/total: 06:07/06:07]: zxjafont [136k]
Installing [3056/3056, time/total: 06:07/06:07]: zxjatype [142k]
Time used for installing the packages: 06:07
running mktexlsr /usr/local/texlive/2015/texmf-dist ...
mktexlsr: Updating /usr/local/texlive/2015/texmf-dist/ls-R...
mktexlsr: Done.
writing fmtutil.cnf to /usr/local/texlive/2015/texmf-dist/web2c/fmtutil.cnf
writing updmap.cfg to /usr/local/texlive/2015/texmf-dist/web2c/updmap.cfg
writing language.dat to /usr/local/texlive/2015/texmf-var/tex/generic/config/language.dat
writing language.def to /usr/local/texlive/2015/texmf-var/tex/generic/config/language.def
writing language.dat.lua to /usr/local/texlive/2015/texmf-var/tex/generic/config/language.dat.lua
running mktexlsr /usr/local/texlive/2015/texmf-var /usr/local/texlive/2015/texmf-config /usr/local/texlive/2015/texmf-dist ...
mktexlsr: Updating /usr/local/texlive/2015/texmf-config/ls-R...
mktexlsr: Updating /usr/local/texlive/2015/texmf-dist/ls-R...
mktexlsr: Updating /usr/local/texlive/2015/texmf-var/ls-R...
mktexlsr: Done.
running updmap-sys --nohash ...done
re-running mktexlsr /usr/local/texlive/2015/texmf-var /usr/local/texlive/2015/texmf-config ...
mktexlsr: Updating /usr/local/texlive/2015/texmf-config/ls-R...
mktexlsr: Updating /usr/local/texlive/2015/texmf-var/ls-R...
mktexlsr: Done.
setting up ConTeXt cache: running mtxrun --generate ...done
pre-generating all format files, be patient...
running fmtutil-sys --no-error-if-no-engine=luajittex --all ...done
running package-specific postactions
finished with package-specific postactions See
/usr/local/texlive/2015/index.html
for links to documentation. The TeX Live web site
contains updates and corrections: http://tug.org/texlive. TeX Live is a joint project of the TeX user groups around the world;
please consider supporting it by joining the group best for you. The
list of user groups is on the web at http://tug.org/usergroups.html. Add /usr/local/texlive/2015/texmf-dist/doc/info to INFOPATH.
Add /usr/local/texlive/2015/texmf-dist/doc/man to MANPATH
(if not dynamically found). Most importantly, add /usr/local/texlive/2015/bin/x86_64-linux
to your PATH for current and future sessions. Welcome to TeX Live!
Logfile: /usr/local/texlive/2015/install-tl.log
[She@She tmp]$
至此,texlive2015已经成功安装。
将 texlive2015-20150523.iso 卸载.
cd ..
sudo umount /mnt/tmp
1.3 修改环境变量
texlive 默认的安装目录是/usr/local/texlive/2015/bin/x86_64-linux/ (64位系统)或.../i386-linux/ (32位系统),为了让 shell 能够自动找到 tex 的 bin 文件,我们需要修改环境变量 PATH。
如果我们希望系统也能够自动找到 texlive 的 man 或 info 文档,我们一并修改环境变量 MANPATH 和 INFOPATH。
在终端输入如下,编辑 $HOME/.bashrc 文档 或 $HOME/.bash_profile 或 /etc/profile.d/texlive2017.sh (三个文档只需修改其中一个) :
vim ~/.bashrc
或 在 ~/.bashrc 中添加下面的内容:
PATH=/usr/local/texlive/2015/bin/x86_64-linux:$PATH; export PATH
MANPATH=/usr/local/texlive/2015/texmf-dist/doc/man:$MANPATH; export MANPATH
INFOPATH=/usr/local/texlive/2015/texmf-dist/doc/man:$INFOPATH; export INFOPATH
又或 在 /etc/profile.d/texlive2017.sh 中添加以下内容:
#!/bin/bash
# setting for TexLive environment variables, edit by She
export PATH="/usr/local/texlive/2017/bin/x86_64-linux":$PATH
export MANPATH="/usr/local/texlive/2017/texmf-dist/doc/man":$MANPATH
export INFOPATH="/usr/local/texlive/2017/texmf-dist/doc/info":$INFOPATH
export TEXINPUTS="/usr/local/texlive/2017/texmf-dist/tex/latex/latexconfig"
export TEXMF="/usr/local/texlive/2017/texmf-dist"
接着,修改/etc/man.config (CentOS7对应的是这个文件: sudo gedit /etc/man_db.conf )
sudo vi /etc/man.config
在# set up PATH to MANPATH mapping下输入 (注意:中间的空白部分不是空格,而是Tab分隔符)
MANPATH_MAP /usr/local/texlive/2015/bin/x86_64-linux /usr/local/texlive/2015/texmf-dist/doc/man
重启。
1.4 测试安装是否成功
(1)首先确认我们安装的 tex 和latex 版本
[She@She tmp]$ tex --version
TeX 3.14159265 (TeX Live 2015)
kpathsea version 6.2.1
Copyright 2015 D.E. Knuth.
[She@She tmp]$ latex --version
pdfTeX 3.14159265-2.6-1.40.16 (TeX Live 2015)
kpathsea version 6.2.1
Copyright 2015 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
(2)编写一个简单的 tex 文件,然后编译它
新建一个 test.tex 文件,然后输入下面内容
\documentclass{article}
\begin{document}
Hello \LaTeX!
\end{document}
然后运行下面命令即可生成 test.pdf。
[She@She LaTex_test]$ xelatex test.tex
双击打开 test.pdf,看到如下内容
现在,texlive可以正常工作。
2 配置中文环境和中文字体安装
2.1 拷贝Windows字体
(1) 创建Windows字体目录WinFonts和Adobe字体目录AdobeFonts。
sudo mkdir /usr/share/fonts/WinFonts
sudo mkdir /usr/share/fonts/AdobeFonts
WinFonts位于C:\Windows\fonts\文件夹下,只要ttf、TTF、ttc 和 TTC 格式的中文字体(SimSun字体对应的文件是 simsun.ttc);Adobe的字体则位于它的安装目录下,一个名叫font的文件夹内。
(2) 复制上述准备的字体到各自目录。
sudo cp /media/Ushe/WindowsFonts/* /usr/share/fonts/WinFonts
sudo cp /media/Ushe/AdobeFonts/* /usr/share/fonts/AdobeFonts
这里需要注意:修改上面拷贝字体的权限
sudo chmod 644 /usr/share/fonts/WinFonts/*
sudo chmod 644 /usr/share/fonts/AdobeFonts/*
如果没有这一步,会在编译tex文件时出现下面类似的错误:
SimSun at 17.28pt not loadable
(3) 刷新字体缓存
sudo mkfontscale
sudo mkfontdir
sudo fc-cache -fsv
2.2 安装中文字体后的配置
(1) 查看系统中安装的中文字体的名字。
fc-list :lang=zh | sort
(2) 查看并根据生成的 fonts 编辑 ctex-xecjk-winfonts.def(如果不存在,则新建该文件)[CentOS7 中安装 TexLive2017 时,可略过这一步]
sudo vi /usr/local/texlive//texmf-dist/tex/latex/ctex/fontset/ctex-xecjk-winfonts.def
编辑前ctex-xecjk-winfonts.def如下:
% ctex-xecjk-winfonts.def: Windows 的 xeCJK 字体设置,默认为六种中易字体
%vim:ft=tex/setCJKmainfont[BoldFont={SimHei},ItalicFont={[simkai.ttf]}]
{SimSun}
/setCJKsansfont{SimHei}
/setCJKmonofont{[simfang.ttf]}
/setCJKfamilyfont{zhsong}{SimSun}
/setCJKfamilyfont{zhhei}{SimHei}
/setCJKfamilyfont{zhkai}{[simkai.ttf]}
/setCJKfamilyfont{zhfs}{[simfang.ttf]}
/newcommand*{/songti}{/CJKfamily{zhsong}} % 宋体
/newcommand*{/heiti}{/CJKfamily{zhhei}} % 黑体
/newcommand*{/kaishu}{/CJKfamily{zhkai}} % 楷书
/newcommand*{/fangsong}{/CJKfamily{zhfs}} % 仿宋
/newcommand*{/lishu}{/CJKfamily{zhli}} % 隶书
/newcommand*{/youyuan}{/CJKfamily{zhyou}} % 幼圆
/endinput
编辑后 ctex-xecjk-winfonts.def 的内容:
% ctex-xecjk-winfonts.def: Windows 的 xeCJK 字体设置,默认为六种中易字体
% vim:ft=tex
/setCJKmainfont[BoldFont={SimHei},ItalicFont={KaiTi}] {SimSun}
/setCJKsansfont{SimHei}
/setCJKmonofont{FangSong}
/setCJKfamilyfont{zhsong}{SimSun}
/setCJKfamilyfont{zhhei}{SimHei}
/setCJKfamilyfont{zhkai}{KaiTi}
/setCJKfamilyfont{zhfs}{FangSong}
/setCJKfamilyfont{zhli}{LiSu}
/setCJKfamilyfont{zhyou}{YouYuan}
/newcommand*{/songti}{/CJKfamily{zhsong}} % 宋体
/newcommand*{/heiti}{/CJKfamily{zhhei}} % 黑体
/newcommand*{/kaishu}{/CJKfamily{zhkai}} % 楷书
/newcommand*{/fangsong}{/CJKfamily{zhfs}} % 仿宋
/newcommand*{/lishu}{/CJKfamily{zhli}} % 隶书
/newcommand*{/youyuan}{/CJKfamily{zhyou}} % 幼圆
/endinput
(3) 同上.查看并根据生成的fonts文件修改ctex-xecjk-adobefonts.def。
3 测试ctex中文套装
要使我们的texlive支持中文,我们使用ctex套装。
关于ctex的介绍见 http://www.ctex.org/HomePage。
texlive 安 装 包 默 认 携带 了 ctex 宏 包,ctex 宏 包 的 目 录 为/usr/local/texlive/2015/texmf-dist/tex/latex/ctex。
3.1 测试1
输入一个典型的中文支持例子测试,新建一个名为test.tex的文件,其内容如下:
\documentclass[UTF8]{ctexart}
\begin{document}
这是我的第一个\TeX{}文件
\end{document}
用xelatex命令编译: [She@She LaTex_test]$ xelatex test.tex
结果如下,
3.2 测试2
我们新建一个 ctex.tex 文件,输入下面的内容
\documentclass{ctexart}
\begin{document}
您好,\LaTeX!
\end{document}
保存,然后运行下面命令,可以得到结果。
[She@She LaTex_test]$ xelatex ctex.tex
4 更新源配置
配置合适的CTAN源可以加快宏包更新的网速,以中科大的源为例:
$ su
密码:
[root@localhost She]# tlmgr option repository http://mirrors.ustc.edu.cn/CTAN/systems/texlive/tlnet
tlmgr: setting default package repository to http://mirrors.ustc.edu.cn/CTAN/systems/texlive/tlnet
之后,可以利用 tlmgr
进行网络更新。CTAN 上的包更新很频繁,所以即便是最新版的 texlive2017,其中也有大量的宏包需要更新(可能包括 tlmgr 程序本身)
[root@localhost She]# tlmgr update --self # 更新 TeXLive 包管理器 tlmgr
tlmgr: package repository http://mirrors.ustc.edu.cn/CTAN/systems/texlive/tlnet (verified)
tlmgr: saving backups to /usr/local/texlive/2017/tlpkg/backups
[1/1, ??:??/??:??] update: texlive.infra [339k] (44424 -> 44836) ... done
running mktexlsr ...
done running mktexlsr.
running mtxrun --generate ...
done running mtxrun --generate.
tlmgr: package log updated: /usr/local/texlive/2017/texmf-var/web2c/tlmgr.log
[root@localhost She]# tlmgr update --all # 更新 TeXLive 的全部包
tlmgr: package repository http://mirrors.ustc.edu.cn/CTAN/systems/texlive/tlnet (verified)
tlmgr: saving backups to /usr/local/texlive/2017/tlpkg/backups
[ 1/192] auto-remove: rputover ... done
[ 2/192, ??:??/??:??] update: GS1 [1125k] (27540 -> 44822) ... done
[ 3/192, 00:05/15:54] update: acmart [6410k] (44367 -> 44745) ... done
[ 4/192, 00:10/04:44] update: acro [595k] (43186 -> 44667) ... done
[ 5/192, 00:13/05:43] update: actuarialsymbol [293k] (43768 -> 44607) ... done
[ 6/192, 00:25/10:36] update: adobemapping [1944k] (44085 -> 44861) ... done
[ 7/192, 00:28/09:39] update: algorithm2e [579k] (38805 -> 44846) ... done
[ 8/192, 00:29/09:28] update: apa6 [602k] (42516 -> 44652) ... done
[ 9/192, 00:31/09:36] update: apxproof [452k] (43527 -> 44478) ... done
...
[189/192, 07:52/07:52] update: collection-luatex [1k] (42670 -> 44500) ... done
[190/192, 07:53/07:53] update: collection-pictures [2k] (44395 -> 44823) ... done
[191/192, 07:54/07:54] update: collection-pstricks [1k] (44305 -> 44742) ... done
[192/192, 07:55/07:55] update: collection-publishers [2k] (44026 -> 44485) ... done
running mktexlsr ...
done running mktexlsr.
running mtxrun --generate ...
done running mtxrun --generate.
running updmap-sys ...
done running updmap-sys.
regenerating fmtutil.cnf in /usr/local/texlive/2017/texmf-dist
running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine xetex ...
done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine xetex.
running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --no-error-if-no-format --byengine euptex ...
...
running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --byfmt latex ...
done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --byfmt latex.
running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --byfmt platex ...
done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --byfmt platex.
...
running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --byfmt pdfxmltex ...
done running fmtutil-sys --no-error-if-no-engine=luajittex,mfluajit --byfmt pdfxmltex.
...
tlmgr: package log updated: /usr/local/texlive/2017/texmf-var/web2c/tlmgr.log
最后,利用 texhash 命令进行位置的更新:
[root@localhost She]# texhash
texhash: Updating /usr/local/texlive/2017/texmf-config/ls-R...
texhash: Updating /usr/local/texlive/2017/texmf-dist/ls-R...
texhash: Updating /usr/local/texlive/2017/texmf-var/ls-R...
texhash: Updating /usr/local/texlive/texmf-local/ls-R...
texhash: Done.
更新完成。
CentOS6.5 下安装 texlive2015 并设置 ctex 中文套装的更多相关文章
- ubuntu 下安装 texlive 并设置 ctex 中文套装
1 安装 texlive2013 1.1 下载 texlive2013 下载地址:http://ftp.ctex.org/mirrors/CTAN/systems/texlive/Images/tex ...
- CentOS6.8下安装memcached并设置开机自启动
参考资料:http://www.cnblogs.com/handongyu/p/6419305.html http://coolnull.com/1986.html 一.安装libevent 首 ...
- 【转载】CentOS6.5_X64下安装配置MongoDB数据库
[转载]CentOS6.5_X64下安装配置MongoDB数据库 2014-05-16 10:07:09| 分类: 默认分类|举报|字号 订阅 下载LOFTER客户端 本文转载自zhm&l ...
- CentOS6.5下安装配置MySQL
CentOS6.5下安装配置MySQL,配置方法如下: 安装mysql数据库:# yum install -y mysql-server mysql mysql-deve 查看mysql-server ...
- 建站笔记1:centos6.5下安装mysql
近期买了个域名,想要玩玩自己建站点:接下来遇到的问题都会一次记录下来.以备自己以后复习查看: 首先建站方案选择: wordPress +centos6.5 +mysql; server买的:搬瓦工最低 ...
- centos6.7下安装配置vnc
vnc是一款使用广泛的服务器管理软件,可以实现图形化管理,下面简单介绍一下如何在centos6.7下安装vnc. 1.安装vncserver yum install tigervnc tigervnc ...
- CentOS6.5下安装JDK1.7+MYSQL5.5+TOMCAT7+nginx1.7.5环境安装文档
----------------CentOS6.5下安装JDK1.7+MYSQL5.5+TOMCAT7+nginx1.7.5环境安装文档----------------------- [JDK1.7安 ...
- CentOS6.5下安装apache2.2和PHP 5.5.28
CentOS6.5下安装apache2.2 1. 准备程序 :httpd-2.2.27.tar.gz 下载地址:http://httpd.apache.org/download.cgi#apache2 ...
- CentOS6.5下安装Apache2.4+PHP7
CentOS6.5下安装Apache2.4+PHP7 http://blog.csdn.net/along602/article/details/42695779 http://www.th7.cn/ ...
随机推荐
- MySQL int(11)及int(M)解析
默认创建int类型的字段,SHOW CREATE TABLE table_name或DESC table_name常常可以看到其默认情况为int(11). 这个int(M)很多时候都会被误解为最大范围 ...
- 讯时网关IP对接PBX
先配置呼入 1.在网关的中继线绑定号码 2.在路由表写入到PBX 路由到 pbx IP 绑定的号码和路由的 fxo后面的数字要一致 3.在PBX 建一个sip中继,host为网关IP 4.创 ...
- UVA 11384 正序数排列
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- Mifare系列4-组成(转)
文/闫鑫原创转载请注明出处http://blog.csdn.net/yxstars/article/details/38081241 MIFARE集成电路芯片内含EEPROM.RF接口和数字控制单元. ...
- 关于tomcat访问managerapp出现403报错的解决方法
最近工作需要在tomct下部署war包并访问. 学了几种方法后想从Tomcat Web Application Manager去部署. 但是启动tomcat后浏览器http://localhost:8 ...
- (转)awk实例练习(二)
文章转自 http://www.cnblogs.com/zhuyp1015/archive/2012/07/14/2591842.html 先来总结一下awk内置变量: ARGC 命 ...
- AnguarJS测试的实施步骤整理
最近开发用到了AngularJS,据说目前大型系统都用这个作为前端.最近参与的一个项目,web部分重度使用了AngularJS,整个前端架构有组织有纪律.所谓的有纪律就是说,有比较完善的测试用例,用上 ...
- python 03
数据结构 在 python 中有4种内建数据结构, 列表, 元组, 字典和集合. 列表 list 有序项目的数据结构, 类似数组, 是对象. 列表用中括号中用逗号分隔的项目定义.例如 ['apple' ...
- jquery ajax的error错误信息
项目开发中ajax的异常处理起来算是比较头疼的,因为是异步请求,所以即使ajax异常程序依然会继续执行,导致找ajax的异常比较麻烦. 今天处理ajax异常时搜到一篇文章,提到error可以返回aja ...
- servlet学习笔记_2
一.Servlet线程安全问题1.servlet的线程安全问题.servlet引擎采用多线程的模式运行,它为并发的每个访问请求都预备一个线程来相应,但是由于只有一个servlet对象,因此,如果多个线 ...