[[Visual Studio Code]] > LaTeX Workshop ---- #contents ---- **LaTeX Workshop [#b34f0500] LaTeX Workshop は Visual Studio Code に LaTeX の統合環境を追加する extension です。 -[[LaTeX Workshop:https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop]] --https://marketplace.visualstudio.com/items/James-Yu.latex-workshop/changelog -https://github.com/James-Yu/LaTeX-Workshop --https://github.com/James-Yu/LaTeX-Workshop/commits/master --https://github.com/James-Yu/LaTeX-Workshop/blob/master/CHANGELOG.md -[[MyTeXpert:Visual Studio Code/LaTeX Workshop]] ***日本語文書向けの設定 [#f7cc6d6c] Ctrl+Comma で Settings タブを開きます。 「設定の検索」で「Tools」を入力して「Latex-workshop > Latex: Tools」を探して「settings.json で編集」をクリックします。 左側に既定のユーザー設定、右側にユーザー設定 (settings.json) が開かれます。 左側に表示されている既定のユーザー設定の latex-workshop.latex.tools は以下のように設定されています。 "latex-workshop.latex.tools": [ { "name": "latexmk", "command": "latexmk", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "-pdf", "%DOC%" ] }, { "name": "pdflatex", "command": "pdflatex", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOC%" ] }, { "name": "bibtex", "command": "bibtex", "args": [ "%DOCFILE%" ] } ] Windows で Latexmk-upLaTeX を使用する場合は右側に表示されている settings.json の {} の中に以下の設定を追加・保存して既定のユーザー設定を上書きします。 "latex-workshop.latex.tools": [ { "name": "latexmk", "command": "latexmk", "args": [ "-e", "$latex=q/uplatex %O -kanji=utf8 -no-guess-input-enc -synctex=1 -interaction=nonstopmode -file-line-error %S/", "-e", "$bibtex=q/upbibtex %O %B/", "-e", "$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/", "-e", "$makeindex=q/upmendex %O -o %D %S/", "-e", "$dvipdf=q/dvipdfmx %O -o %D %S/", "-norc", "-pdfdvi", "%DOC%" ] } ] Windows で Latexmk-LuaLaTeX を使用する場合は右側に表示されている settings.json の {} の中に以下の設定を追加・保存して既定のユーザー設定を上書きします。 "latex-workshop.latex.tools": [ { "name": "latexmk", "command": "latexmk", "args": [ "-e", "$lualatex=q/lualatex %O -synctex=1 -interaction=nonstopmode -file-line-error %S/", "-e", "$bibtex=q/upbibtex %O %B/", "-e", "$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/", "-e", "$makeindex=q/upmendex %O -o %D %S/", "-norc", "-pdflua", "%DOC%" ] } ] macOS, Linux で Latexmk-upLaTeX を使用する場合は右側に表示されている settings.json の {} の中に以下の設定を追加・保存して既定のユーザー設定を上書きします。 "latex-workshop.latex.tools": [ { "name": "latexmk", "command": "latexmk", "args": [ "-e", "$latex=q/uplatex %O -synctex=1 -interaction=nonstopmode -file-line-error %S/", "-e", "$bibtex=q/upbibtex %O %B/", "-e", "$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/", "-e", "$makeindex=q/upmendex %O -o %D %S/", "-e", "$dvipdf=q/dvipdfmx %O -o %D %S/", "-norc", "-pdfdvi", "%DOC%" ] } ] macOS, Linux で Latexmk-LuaLaTeX を使用する場合は右側に表示されている settings.json の {} の中に以下の設定を追加・保存して既定のユーザー設定を上書きします。 "latex-workshop.latex.tools": [ { "name": "latexmk", "command": "latexmk", "args": [ "-e", "$lualatex=q/lualatex %O -synctex=1 -interaction=nonstopmode -file-line-error %S/", "-e", "$bibtex=q/upbibtex %O %B/", "-e", "$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/", "-e", "$makeindex=q/upmendex %O -o %D %S/", "-norc", "-pdflua", "%DOC%" ] } ] ***使い方 [#mdd9327c] ファイルの内容を変更して Ctrl+S で保存するとビルドコマンドが実行されます。ファイルの内容を変更していない状態でビルドコマンドを実行したい場合は Ctrl+Alt+B でビルドコマンドを実行します。 Ctrl+Alt+V あるいは右上の PDF ファイルのアイコンを左クリックで指定した PDF ビューアで PDF ファイルを表示します。 タブで開く場合は右側に新しいタブで PDF ファイルを表示します。 ブラウザで開く場合は既定のブラウザで PDF ファイルを表示します。 Ctrl+Alt+J で forward search,Ctrl+左クリックで inverse search を行います。 Ctrl+Alt+X あるいは左側の Activity Bar の TeX アイコンをクリックで以下のリストが表示されリストの項目から Action を選択すると実行されます。 > Build LaTeX project&br; View LaTeX PDF&br; View Log messages&br; Navigate, select, and exit&br; Miscellaneous&br; < **タブで PDF を開く [#h0e50815] settings.json の {} の中に以下の設定を追加・保存します。 "latex-workshop.view.pdf.viewer": "tab" **既定のブラウザで PDF を開く [#m1b4a870] settings.json の {} の中に以下の設定を追加・保存します。 "latex-workshop.view.pdf.viewer": "browser" **SumatraPDF との連携 [#d61e968a] ***forward search [#ydcc4b93] settings.json の {} の中に以下の設定を追加・保存します。 "latex-workshop.view.pdf.viewer": "external", "latex-workshop.view.pdf.external.command": { "command": "C:/Program Files/SumatraPDF/SumatraPDF.exe", "args": [ "-reuse-instance", "%PDF%" ] }, "latex-workshop.view.pdf.external.synctex": { "command": "C:/Program Files/SumatraPDF/SumatraPDF.exe", "args": [ "-reuse-instance", "-forward-search", "%TEX%", "%LINE%", "%PDF%" ] } ***inverse search [#he69ec2b] SumatraPDF の [☰] > [設定(S)] > [オプション(O)...] の「逆順検索コマンドラインの設定」に以下の設定をします。 "C:\Program Files\Microsoft VS Code\bin\code.cmd" -g "%f:%l"