LaTeX技巧892: Ubuntu 安裝新版本TeXLive並更新

原文地址:http://www.latexstudio.net/archives/9788.htmlhtml

摘要: 本文比較系統地介紹了在Ubuntu下的TeXLive的安裝與配置測試過程,建議使用Ubuntu的重度LaTeX用戶能夠看看該文章,另外,文章中也解決了烏班圖安裝TeXLive並更新問題。 TeXLive在CTAN最新版本下載地址linux

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

該頁面下有texlive最新版本ISO種子問題下載連接。nginx

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

TeXLive在國內下載源不少,現僅以清華大學和阿里云爲例。git

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

  找到經常使用發行版 iso 和應用工具安裝包直接下載,點擊應用軟件,TeXLive2016下載連接以下github

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

阿里雲下載連接:ubuntu

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

選擇對應版本下載便可。 下載可使用wget下載,也能夠在Windows上面將ISO文件複製到系統目錄。 下載完成就能夠掛載ISO鏡像。 CTAN官方網站ISO掛載教程以下。windows

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:~$

安裝命令app

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, new cache contents: 0 fonts, 4 dirs
/usr/share/fonts/X11/Type1: caching, new cache contents: 8 fonts, 0 dirs
/usr/share/fonts/X11/encodings: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/X11/encodings/large: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/X11/misc: caching, new cache contents: 59 fonts, 0 dirs
/usr/share/fonts/X11/util: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/cmap: caching, new cache contents: 0 fonts, 5 dirs
/usr/share/fonts/cmap/adobe-cns1: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/cmap/adobe-gb1: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/cmap/adobe-japan1: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/cmap/adobe-japan2: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/cmap/adobe-korea1: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/opentype: caching, new cache contents: 0 fonts, 5 dirs
/usr/share/fonts/opentype/mondulkiri: caching, new cache contents: 8 fonts, 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, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/arphic: caching, new cache contents: 8 fonts, 0 dirs
/usr/share/fonts/truetype/capture-it-elementary: caching, new cache contents: 2 fonts, 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, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/freefont: caching, new cache contents: 12 fonts, 0 dirs
/usr/share/fonts/truetype/hvd-bodedo-elementary: caching, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/jenna-sue-elementary: caching, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/kacst: caching, new cache contents: 15 fonts, 0 dirs
/usr/share/fonts/truetype/kacst-one: caching, new cache contents: 2 fonts, 0 dirs
/usr/share/fonts/truetype/lao: caching, new cache contents: 1 fonts, 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, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/lobster-elementary: caching, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/lohit-punjabi: caching, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/nanum: caching, new cache contents: 8 fonts, 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, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/operating-instructions-elementary: caching, new cache contents: 1 fonts, 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, new cache contents: 9 fonts, 0 dirs
/usr/share/fonts/truetype/redacted-elementary: caching, new cache contents: 3 fonts, 0 dirs
/usr/share/fonts/truetype/roboto: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/truetype/roboto/hinted: caching, new cache contents: 18 fonts, 0 dirs
/usr/share/fonts/truetype/roboto-mono-elementary: caching, new cache contents: 10 fonts, 0 dirs
/usr/share/fonts/truetype/sinhala: caching, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/takao-gothic: caching, new cache contents: 3 fonts, 0 dirs
/usr/share/fonts/truetype/takao-mincho: caching, new cache contents: 3 fonts, 0 dirs
/usr/share/fonts/truetype/tibetan-machine: caching, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/tlwg: caching, new cache contents: 58 fonts, 0 dirs
/usr/share/fonts/truetype/ttf-khmeros-core: caching, new cache contents: 2 fonts, 0 dirs
/usr/share/fonts/truetype/ubuntu-font-family: caching, new cache contents: 13 fonts, 0 dirs
/usr/share/fonts/truetype/unfonts-core: caching, new cache contents: 12 fonts, 0 dirs
/usr/share/fonts/type1: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/type1/gsfonts: caching, new cache contents: 35 fonts, 0 dirs
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
Re-scanning /usr/share/fonts: caching, new cache contents: 0 fonts, 6 dirs
Re-scanning /usr/share/fonts/X11: caching, new cache contents: 0 fonts, 4 dirs
Re-scanning /usr/share/fonts/X11/encodings: caching, new cache contents: 0 fonts, 1 dirs
Re-scanning /usr/share/fonts/cmap: caching, new cache contents: 0 fonts, 5 dirs
Re-scanning /usr/share/fonts/opentype: caching, new cache contents: 0 fonts, 5 dirs
Re-scanning /usr/share/fonts/truetype: caching, new cache contents: 2 fonts, 38 dirs
Re-scanning /usr/share/fonts/truetype/roboto: caching, new cache contents: 0 fonts, 1 dirs
Re-scanning /usr/share/fonts/type1: caching, new cache contents: 0 fonts, 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 安裝源發佈後更新,本方法能夠解決安裝源太舊問題。 首先,執行命令:

sudo apt install git

安裝git客戶端,克隆代碼到本地。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

等待程序自動選擇安裝源並自動安裝,大功告成。 提示:該方法須要全網絡極爲穩定,不然可能會出現斷線從新安裝。 安裝完成後,檢查安裝狀況,能夠執行命令。

xelatex -version 

程序安裝完成後,開始菜單會增長一個選項--TeXLive Package Manager,經過該軟件能夠完成宏包更新和管理等操做。 圖片是在Windows 環境下面執行結果,可能與Ubuntu執行結果略有差別。 示例代碼以下,

\documentclass{book}
\usepackage{amsmath}
\usepackage{ctex}
%\usepackage{ctex}%(PDF)LaTeX編譯方式請選擇此行,註釋上一行代碼
\begin{document}
你好,中國。

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

Happy TeXing.
\end{document}

將代碼保存至/home/dell/文檔/tex/Hello目錄下,該目錄是筆者電腦目錄,可根據實際狀況選擇保存目錄。

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

編譯文件,

#切換到tex源文件目錄
cd /home/dell/文檔/Hello/
#xelatex命令編譯文件,可選其餘選項
xelatex hello.tex

等待編譯完成。

相關文章
相關標籤/搜索