Ubuntu 安装TeXLive 2016并完成宏包更新

前端之家收集整理的这篇文章主要介绍了Ubuntu 安装TeXLive 2016并完成宏包更新前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

TeXLive在CTAN最新版本下载地址

https://www.tug.org/texlive/acquire-iso.html

页面下有texlive最新版本ISO种子问题下载链接

https://www.tug.org/texlive/files/texlive2016.iso.torrent

TeXLive在国内下载源很多,现仅以清华大学和阿里云为例。

https://mirrors.tuna.tsinghua.edu.cn/#

找到常用发行版 iso 和应用工具安装包直接下载,点击应用软件,TeXLive2016下载链接如下

https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/Images/texlive2016-20160523.iso

阿里云下载链接

http://mirrors.aliyun.com/CTAN/systems/texlive/Images/

选择对应版本下载即可。

下载可以使用wget下载,也可以在Windows上面将ISO文件复制到系统目录。

下载完成就可以挂载ISO镜像。

CTAN官方网站ISO挂载教程如下。

mount -t iso9660 -o ro,loop,noauto /yourISOFileDictory/texlive.iso /mnt

笔者挂载记录如下:

dell@DELL-Server:~$ sudo mount -o loop texlive2016.iso /mnt/
mount: /home/dell/texlive2016.iso is already mounted
dell@DELL-Server:~$ ls /mnt/
archive      install-tl               LICENSE.CTAN  readme-html.dir    release-texlive.txt  tlpkg
autorun.inf  install-tl-advanced.bat  LICENSE.TL    readme-txt.dir     source               tl-tray-menu.exe
index.html   install-tl-windows.bat   README        README.usergroups  texlive-doc
dell@DELL-Server:~$

安装命令

dell@DELL-Server:~$ cd /mnt/
dell@DELL-Server:/mnt$ sudo ./install-tl --gui

该命令可以在图形化界面下安装。

安装过程和完成截图如下。

安装界面有很多安装选项,无特殊要求直接点击安装texlive,等待安装过程完成。

完成安装后,卸载镜像。

sudo umount /mnt

也可以将ISO解压后复制到Linux系统。复制文件方法这里不再赘述。

增加环境变量。

# TeX Live 2016
#命令可以直接复制运行,每次运行一条命令
export TeXLiveMANPATH=/urs/local/texlive/2016/texmf-dist/doc/man
export TeXLiveINFOPATH=/usr/local/texlive/2016/texmf-dist/doc/info
#64位系统
export TeXLivePATH=/usr/local/texlive/2016/bin/x86_64-linux

具体安装路径请以安装时选择目录为准。

本机运行结果如下:

dell@DELL-Server:~$ export TeXLiveMANPATH=/urs/local/texlive/2016/texmf-dist/doc/man
dell@DELL-Server:~$ export TeXLiveINFOPATH=/usr/local/texlive/2016/texmf-dist/doc/info
dell@DELL-Server:~$ export TeXLivePATH=/usr/local/texlive/2016/bin/x86_64-linux
dell@DELL-Server:~$ echo $TeXLiveMANPATH
/urs/local/texlive/2016/texmf-dist/doc/man
dell@DELL-Server:~$ echo $TeXLiveINFOPATH
/usr/local/texlive/2016/texmf-dist/doc/info
dell@DELL-Server:~$ echo $TeXLivePATH
/usr/local/texlive/2016/bin/x86_64-linux
dell@DELL-Server:~$

建议安装前将Windows字体复制到Linux,复制字体方法和复制ISO解压后文件方法一样,等待字体安装完成后再安装texlive。

在Linux系统字体目录下创建winfonts文件夹(可选项),前提是已复制字体到Linux主机。

#创建Windows字体文件目录,目录名称自定义
dell@DELL-Server:~$ sudo mkdir /usr/share/fonts/WindowsFonts
#查看目录
dell@DELL-Server:~$ ls /usr/share/fonts/
cmap  opentype  truetype  type1  WindowsFonts  X11

复制字体到winfonts文件夹。

