Sublime Text3 + Tex Live 2018 + LaTexTools + SumatraPDF 搭建 Windows 下 LaTex 编译环境

准备工作

Sublime Text3
Tex Live 2018
LaTexTools
SumatraPDF

安装 Tex Live 2018

在 Windows 10 中可以右击下载的 ISO 文件选择”挂载”(非 Windows 10 系统可以用 Winrar 等工具解压该文件),然后以管理员身份运行 install-tl-windows.bat 脚本。

在出现的 GUI 界面中选择合适的配置,安装(一般情况下默认配置即可;习惯用 Texworks 可以保留该编辑器)。

SumatraPDF 配置

安装完成后打开 SumatraPDF,点击左上角,选择 设置 -> 选项,在最下方 “请键入双击 PDF 文件时,应运行的命令” 中填入如下命令:

1
"C:\Program Files\Sublime Text 3\sublime_text.exe""%f:%l"

也就是 “Sublime Text的安装路径””%f:%l”。

Sublime Text3 + LaTexTools 的配置

安装好 Sublime Text 之后,首先安装控制台 Package Control

安装完成之后,Preferences -> Package Control, 在打开的对话框里输入 Inatall Package,

选择第一个选项,然后在弹出的 Inatall Package 对话框中输入 LaTexTools, 找到对应选项点击安装。 安装完成后重启 Sublime Text。

更新后的 Sublime Text 可以在 Preferences -> Pakage Setting 路径中找到 LaTeXTools 选项,点击该选项下级菜单中的 Settings-User。

在打开的 LaTexTools.sbulime-seeting 文件的第 209 行找到 “Windows” 关键词并将其下面的 dict 更新为以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"windows": {
// Path used when invoking tex & friends; "" is fine for MiKTeX
// For TeXlive 2011 (or other years) use
// "texpath" : "C:\\texlive\\2011\\bin\\win32;$PATH",
"texpath" : "C:\\Texlive\\2018\\bin\\win32;$PATH",
// TeX distro: "miktex" or "texlive"
"distro" : "texlive",
// Command to invoke Sumatra. If blank, "SumatraPDF.exe" is used (it has to be on your PATH)
"sumatra": "C:\\Program Files\\SumatraPDF\\SumatraPDF.exe",
// Command to invoke Sublime Text. Used if the keep_focus toggle is true.
// If blank, "subl.exe" or "sublime_text.exe" will be used.
"sublime_executable": "",
// how long (in seconds) to wait after the jump_to_pdf command completes
// before switching focus back to Sublime Text. This may need to be
// adjusted depending on your machine and configuration.
"keep_focus_delay": 0.5
},

其中 “texpath” 为 Texlive 的安装路径; “distro” 改为 “texlive”; “sumatra” 为 SumatraPDF 的安装路径。

在第 379 行将 “builder” 的值更新为 “basic”,

1
"builder": "basic",

在第 398 行找到 “builder_settings” 关键词并将其下面的 dict 更新为以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
"builder_settings" : {

// General settings:
// See README or third-party documentation
"program": "xelatex",
"command": ["texify", "-b", "-p", "--tex-option=\"--synctex=1\""],
// (built-ins): true shows the log of each command in the output panel
"display_log" : false,

// Platform-specific settings:

...

},

安装字体

解压下载的字体文件后,为了让 xelatex 调用到我们要安装的字体,需要右击字体文件,选择 “为所有用户安装” 来安装字体。

安装完成后需要刷新字体缓存, 用管理员权限打开 cmd ,运行下面的命令:

1
fc-cache

测试

用 Sublime Text 打开用 MyriadPro 字体的 tex 文件,ctrl + b 编译文件。

在 PDF 文档中双击任意位置,可以打开 tex 文件并跳转至文档对应的源码处。