WSL2 下在线安装 TeX Live 2025 指南

引言

本文介绍一种在 WSL2 中安装 TeX Live 2025 的方案。相比于前人的类似教程,本文的贡献是:

  1. 采用 TeX Live 官方推荐的网络安装方案,使用中国科学技术大学开源软件镜像源
  2. 遵循 TeX Live 官方关于无需 super user 权限的建议

    You do not need to be root (administrator on Windows) to install, use, or manage TeX Live. Indeed, we recommend installing it as a normal user, except on macOS, where it’s conventional to install as administrator. (Information about shared installations.) As always, you need to have permission to write into the destination directory, but TeX Live itself does not care if you are root or not.
    (来源:官方文档,Mar. 12, 2025)

  3. 缓解了经典指南 install-latex-guide-zh-cn 第 2.1.1 和 4.1.1 节中关于字体配置的操作有时不能获得预期效果的问题

本文的主要内容综合自

  1. (tug.org/texlive/). TeX Live - Quick install for Unix
  2. 王然. 一份简短的关于 LaTeX 安装的介绍
  3. (Eslzzyl). TeX Live 2024 安装教程(Windows/WSL/Linux)

这三篇文档。

系统环境

安装步骤

  1. 安装前的准备
    1. 环境搭建(来自一份简短的关于 LaTeX 安装的介绍 第 2.1 节)
      sudo apt install fontconfig
      
    2. 清理上次未成功安装尝试的残余(若有)

      If you’re re-installing after a previous attempt, be sure to completely remove your failed installation. By default, this would be in these two directories (on Unix-like systems):

      rm -rf /usr/local/texlive/2025 # 若上次安装位置不在此,则须作相应修改,例如 rm -rf ~/texlive/2025
      rm -rf ~/.texlive2025
      

      (来源:官方文档,Mar. 12, 2025)

  2. 下载 TeX Live 在线安装文件到本地(来自官方文档
    mkdir ~/tmp # working directory of your choice
    cd ~/tmp
    curl -L -o install-tl-unx.tar.gz https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
    zcat < install-tl-unx.tar.gz | tar xf - # note final - on that command line
    
  3. 开始安装(来自官方文档
    cd install-tl-*
    perl ./install-tl --location https://mirrors.ustc.edu.cn/CTAN/systems/texlive/tlnet # 也可换成其他源
    
    根据安装提示,修改 TEXDIR (the main TeX directory),由默认的 /usr/local/texlive/2025 改为 ~/texlive/2025
  4. 安装后
    1. 修改环境变量。根据安装程序的提示,在 .bashrc 文件末尾添加(来自一份简短的关于 LaTeX 安装的介绍 第 2.1.1 节)
      # Add TeX Live to the PATH, MANPATH, INFOPATH
      export PATH=~/texlive/2025/bin/x86_64-linux:${PATH}
      export MANPATH=~/texlive/2025/texmf-dist/doc/man:/usr/share/man:${MANPATH}
      export INFOPATH=~/texlive/2025/texmf-dist/doc/info:${INFOPATH}
      
    2. 刷新字体配置(来自 TeX Live 2024 安装教程(Windows/WSL/Linux)
      cp ~/texlive/2025/texmf-var/fonts/conf/texlive-fontconfig.conf /etc/fonts/conf.d/09-texlive.conf
      sudo ln -s /mnt/c/Windows/Fonts /usr/local/share/fonts/WindowsFonts # 使用软链接将 Windows 主机中的字体链接到 WSL
      fc-cache -fv
      
    3. 检验 TeX Live 是否正常工作
      可参考 TeX Live 2024 安装教程(Windows/WSL/Linux),尝试编译一个小型中文文档。

LaTeX 开发环境搭建

推荐 VS Code + LaTeX Workshop 插件。前、后向同步的设置可参考这里

关于是否需要保持更新,TeX Live 官方的建议是不推荐:

If you want to update packages from CTAN after installation, see these examples of using tlmgr. This is not required, or even necessarily recommended; it’s up to you to decide if it makes sense to get continuing updates in your particular situation.

Typically the main binaries are not updated in TeX Live between major releases. If you want to get updates for LuaTeX and other packages and programs that aren’t officially released yet, they may be available in the TLContrib repository, or you may need to compile the sources yourself.

(来源:官方文档,Mar. 12, 2025)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值