dell@DELL-Server:~$ sudo cp /home/dell/Fonts/* /usr/share/fonts/WindowsFonts/
#查看字体复制情况
dell@DELL-Server:~$ ls /usr/share/fonts/WindowsFonts/

安装字体命令。

dell@DELL-Server:mkfontscale
dell@DELL-Server:mkfontdir
dell@DELL-Server:sudo fc-cache -fv
dell@DELL-Server:~$ sudo fc-cache -fsv
/usr/share/fonts: caching,new cache contents: 0 fonts,6 dirs
/usr/share/fonts/WindowsFonts: caching,new cache contents: 1188 fonts,0 dirs
/usr/share/fonts/X11: caching,4 dirs
/usr/share/fonts/X11/Type1: caching,new cache contents: 8 fonts,0 dirs
/usr/share/fonts/X11/encodings: caching,1 dirs
/usr/share/fonts/X11/encodings/large: caching,0 dirs
/usr/share/fonts/X11/misc: caching,new cache contents: 59 fonts,0 dirs
/usr/share/fonts/X11/util: caching,0 dirs
/usr/share/fonts/cmap: caching,5 dirs
/usr/share/fonts/cmap/adobe-cns1: caching,0 dirs
/usr/share/fonts/cmap/adobe-gb1: caching,0 dirs
/usr/share/fonts/cmap/adobe-japan1: caching,0 dirs
/usr/share/fonts/cmap/adobe-japan2: caching,0 dirs
/usr/share/fonts/cmap/adobe-korea1: caching,0 dirs
/usr/share/fonts/opentype: caching,5 dirs
/usr/share/fonts/opentype/mondulkiri: caching,0 dirs
/usr/share/fonts/opentype/noto: caching,new cache contents: 36 fonts,0 dirs
/usr/share/fonts/opentype/opendyslexic: caching,new cache contents: 9 fonts,0 dirs
/usr/share/fonts/opentype/stix: caching,new cache contents: 29 fonts,0 dirs
/usr/share/fonts/opentype/stix-word: caching,new cache contents: 5 fonts,0 dirs
/usr/share/fonts/truetype: caching,new cache contents: 2 fonts,38 dirs
/usr/share/fonts/truetype/abyssinica: caching,new cache contents: 1 fonts,0 dirs
/usr/share/fonts/truetype/ancient-scripts: caching,0 dirs
/usr/share/fonts/truetype/arphic: caching,0 dirs
/usr/share/fonts/truetype/capture-it-elementary: caching,0 dirs
/usr/share/fonts/truetype/croscore: caching,new cache contents: 12 fonts,0 dirs
/usr/share/fonts/truetype/daniel-elementary: caching,new cache contents: 3 fonts,0 dirs
/usr/share/fonts/truetype/dejavu: caching,new cache contents: 21 fonts,0 dirs
/usr/share/fonts/truetype/fonts-guru-extra: caching,0 dirs
/usr/share/fonts/truetype/freefont: caching,0 dirs
/usr/share/fonts/truetype/hvd-bodedo-elementary: caching,0 dirs
/usr/share/fonts/truetype/jenna-sue-elementary: caching,0 dirs
/usr/share/fonts/truetype/kacst: caching,new cache contents: 15 fonts,0 dirs
/usr/share/fonts/truetype/kacst-one: caching,0 dirs
/usr/share/fonts/truetype/lao: caching,0 dirs
/usr/share/fonts/truetype/lato: caching,new cache contents: 18 fonts,0 dirs
/usr/share/fonts/truetype/liberation: caching,new cache contents: 16 fonts,0 dirs
/usr/share/fonts/truetype/limelight-elementary: caching,0 dirs
/usr/share/fonts/truetype/lobster-elementary: caching,0 dirs
/usr/share/fonts/truetype/lohit-punjabi: caching,0 dirs
/usr/share/fonts/truetype/nanum: caching,0 dirs
/usr/share/fonts/truetype/noto: caching,new cache contents: 175 fonts,0 dirs
/usr/share/fonts/truetype/open-sans-elementary: caching,new cache contents: 10 fonts,0 dirs
/usr/share/fonts/truetype/openoffice: caching,0 dirs
/usr/share/fonts/truetype/operating-instructions-elementary: caching,0 dirs
/usr/share/fonts/truetype/padauk: caching,new cache contents: 4 fonts,0 dirs
/usr/share/fonts/truetype/plainblack-elementary: caching,new cache contents: 6 fonts,0 dirs
/usr/share/fonts/truetype/raleway-elementary: caching,0 dirs
/usr/share/fonts/truetype/redacted-elementary: caching,0 dirs
/usr/share/fonts/truetype/roboto: caching,1 dirs
/usr/share/fonts/truetype/roboto/hinted: caching,0 dirs
/usr/share/fonts/truetype/roboto-mono-elementary: caching,0 dirs
/usr/share/fonts/truetype/sinhala: caching,0 dirs
/usr/share/fonts/truetype/takao-gothic: caching,0 dirs
/usr/share/fonts/truetype/takao-mincho: caching,0 dirs
/usr/share/fonts/truetype/tibetan-machine: caching,0 dirs
/usr/share/fonts/truetype/tlwg: caching,new cache contents: 58 fonts,0 dirs
/usr/share/fonts/truetype/ttf-khmeros-core: caching,0 dirs
/usr/share/fonts/truetype/ubuntu-font-family: caching,new cache contents: 13 fonts,0 dirs
/usr/share/fonts/truetype/unfonts-core: caching,0 dirs
/usr/share/fonts/type1: caching,1 dirs
/usr/share/fonts/type1/gsfonts: caching,new cache contents: 35 fonts,0 dirs
/usr/local/share/fonts: caching,0 dirs
Re-scanning /usr/share/fonts: caching,6 dirs
Re-scanning /usr/share/fonts/X11: caching,4 dirs
Re-scanning /usr/share/fonts/X11/encodings: caching,1 dirs
Re-scanning /usr/share/fonts/cmap: caching,5 dirs
Re-scanning /usr/share/fonts/opentype: caching,5 dirs
Re-scanning /usr/share/fonts/truetype: caching,38 dirs
Re-scanning /usr/share/fonts/truetype/roboto: caching,1 dirs
Re-scanning /usr/share/fonts/type1: caching,1 dirs
/var/cache/fontconfig: cleaning cache directory
fc-cache: succeeded
dell@DELL-Server:~$

Ubuntu网络安装TeXLive比较简单,只需要执行一条命令并等待安装完成。

首先要安装基础依赖软件。

sudo apt-get install libdigest-perl-md5-perl perl-tk
sudo apt install texlive-full

但该方法安装存在一个弊端,即不能更新宏包(包括所有Debian和Ubuntu发行版本)。

当我们执行命令

tlmgr update -all

我们可以使用

时会有报错。报错信息如下:

jiangjuan@OptiPlex-390:~$ tlmgr update --all
(running on Debian,switching to user mode!)
cannot setup TLPDB in /home/jiangjuan/texmf at /usr/bin/tlmgr line 5604.

其他tlmgr命令也无效。所以我们需要其他方法安装TeXLive。下文将加以介绍。

安装镜像中所有宏包均是打包时版本,部分软件包会在Ubuntu 安装源发布后更新,本方法可以解决安装源软件版本不能实时更新问题。部分Debian系发行版本执行tlmgr命令有问题,下文将给出一个解决方法

首先,执行命令:

#一定要安装perl-tk
sudo apt install git perl-tk

安装git客户端,git客户端可以克隆github代码到本地。git完成后如下图。

install-tl-ubuntuGitHub地址。

https://github.com/scottkosty/install-tl-ubuntu .

下面是重要环节,首先git 同步 install-tl-ubuntu代码到本机并安装。代码如下:

#克隆代码
git clone https://github.com/scottkosty/install-tl-ubuntu.git
#切换到安装目录
cd cd install-tl-ubuntu
#赋予安装文件可执行权限
chmod +x ./install-tl-ubuntu
#开始安装
sudo ./install-tl-ubuntu
#查看安装帮助文档,以下是部分帮助文档
jiangjuan@jiangjuan-machine:~/install-tl-ubuntu$ ./install-tl-ubuntu --help | more

  USAGE
  sudo ./install-tl-ubuntu [OPTIONS]

  DESCRIPTION
  This script uses the TeX Live 2016 installer to install TeX Live so that LaTeX
  packages can be updated through CTAN with tlmgr. To do this,the official TeX
  Live 2016 installer is downloaded and used and apt is informed that TeX
  dependencies are satisfied. Thus,when you want to install a program with
  apt-get that depends on TeX Live,apt will not try to install the TeX Live
  packages from the Ubuntu repositories.

  If this script detects a prevIoUs TeX Live installation installed to the same
  place (/opt/texbin),the link will be updated to the new installation but the
  old installation (the place /opt/texbin points to) will not be removed and
  should be removed manually by the user if desired.

  This script must be run with sudo. Many recommend not installing TeX Live with
  sudo,in which case this script must be altered (please send a patch or post
  an enhancement request).

--更多-

等待程序自动选择安装源并自完成安装,全程无需人工干预。

提示:需要注意该方法需要网络环境稳定,否则可能会出现反复重新安装情况。

程序安装完成后,开始菜单增加一个选项--TeXLive Package Manager,通过该软件可以完成宏包更新和管理等操作。

提示:软件功能bug可能会随着作者更新软件而修复。

安装完成后,检查软件安装情况,可以执行命令。

xelatex -version

LaTeX示例代码如下,Windows将代码直接复制到文本编辑器(记事本,notepad++等)中,另存为英文名称.tex(Linux没有该限制),可在文本编辑器中再次打开,或者直接通过命令编译。

\documentclass{book}
\usepackage{amsmath}
\usepackage{ctex}
%\usepackage{ctex}%(PDF)LaTeX编译方式请选择此行,注释上一行代码
\begin{document}
你好,中国。

勾股定律
$$a^2+b^2=c^2$$

Happy TeXing.
\end{document}

Linux系统可以将代码保存至/home/dell/文档/tex/Hello目录下,该目录是笔者电脑目录,可根据实际情况选择保存目录,或者放置到其他任意目录。

/home/dell/文档/tex/Hello/hello.tex

Linux编译文件操作步骤如下:

#切换到tex源文件目录
cd /home/dell/文档/Hello/
#xelatex命令编译文件,可选其他选项
xelatex hello.tex

等待编译过程完成即可。

下面贴出一个编译过程。

jiangjuan@jiangjuan-machine:~/test$ xelatex test.tex
This is XeTeX,Version 3.14159265-2.6-0.99992 (TeX Live 2015/Debian) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2016/02/01>
Babel <3.9q> and hyphenation patterns for 81 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/book.cls
Document Class: book 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/bk10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath,use the `?' option.
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/share/texlive/texmf-dist/tex/latex/ctex/ctex.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def))
(/usr/share/texlive/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty)
(/usr/share/texlive/texmf-dist/tex/latex/ctex/ctexhook.sty)
(/usr/share/texlive/texmf-dist/tex/latex/ctex/ctexpatch.sty)
(/usr/share/texlive/texmf-dist/tex/latex/base/fix-cm.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.def))
(/usr/share/texlive/texmf-dist/tex/latex/ms/everysel.sty)
(/usr/share/texlive/texmf-dist/tex/latex/ctex/config/ctexopts.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/ctex/engine/ctex-engine-xetex.def
(/usr/share/texlive/texmf-dist/tex/xelatex/xecjk/xeCJK.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty)
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/euenc/eu1enc.def)
(/usr/share/texlive/texmf-dist/tex/latex/euenc/eu1lmr.fd))
(/usr/share/texlive/texmf-dist/tex/xelatex/xunicode/xunicode.sty
(/usr/share/texmf/tex/latex/tipa/t3enc.def
(/usr/share/texlive/texmf-dist/tex/latex/euenc/eu1lmss.fd))
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/graphics.cfg)
(/usr/share/texlive/texmf-dist/tex/xelatex/xetex-def/xetex.def
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))))
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/share/texlive/texmf-dist/tex/xelatex/xecjk/xunicode-addon.sty)
(/usr/share/texlive/texmf-dist/tex/xelatex/xunicode/xunicode.sty
*** Reloading Xunicode for encoding 'EU1' ***
) (/usr/share/texlive/texmf-dist/tex/xelatex/xecjk/xunicode-extra.def)
(/usr/share/texlive/texmf-dist/tex/xelatex/xecjk/xeCJK.cfg))
(/usr/share/texlive/texmf-dist/tex/xelatex/xecjk/xeCJKfntef.sty
(/usr/share/texlive/texmf-dist/tex/generic/ulem/ulem.sty)
(/usr/share/texlive/texmf-dist/tex/latex/environ/environ.sty
(/usr/share/texlive/texmf-dist/tex/latex/trimspaces/trimspaces.sty))
(/usr/share/texmf/tex/latex/CJK/CJKfntef.sty)))
(/usr/share/texlive/texmf-dist/tex/latex/zhnumber/zhnumber.sty
(/usr/share/texlive/texmf-dist/tex/latex/zhnumber/zhnumber-utf8.cfg))
(/usr/share/texlive/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese.def
(/usr/share/texlive/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.cfg))
(/usr/share/texlive/texmf-dist/tex/latex/tools/indentfirst.sty)
(/usr/share/texlive/texmf-dist/tex/latex/ctex/ctex-c5size.clo)
(/usr/share/texlive/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-fandol.def
*************************************************
* fontspec warning: "script-not-exist"
*
* Font 'FandolSong-Regular' does not contain script 'CJK'.
*************************************************
)) (/usr/share/texlive/texmf-dist/tex/latex/ctex/config/ctex.cfg)
No file test.aux.
(/usr/share/texmf/tex/latex/tipa/t3cmr.fd)
ABD: EverySelectfont initializing macros

LaTeX Font Warning: Font shape `OMX/cmex/m/n' in size <10.53937> not available
(Font)              size <10.95> substituted on input line 6.

[1] (./test.aux)

LaTeX Font Warning: Size substitutions with differences
(Font)              up to 0.41063pt have occurred.

 )
Output written on test.pdf (1 page).
Transcript written on test.log.
jiangjuan@jiangjuan-machine:~/test$
#PDF生成正常
jiangjuan@jiangjuan-machine:~/test$ ls
test.aux  test.log  test.pdf  test.tex  WhoLogIn.sh
jiangjuan@jiangjuan-machine:~/test$

猜你在找的Ubuntu相关文章