標籤:style blog http color os io 檔案 for
一直在用Sublime Text + ctexIntegration Environment編寫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的設定檔。如果系統安裝的是MiKTeXIntegration Environment的話,設定檔不需要修改直接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並不支援。