一种macOS系统下的LaTeX最小安装方法

一种 macOS 系统下的 $\LaTeX$ 最小安装方法

BasicTeX + CTeX + VS Code (LaTeX Workshop)

TL;DR

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
brew install basictex

# VS Code 装 LaTeX Workshop

# ctex
sudo tlmgr update --self
sudo tlmgr update texlive-scripts
sudo tlmgr update --all
sudo tlmgr install ctex
# sudo tlmgr install gbt7714 # optional

# LaTeX Workshop 插件依赖
# latexmk
sudo tlmgr install latexmk
echo '$pdflatex = "xelatex %O %S";' > ~/.latexmkrc
# latexindent
sudo tlmgr install latexindent
sudo cpan Log::Log4perl
sudo cpan Log::Dispatch
sudo cpan YAML::Tiny
sudo cpan File::HomeDir
sudo cpan Unicode::GCString

Full story

  1. 先决条件:
    • Homebrew
    • Visual Studio Code
  1. 装 basictex:
1
brew install basictex
  1. 装 ctex:
    参考 tex.stackexchange: Cannot install ctex via tlmgr: “Unknown option: status-file” when running fmtutil-sys
1
2
3
4
5
sudo tlmgr update --self
sudo tlmgr update texlive-scripts
sudo tlmgr update --all
sudo tlmgr install ctex
# sudo tlmgr install gbt7714 # optional: 国产文献格式
  1. 装 VS Code 插件:
    See James-Yu/LaTeX-Workshop

  2. 装 latexmk,配置 pdfTex => XeLaTeX
    参考 tex.stackexchange: How to make LaTeXmk work with XeLaTeX and biber

1
2
3
# latexmk
sudo tlmgr install latexmk
echo '$pdflatex = "xelatex %O %S";' > ~/.latexmkrc
  1. 装缩进处理程序:
    参考 James-Yu/LaTeX-Workshop #376 Formatting failed error
1
2
3
4
5
6
7
# latexindent: https://github.com/James-Yu/LaTeX-Workshop/issues/376
sudo tlmgr install latexindent
sudo cpan Log::Log4perl
sudo cpan Log::Dispatch
sudo cpan YAML::Tiny
sudo cpan File::HomeDir
sudo cpan Unicode::GCString

Upgrade

如果不幸需要更新大版本:(TexLive 2021 -> 2022)

1
2
3
brew upgrade basictex
# 重做上述所有安装步骤
fmtutil-user --all