Ubuntu 环境下安装 LaTeX

如果想懒省事且有充足的安装空间的话,可以直接安装完全体版 texlive-full

1
sudo apt-get install texlive-full

这大概会占用 6 GB 的空间,但是好处是在未来写 tex 文档时,不会加载了奇奇怪怪的宏包之后编译出现 bug。

另外可以安装低配版的宏包,可是在 VSCode 编译时会出现如下错误:

1
Recipe terminated with fatal error: spawn xelatex ENOENT

查看网上的问题贴,这应该是因为找不到 xelatex 的安装路径。但如果装的是低配版的 texlive,我根本就不知道 Ubuntu 这货把它装在哪里了…

安装完 texlive-full 之后还有问题:

1
I can't find the format file `xelatex.fmt'!

stackflow 上有相关的帖子,尝试最高赞的解决方案:

try to run sudo fmtutil-sys --all which should create all missing format files.

没有奏效。第二个解决方案是重新安装 xetex

If you installed TeX from the repositories of your Linux system, you could reinstall the xetex package from a repository.

  • Redhat/Fedora: sudo yum reinstall texlive-xetex
  • Debian/Ubuntu: sudo apt-get install --reinstall texlive-xetex

It works!