Windows下打造Sublime Text + Tex Live环境

一直在用Sublime Text + ctex集成环境编写Latex文档,最近发现ctex套件内嵌的MiKTeX包管理器功能太弱了,遂将目标转向了功能更加强大的Tex Live环境。

首先安装Tex Live环境,可以选择在线安装或者下载iso文件安装。可以参考官方网站的安装教程http://www.tug.org/texlive/,也可以参考这篇博文http://exciton.eo.yzu.edu.tw/~lab/latex/install_latex_cjk_ms_windows.html

安装完成后,将Tex Live安装目录中的可执行文件目录添加进系统PATH路径,目录一般是这种形式的D:\texlive\2014\bin\win32。

Sublime Text中安装LaTeXTools插件,然后依次点击:Preferences -->> Package Settings -->> LaTeXTools --> Reconfigure LaTeXTools and migrate settings,插件会在User目录下生成LaTeXTools的配置文件。如果系统安装的是MiKTeX集成环境的话,配置文件不需要修改直接ctrl+b就可以编译Latex文件。现在我们想要LaTeXTools调用Tex Live编译Latex文件,只需要修改配置文件中的Platform settings部分。

"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" : "",
        // TeX distro: "miktex" or "texlive"
        "distro" : "texlive"
    },

将"distro"属性修改成"texlive",LaTeXTools插件就可以默然调用Tex Live编译Latex文件了。在这种情况下,如果Build engine settings里设置成"traditional",那么ctrl+b编译的时候,实际上调用的是Tex Live中的latexmk命令。

// ------------------------------------------------------------------
// 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
    //                    peoeple writing their own build engines.
    //
    // "traditional"    replicates the 'old' system based on
    //                    latexmk (TeXLive) / texify (MiKTeX)
    //
    // "script"            external script: just invokes the script
    //                    specified in "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",

插一句题外话,latexmk命令还有一个强大的功能,它可以通过读取Latex文件首行的Tex引擎设置参数来调用不同编译引擎编译文件。其Tex引擎设置命令格式为:%!TEX program = <program>。在这里program可以是pdflatex(默认),luaoatex或xelatex。如果首行没有Tex引擎选择指令,latexmk将默认调用pdflatex引擎。例如,在Latex文件的第一行的内容是:%!TEX program = xelatex。那么在用latexmk命令编译文件的时候,实际上调用的是xelatex编译引擎。这个功能使得我们可以在不修改编译命令的情况下,修改编译引擎,只需要在Latex文件的首行加一条配置命令即可实现编译引擎的选择,可以大大方提高Latex文件编译的灵活度。目前,MiKTeX的texify并不支持。

 

posted @ 2014-08-06 17:14  冰原狼  阅读(9578)  评论(0编辑  收藏  举报