Sublime Text安装LaTeXTools插件后,默认是编译工具是latexmk (TeXLive),大部分情况下,latexmk应该够用,它能够判断需要编译的次数,包括使用bibtex编译引用的参考文献。但有时候会有需要自定义编译引擎或者顺序。
下面以pdflatex+bibtex+pdflatex*2的编译为例说明下如何自定义LaTeX编译。
(参考自LaTeXTools)
在LaTeXTools的安装目录(Mac下默认为~/Library/Application Support/Sublime Text 3/Packages/LaTeXTools)有默认的配置文件LaTeXTools.sublime-settings,将其复制到安装目录上一级目录的Use文件夹下。安装目录下的配置文件不建议修改,但复制到User目录后做用作用户自定义配置进行修改。打开配置文件可在编译引擎设置部分看到
// Build engine settings
// ------------------------------------------------------------------
// OPTION: "builder"
// Specifies a build engine
// Possible values:
//
// "default" or "" the default built-in build engine; currently
// this is the same as "traditional"
//
// "simple" invokes pdflatex 1x or 2x as needed, then
// bibtex and pdflatex again if needed;
// intended mainly as a simple example for
// people writing their own build engines.
//
// "traditional" replicates the 'old' system based on
// latexmk (TeXLive) / texify (MiKTeX)
//
// "script" external script: invokes the set of commands
// specified in the "script_commands" setting
// in the platform-specific part of the
// "builder_settings"
//
// custom name you can also use third-party build engines;
// if so, set the "builder_path" option below
//
// NOTE: custom builders CANNOT have the same name as an existing
// built-in build engine (including "default")
"builder": "traditional",
默认的编译引擎是"traditional",即latexmk (TeXLive)。可以通过设置编译引擎为"script",然后设置需要的"script_commands"来自定义编译。要实现pdflatex+bibtex+pdflatex*2的编译需要在"builder_settings"相应的平台条目中加入编译命令,如我是在Mac下:
...
"osx" : {
// See README or third-party documentation
"script_commands": [
"pdflatex -synctex=1 -interaction=nonstopmode",
"bibtex",
"pdflatex -synctex=1 -interaction=nonstopmode",
"pdflatex -synctex=1 -interaction=nonstopmode"
]
},
...
保存文件。再次编译tex文件时默认是编译就是pdflatex+bibtex+pdflatex*2了。