天天看點

latex 中文_Vscode+Texlive+SumatraPDF配置Latex環境

整合化開發環境texstudio覺得挺好用,也沒覺出一些大佬們說的界面不好看問題,但是後面texstudio竟然出現閃退問題,可能是自己古舊的機器跟不上了?Anyway,幾番查詢後這裡記錄下另一種建構方式。

參考b站視訊:【https://www.bilibili.com/video/BV1ht4y197Nz?from=search&seid=7824099234768671160】

以及知乎回答:【https://zhuanlan.zhihu.com/p/38178015】

一:

編輯環境選擇Vscode,這裡選擇安裝版installer:

latex 中文_Vscode+Texlive+SumatraPDF配置Latex環境

連結為【https://code.visualstudio.com/Download】

安裝路徑盡量簡單,無中文,無空格。

=============================================

二:

編譯環境選最新texlive,這裡用texlive2020,容易下載下傳安裝。如【https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/Images/】

安裝路徑盡量簡單,無中文,無空格。

=============================================

三:

輕量化PDF預覽工具SumatraPDF。這裡我們用的便攜版:

latex 中文_Vscode+Texlive+SumatraPDF配置Latex環境

連結為【https://www.sumatrapdfreader.org/download-free-pdf-viewer.html】

下載下傳完成後解壓得到exe程式,為簡單其名稱改為SumatraPDF.exe

程式路徑盡量簡單,無中文,無空格。

==========================================================================================

安裝好上面的部件後。

給Vscode安裝好插件

中文語言包

LaTeX Workshop

設定配置檔案Ctrl+Shift+P打開setting.json:

latex 中文_Vscode+Texlive+SumatraPDF配置Latex環境

給出如下設定:

=============================================

{

    //編譯指令

    "latex-workshop.latex.tools": [

      {

        "name": "xelatex",

        "command": "xelatex",

        "args": [

          "-synctex=1",

          "-interaction=nonstopmode",

          "-file-line-error",

          "%DOCFILE%"

        ]

      },

        {

          "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": "pdflatex",

          "tools": [

            "pdflatex"

          ]

        },

        {

          "name": "xe->bib->xe->xe",

          "tools": [

            "xelatex",

            "bibtex",

            "xelatex",

            "xelatex"

          ]

        },

        {

          "name": "pdflatex -> bibtex -> pdflatex*2",

          "tools": [

            "pdflatex",

            "bibtex",

            "pdflatex",

            "pdflatex"

          ]

        }

      ],

      "latex-workshop.latex.autoBuild.run": "never",

      "latex-workshop.synctex.afterBuild.enabled": true,

      //設定外部PDF預覽

      "latex-workshop.view.pdf.viewer": "external",

      //配置正向搜尋

      "latex-workshop.view.pdf.external.viewer.command": "D:/Working/Documentary/SumatraPDF/SumatraPDF.exe",

      //配置反向搜尋

      "latex-workshop.view.pdf.external.synctex.command": "D:/Working/Documentary/SumatraPDF/SumatraPDF.exe",

      "latex-workshop.view.pdf.external.synctex.args": [

        "-forward-search",

        "%TEX%",

        "%LINE%",

        "-reuse-instance",

        "-inverse-search",

        "\"D:/Working/Coding/Vscode/Code.exe\" \"D:/Working/Coding/Vscode/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",

        "%PDF%"

      ],

      "latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",

    //配色主題設定

    "workbench.colorTheme": "Monokai",

    "editor.fontSize": 15

}

=============================================

儲存重新開機過應該就OK了~

四:設定快捷鍵

在 VSCode 界面下按下 F1,鍵入“keyjson”,選擇“打開鍵盤快捷方式(JSON)”,然後把以下代碼放入:

================================================

{
    "key": "alt+s",
    "command": "latex-workshop.synctex",
    "when": "editorTextFocus && !isMac"
},
{
    "key": "alt+b",
    "command": "latex-workshop.build",
    "when": "editorTextFocus && !isMac"
},
{
    "key": "alt+t",
    "command": "latex-workshop.kill",
    "when": "editorTextFocus && !isMac"
},
{
    "key": "alt+e",
    "command": "latex-workshop.recipes"
},
           

================================================

這裡意思是:将 Alt+s 綁定到正向搜尋,将 Alt+b 綁定到使用預設 recipe 編譯,将 Alt+t 綁定到終止編譯,将 Alt+e 綁定到選擇其他 recipe 編譯,可以自行更換為适合自己的快捷鍵,隻需修改“key”那一項即可。也可以隻設定其中一兩個快捷鍵。

測試下:

latex 中文_Vscode+Texlive+SumatraPDF配置Latex環境

含中文選用xelatex建構

latex 中文_Vscode+Texlive+SumatraPDF配置Latex環境

搞定~

繼續閱讀