参考: Docker+VSCodeで保存時に自動でコンパイルされるLatex環境を作る話 - Qiita Windows10,WSL2ベースのDocker環境で動作確認.

  1. WSL2のインストール
  2. Docker Desktop for Windowsのインストール
  3. PowerShellから,

    $ docker pull paperist/alpine-texlive-ja
  4. vscodeにLaTeX Workshop - Visual Studio Marketplaceのインストール
  5. setting.jsonに追記
    以下のファイルはDocker+VSCodeで保存時に自動でコンパイルされるLatex環境を作る話 - Qiitaより.
    {
      "[plaintext]": {
        "editor.quickSuggestions": true,
        "editor.acceptSuggestionOnEnter": "off"
      },
      "latex-workshop.latex.recipes": [
        {
          "name": "compile",
          "tools": [
            "latexindent",
            "ptex2pdf",
          ]
        }
      ],
      "latex-workshop.latex.tools": [
        {
          "name": "ptex2pdf",
          "command": "docker",
          "args": [
            "run",
            "--rm",
            "-v",
            "%DIR%:/workdir",
            "paperist/alpine-texlive-ja",
            "latexmk",
            "/workdir/%DOCFILE_EXT%",
            "-latex=uplatex"
          ]
        },{
          "name": "latexindent",
          "command": "docker",
          "args": [
            "run",
            "--rm",
            "-v",
            "%DIR%:/workdir",
            "csegarragonz/latexindent:0.0.1",
            "latexindent",
            "/workdir/%DOCFILE_EXT%",
            "--overwrite"
          ]
        }
      ],
      "latex-workshop.latex.autoBuild.run": "onSave",
      "latex-workshop.view.pdf.viewer": "browser",
      "editor.wordWrap": "on",
      "latex-workshop.latex.autoBuild.cleanAndRetry.enabled": false,
    }