9
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

VSCode で LaTeX をビルドできるようにする

Last updated at Posted at 2020-11-22

#環境
Windows 10 Home
Visual Studio Code バージョン 1.51.1
LaTeX Workshop v8.14.0

#発生した問題
Visual Studio CodeにLaTeX Workshopを入れてビルドしようと思ったら、以下のようなエラーが出た。
20201122120304.jpg
そこで、Open compiler logをクリックして出力を見てみると、以下のような表示が。

No pages of output.
Transcript written on c:/Users/ユーザー名/Desktop/textest/1.log.
Latexmk: Log file says no output from latex
Latexmk: For rule 'pdflatex', no output was made
Collected error summary (may duplicate other messages):
  pdflatex: Command for 'pdflatex' gave return code 1
      Refer to 'c:/Users/ユーザー名/Desktop/textest/1.log' for details
Latexmk: Use the -f option to force complete processing,
 unless error was exceeding maximum runs, or warnings treated as errors.
=== TeX engine is 'pdfTeX'
Latexmk: Errors, so I did not complete making targets

どうやら、Latexmkからpdflatexが呼び出されている。TeXworksを使っていた時に、pdflatexは日本語を扱えないという制約があったことを思い出し、その時と同様にptex2pdfを使うように変更した。

#解決法
以下をsettings.jsonに記述する。

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

これで、Visual Studio Code上でビルドができるようになり、PDFのプレビューもできるようになった。

#参考
TeXworks/設定
VSCodeプラグイン「LaTeX Workshop」の設定

9
7
0

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
9
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?