Manjaro20.2配置TeXLive+VSCode的LaTeX环境

1. 安装

1.1 安装 TeXLive

1.1.1 从软件源安装

在终端执行以下代码,安装 TeXLive 环境:

1
2
sudo pacman -S texlive-most
sudo pacman -S texlive-lang

【注】这样安装 TeXLive 后无法在终端使用 texdoc 工具,会报错:/usr/local/texlive/2020/texmf-dist/doc/generic/pgf/pgfmanual.pdf

1.1.2 从安装包安装

如果想要使用 texdoc 等其他工具,最好的办法还是到官网下载安装包进行在本地安装(在线安装包下载地址、离线安装包下载地址)。下面以本人安装为例:

1
2
cd install-tl-20200411
sudo ./install-tl

安装完后,会提示需要添加路径:

1
2
3
4
Add /usr/local/texlive/2020/texmf-dist/doc/man to MANPATH.
Add /usr/local/texlive/2020/texmf-dist/doc/info to INFOPATH.
Most importantly, add /usr/local/texlive/2020/bin/x86_64-linux
to your PATH for current and future sessions.

首先编辑 /etc/profile 文件:

1
sudo vim /etc/profile

然后刷新使之生效:

1
source /etc/profile

此时就安装好 TeXLive 了,并且可以在终端使用 texdoc 工具。

【注】更多 TeXLive 安装详情可参阅 ArchWiki

1.2 安装 VSCode

在终端直接从软件源安装即可:

1
sudo pacman -S visual-studio-code-bin

1.3 配置 VSCode

首先安装 LaTeX 插件 LaTeX Workshop,然后将以下设置加入到 VSCode 的设置 json 文件中:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{
// Latex workshop
"latex-workshop.latex.tools": [
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOC%"
]
},
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}
],
"latex-workshop.latex.recipes": [
{
"name": "xelatex",
"tools": [
"xelatex"
]
},
{
"name": "latexmk",
"tools": [
"latexmk"
]
},

{
"name": "pdflatex -> bibtex -> pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
}
],
"latex-workshop.view.pdf.viewer": "tab",
"latex-workshop.latex.clean.fileTypes": [
"*.aux",
"*.bbl",
"*.blg",
"*.idx",
"*.ind",
"*.lof",
"*.lot",
"*.out",
"*.toc",
"*.acn",
"*.acr",
"*.alg",
"*.glg",
"*.glo",
"*.gls",
"*.ist",
"*.fls",
"*.log",
"*.fdb_latexmk"
]
}

2. 管理

TeXLive 提供了 TeX 宏包管理器 tlmgr,可以用来安装、删除、更新宏包,具体使用参见:

1
tlmgr --help

3. 文档

【注】使用LaTeX写作过程中,若想查看某一宏包(XXX)的官方手册,可以在终端使用 texdoc 命令:

1
texdoc XXX