标签:
如果系统没有安装过texlive,则跳过第0步。
可以在终端中使用如下命令查询本机已经安装的tex和latex版本:
[She@She LaTex_test]$ tex --version TeX 3.141592 (Web2C 7.5.6)
kpathsea version 3.5.6
Copyright 2007 D.E. Knuth.
Kpathsea is copyright 2007 Karl Berry and Olaf Weber. ... [She@She LaTex_test]$ latex --version pdfTeX using libpoppler 3.141592-1.40.3-2.2 (Web2C 7.5.6)
kpathsea version 3.5.6
Copyright 2007 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Kpathsea is copyright 2007 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清除完毕,重启电脑之后,就可以开始新版本的安装工作。
下载地址: http://mirror.hust.edu.cn/CTAN/systems/texlive/Images/texlive2015-20150523.iso,这是来自华中科技大学的镜像。
将下载的 texlive2015-20150523.iso 挂载到/mnt 目录下并运行 install-tl进行安装
1 sudo mount -o loop texlive2015-20150523.iso /mnt/tmp 2 cd /mnt/tmp 3 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 卸载.
1 cd ..2 sudo umount /mnt/tmp
texlive 默认的安装目录是/usr/local/texlive/2015/bin/x86_64-linux/ (64位系统)或.../i386-linux/ (32位系统),为了让 shell 能够自动找到 tex 的 bin 文件,我们需要修改环境变量 PATH。
如果我们希望系统也能够自动找到 texlive 的 man 或 info 文档,我们一并修改环境变量 MANPATH 和 INFOPATH。
在终端输入如下,编辑~/.bashrc文档:
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/man.config
1 sudo vi /etc/man.config
在# set up PATH to MANPATH mapping下输入
MANPATH_MAP /usr/local/texlive/2015/bin/x86_64-linux /usr/local/texlive/2015/texmf-dist/doc/man
重启。
(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 文件,然后输入下面内容
1 \documentclass{article} 2 \begin{document} 3 Hello \LaTeX! 4 \end{document}
然后运行下面命令即可生成 test.pdf。
1 [She@She LaTex_test]$ xelatex test.tex
双击打开 test.pdf,看到如下内容
现在,texlive可以正常工作。
(1) 创建Windows字体目录WinFonts和Adobe字体目录AdobeFonts。
1 sudo mkdir /usr/share/fonts/WinFonts 2 sudo mkdir /usr/share/fonts/AdobeFonts
WinFonts位于C:\Windows\fonts\文件夹下,只要ttf格式的中文字体;Adobe的字体则位于它的安装目录下,一个名叫font的文件夹内。
(2) 复制上述准备的字体到各自目录。
1 sudo cp /media/Ushe/WindowsFonts/* /usr/share/fonts/WinFonts 2 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) 刷新字体缓存
1 sudo mkfontscale 2 sudo mkfontdir 3 sudo fc-cache -fsv
(1) 查看系统中安装的中文字体的名字。
1 fc-list :lang=zh | sort
(2) 查看并根据生成的 fonts 编辑 ctex-xecjk-winfonts.def(如果不存在,则新建该文件)
1 sudo vi /usr/local/texlive/2015/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。
要使我们的texlive支持中文,我们使用ctex套装。
关于ctex的介绍见 http://www.ctex.org/HomePage。
texlive 安 装 包 默 认 携带 了 ctex 宏 包,ctex 宏 包 的 目 录 为/usr/local/texlive/2015/texmf-dist/tex/latex/ctex。
输入一个典型的中文支持例子测试,新建一个名为test.tex的文件,其内容如下:
\documentclass[UTF8]{ctexart} \begin{document} 这是我的第一个\TeX{}文件 \end{document}
用xelatex命令编译: [She@She LaTex_test]$ xelatex test.tex
结果如下,
我们新建一个 ctex.tex 文件,输入下面的内容
1 \documentclass{ctexart} 2 \begin{document} 3 您好,\LaTeX! 4 \end{document}
保存,然后运行下面命令,可以得到结果。
1 [She@She LaTex_test]$ xelatex ctex.tex
[1] http://www.tug.org/texlive/doc/texlive-zh-cn/texlive-zh-cn.pdf 《TEX Live 指南—2015》
[2] http://seisman.info/install-texlive-under-linux.html 《Linux下安装TeXLive 2015 》
[3] http://www.cnblogs.com/lienhua34/p/3675027.html 《ubuntu 下安装 texlive 并设置 ctex 中文套装》
本文为原创,转载请注明。
标签:
原文地址:http://www.cnblogs.com/onemorepoint/p/5632500.html