LoginSignup
55
38

More than 5 years have passed since last update.

VSCodeでLaTeXコンパイルが終わらないのを直した

Last updated at Posted at 2019-04-15

環境

Windows 10
TeX Live
VS Code
拡張機能 LaTeX Workshop

症状

LaTeX Workshopを使うとVSCode上でコマンドを実行して.texファイルをコンパイルしてくれます。
.texファイルを保存した際に自動でコンパイルしてくれる機能を使うか、
または、自動コンパイルをオフにして、"Build LaTeX project"をクリックすることでコンパイルされてPDFが生成されます。
設定については他の記事を参考にしてください。
Visual Studio CodeでTeXのコンパイルをできるようにする方法
VScodeで快適LaTeX環境を構築する方法
私がハマったのは、.texファイル内で構文に間違いがあってコンパイルエラーになった時、
コンパイルが自動で終わらない、というもので、コンパイルし直すにはVSCodeを毎回再起動していました。

対処法

setting.jsonのLaTeXコマンドの引数に"-interaction=nonstopmode"を追加します。
なお、この引数は"%DOC%"より上に書く必要がありそうです。

setting.json
{
    "latex-workshop.view.pdf.viewer": "tab",
    "latex-workshop.message.update.show": false,
    "latex-workshop.latex.tools": [
        {
            "name": "ptex2pdf",
            "command": "ptex2pdf",
            "args": [
                "-interaction=nonstopmode",
                "-l",
                "-ot",
                "-kanji=utf8 -synctex=1",
                "%DOC%",
            ]
        },
    ],
    "latex-workshop.latex.recipes": [
        {
            "name": "ptex2pdf*2",
            "tools": [
                "ptex2pdf",
                "ptex2pdf"
            ]
        },

    ],
    "latex-workshop.latex.autoBuild.run": "onFileChange",
    "latex-workshop.latex.autoClean.run": "onFailed",
    "latex-workshop.latex.build.clearLog.everyRecipeStep.enabled": false
}
55
38
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
55
38