安装与配置

1. 安装

Ubuntu:

不建议从官方软件源安装, 而是从TeX Live官方网站下载安装文件, 或者在线安装.

我个人喜欢下载iso光盘映像安装.

  1. 下载iso文件 http://mirror.ctan.org/systems/texlive/Images/

  2. 挂载iso文件 mount -t iso9660 -o ro,loop,noauto /your/texlive.iso /mnt

  3. cd /mnt 运行 install-lt, 出现以下字符界面:

       ======================> TeX Live installation procedure <=====================
    
       ======>   Letters/digits in <angle brackets> indicate   <=======
       ======>   menu items for actions or customizations      <=======
    
        Detected platform: GNU/Linux on x86_64
    
        <B> set binary platforms: 1 out of 17
    
        <S> set installation scheme: scheme-full
    
        <C> set installation collections:
            40 collections out of 41, disk space required: 4910 MB
    
        <D> set directories:
          TEXDIR (the main TeX directory):
            /usr/local/texlive/2017
          TEXMFLOCAL (directory for site-wide local files):
            /usr/local/texlive/texmf-local
          TEXMFSYSVAR (directory for variable and automatically generated data):
            /usr/local/texlive/2017/texmf-var
          TEXMFSYSCONFIG (directory for local config):
            /usr/local/texlive/2017/texmf-config
          TEXMFVAR (personal directory for variable and automatically generated data):
            ~/.texlive2017/texmf-var
          TEXMFCONFIG (personal directory for local config):
            ~/.texlive2017/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
        <P> save installation profile to 'texlive.profile' and exit
        <H> help
        <Q> quit
    
       Enter command:
    
    如果不需要修改, 直接输入i开始安装.
    
  4. 设置环境变量, 以ubuntu 64位, TeX Live 2017为例, 将以下环境变量设置加入~/.profile 或者~/.bashrc:

    PATH=/usr/local/texlive/2017/bin/x86_64-linux:$PATH; export PATH
    MANPATH=/usr/local/texlive/2017/texmf-dist/doc/man:$MANPATH; export MANPATH
    INFOPATH=/usr/local/texlive/2017/texmf-dist/doc/info:$INFOPATH; export INFOPATH
    

    官方文档中说安装脚本创建了TEXDIR等环境变量, 但我是先用root用户安装然后又切换回普通用户的, 发现那些环境变量并没有导出, 为了方便, 我也它们也在.bashrc中导出:

    export TEXDIR=/usr/local/texlive/2017
    export TEXMFLOCAL=/usr/local/texlive/texmf-local
    export TEXMFSYSVAR=/usr/local/texlive/2017/texmf-var
    export TEXMFSYSCONFIG=/usr/local/texlive/2017/texmf-config
    export TEXMFVAR=~/.texlive2017/texmf-var
    export TEXMFCONFIG=~/.texlive2017/texmf-config
    export TEXMFHOME=~/texmf
    
  5. XeTeX和LuaTeX的系统字体配置

    • cp $TEXMFSYSVAR/fonts/conf/texlive-fontconfig.conf /etc/fonts/conf.d/09-texlive.conf
    • fc-cache -fsv
  6. 测试安装是否成功

    • 确认可以执行tex程序. 执行``tex –version``查看tex命令是否可以找到以及结果是否正确:

      $tex --version
      TeX 3.14159265 (TeX Live 2017)
      kpathsea version 6.2.3
      Copyright 2017 D.E. Knuth.
      ...
      
    • 处理基本的LaTeX文件. pdflatex sample2e.tex, 直接从tex文件生成pdf:

      $pdflatex sample2e.tex
      This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex)
       restricted \write18 enabled.
      entering extended mode
      ...
      

      成功后会在当前目录生成sample2e.pdf

    • 测试xetex是否能访问系统字体. xetex opentype-info.tex 如果你收到 “Invalid fontname ‘Latin Modern Roman/ICU’…” 这样的错误信息,就说明需要配置系统才能找到TeX Live带的字体:

      $xetex  opentype-info.tex
      This is XeTeX, Version 3.14159265-2.6-0.99998 (TeX Live 2017) (preloaded format=xetex)
       restricted \write18 enabled.
      entering extended mode
      (/usr/local/texlive/2017/texmf-dist/tex/xetex/xetexfontinfo/opentype-info.tex
      [1] [2] )
      Output written on opentype-info.pdf (2 pages).
      Transcript written on opentype-info.log.
      

2. 卸载

Ubuntu:

参考: https://tex.stackexchange.com/questions/95483/how-to-remove-everything-related-to-tex-live-for-fresh-install-on-ubuntu

  1. sudo apt-get purge texlive*
  2. rm -rf /usr/local/texlive/* and rm -rf ~/.texlive*
  3. rm -rf /usr/local/share/texmf
  4. rm -rf /var/lib/texmf
  5. rm -rf /etc/texmf
  6. sudo apt-get remove tex-common --purge
  7. rm -rf ~/.texlive
  8. find -L /usr/local/bin/ -lname /usr/local/texlive/*/bin/* | xargs rm