Haniwa820
@Haniwa820

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

【LaTeX Workshop】 プロジェクトのビルドができない

環境

Windows 11, VSCode, TeXLive, LuaLaTeX

ファイルパス

VSCode C:~\AppData\Local\Programs\Microsoft VS Code
TeXLive D:\texlive
.latexmkrc C:\Users\user
test.tex D:\Program\TEX

解決したいこと

VSCode で拡張機能の LaTeX Workshop を使って PDF 生成を楽にしたいのですが、
エラーが発生してビルドができません。解決策が分かる方にご助力いただけると幸いです!

また、もしよければビルドコマンドのオプションについて解説してくれてるサイト等ありましたら、教えていただけますと幸いです!

VSCode の設定

"latex-workshop.latex.tools": [
      {
        "name": "lualatex",
        "command": "lualatex",
        "args": [
          "--cmdx", "-file-line-error", "-synctex=1", "-interaction=nonstopmode", "-halt-on-error", "%DOC%",
        ],
      },
],

"latex-workshop.latex.recipes": [
      {
        "name": "lualatex",
        "tools": [
          "lualatex",
        ]
      },
],

"latex-workshop.latex.magic.args": [
      "-f", "-gg", "-pv", "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOC%"
],

"latex-workshop.latex.clean.fileTypes": [
    "*.aux", "*.bbl", "*.blg", "*.idx", "*.ind", "*.lof", "*.lot", "*.out", "*.toc", "*.acn",
    "*.acr", "*.alg", "*.glg", "*.glo", "*.gls", "*.ist", "*.fls", "*.log", "*.fdb_latexmk", "*.synctex.gz",

    "_minted*", "*.nav", "*.snm", "*.vrb",
],

"latex-workshop.latex.autoClean.run": "onBuilt",

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

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

"[tex]": {
    "editor.suggest.snippetsPreventQuickSuggestions": false,
    "editor.tabSize": 2
},

"[latex]": {
    "editor.suggest.snippetsPreventQuickSuggestions": false,
    "editor.tabSize": 2
},

"[bibtex]": {
    "editor.tabSize": 2
},


// ---------- LaTeX Workshop ----------

"latex-workshop.intellisense.package.enabled": true,

"latex-workshop.latex.outDir": "out",

latexmkrc の設定

$latex = 'uplatex %O -kanji=utf8 -no-guess-input-enc -synctex=1 -interaction=nonstopmode %S';

$pdflatex = 'pdflatex %O -synctex=1 -interaction=nonstopmode %S';

$lualatex = 'lualatex %O -synctex=1 -interaction=nonstopmode %S';

$xelatex = 'xelatex %O -no-pdf -synctex=1 -shell-escape -interaction=nonstopmode %S';

$biber = 'biber %O --bblencoding=utf8 -u -U --output_safechars %B';
$bibtex = 'upbibtex %O %B';

$makeindex = 'upmendex %O -o %D %S';

$dvipdf = 'dvipdfmx %O -o %D %S';

$dvips = 'dvips %O -z -f %S | convbkmk -u > %D';
$ps2pdf = 'ps2pdf.exe %O %S %D';

$pdf_mode = 4;

$pdf_previewer = 'SumatraPDF -reuse-instance';

発生している問題・エラー

[16:29:52.586][Event] STRUCTURE_UPDATED
[16:29:53.773][Commander] RECIPES command invoked.
[16:29:53.773][Commander] BUILD command invoked.
[16:29:53.774][Build] The document of the active editor: file:///d:/Program/TEX/test.tex
[16:29:53.774][Build] The languageId of the document: latex
[16:29:53.774][Root] Current workspace folders: ["file:///d:/Program/TEX"]
[16:29:53.774][Root] Try finding root from magic comment.
[16:29:53.774][Root] Try finding root from active editor.
[16:29:53.774][Root] Found root file from active editor: %WS1%\test.tex
[16:29:53.774][Root] Keep using the same root file: %WS1%\test.tex
[16:29:53.775][Event] ROOT_FILE_SEARCHED
[16:29:53.775][Event] STRUCTURE_UPDATED
[16:29:53.775][Build] Building root file: %WS1%\test.tex
[16:29:53.775][Build][Recipe] Build root file %WS1%\test.tex
[16:29:53.778][Build][Recipe] Preparing to run recipe: lualatex.
[16:29:53.778][Build][Recipe] Prepared 1 tools.
[16:29:53.779][Build][Recipe] outDir: %WS1%\out .
[16:29:53.785][Build] Recipe step 1 The command is lualatex:["--cmdx","-file-line-error","-synctex=1","-interaction=nonstopmode","-halt-on-error","d:/Program/TEX/test"].
[16:29:53.786][Build] env: undefined
[16:29:53.786][Build] root: %WS1%\test.tex
[16:29:53.786][Build] cwd: %WS1%
[16:29:53.794][Build] LaTeX build process spawned with PID undefined.
[16:29:53.794][Build] LaTeX fatal error on PID undefined. Error: spawn lualatex ENOENT
[16:29:53.795]Error: spawn lualatex ENOENT
	at ChildProcess._handle.onexit (node:internal/child_process:286:19)
	at onErrorNT (node:internal/child_process:484:16)
	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
[16:29:53.795][Build] Does the executable exist? $PATH: undefined, $Path: "連なる環境変数たち", $SHELL: undefined
[16:29:53.795][Build] 
[16:30:00.559][Event] STRUCTURE_UPDATED

自分で試したこと

おそらく何かのPathが無いと言われているので、.latexmk のPath (C:\Users\user) を環境変数に追加してみましたが、解決せず…

0

1Answer

Path には D:\texlive\(西暦)\bin\win32 を追加してください。

オプションについては lualatex --help などで概要を確認し、詳しく知りたければ個別に検索するのがいいと思います。

0Like

Your answer might help someone💌