LoginSignup
27
13

More than 5 years have passed since last update.

VSCodeプラグイン「LaTeX Workshop」の設定

Posted at

LaTeX Workshopで日本語を書くための設定です.
(ドキュメント:https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop)

何も設定せずに使うと,

vscode LaTeX Error: This file needs format `pLaTeX2e' but this is `LaTeX2e'.

というエラーが出てしまうので,設定ファイルを編集しましょう.

ドキュメントを読むと,デフォルトではコンパイルにlatexmkが使われるとのことです.
日本語に対応するために,タイプセットに使うツールをptex2pdfに設定します.
(ターミナルで試すとlatexmkでも日本語で書かれたtexファイルをコンパイルしてくれるのですが,VSCode経由だとなぜかダメに...)

公式ドキュメントに従って,settings.jsonにlatex-workshop.latex.recipes latex-workshop.latex.toolsを記述していきます.

    "latex-workshop.latex.recipes": [{
        "name": "ptex2pdf",
        "tools": [
          "ptex2pdf"
        ] 
    }],
    "latex-workshop.latex.tools": [{
        "name": "ptex2pdf",
        "command": "ptex2pdf",
        "args": [
            "-l",
            "-ot",
            "-kanji=utf8 -synctex=1",
            "%DOC%"
        ]
    }],

これでOK!

*こちらの方の記事を参考にしました.
http://elecho.hatenablog.com/entry/2017/04/27/175500

27
13
1

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
27
13