3
3

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 5 years have passed since last update.

VScodeでupLaTeX+dvipdfmxの環境を整えた

Last updated at Posted at 2019-10-05

概要

Atomで使っていたLaTeXをVScodeでも使えるようにしました。
使用環境はupLaTeX+dvipdfmxです。
まだTeXをインストールしていない人はまずそちらを先にしてください。

基本事項

VScodeでLaTeXを扱うには、パッケージ「LaTeX Workshop」をインストールして、command+,で開けるユーザー設定のsetting.jsonにビルドのrecipeを書き加えてそれを使います。
扱いたいLaTeXの種類によってrecipeの書き方は異なります。また、色々とオプションをつけたい場合もsetting.jsonに書き込みます。

ここでは、upLaTeX+dvipdfmx環境がすでに構築されている前提のもと、TeXファイルを更新すると自動で右のpdfも更新されるような状態を作ります。
test.gif

手順

  1. パッケージ「LaTeX Workshop」をインストール
    https://qiita.com/zr_tex8r/items/a924be192ecea7e6bbe4
  2. command+,で開けるユーザー設定のページにある 2019-10-05 15.01.25.pngマークを押して出てくるsetting.jsonにbuild操作の以下を書き込む。
setting.json
{
"latex-workshop.latex.tools": [{
    "name": "ptex2pdf (uplatex)",
    "command": "ptex2pdf",
    "args": [
      "-interaction=nonstopmode",
      "-l",
      "-u",
      "-ot",
      "-kanji=utf8 -synctex=1",
      "%DOC%"
    ]
  },
],
"latex-workshop.latex.recipes": [
  {
    "name": "ptex2pdf (uplatex) *2",
    "tools": [
      "ptex2pdf (uplatex)",
      "ptex2pdf (uplatex)"
    ]
  },
],
"latex-workshop.synctex.afterBuild.enabled": true,
"latex-workshop.view.pdf.viewer": "tab",
"explorer.confirmDelete": false
}

基本的な使い方

いたってシンプルです。

  1. texファイルを作って、最初は手動でビルドする。(左のtexマークをクリックしてCOMMANDS/Build LaTeX project/Recipe:ptex2pdf(uplatex) *2を押す)
  2. 左のtexマークをクリックしてCOMMANDS/View LaTeX PDF/View in VSCode tabを押す
  3. texファイルを更新して保存すると開いているpdfも更新されていく

注意点とか

  • setting.jsonの設定が反映されない
    →初歩的なミスですが、他の設定を以前にしていて以下のようなファイル構造になってしまっていませんか?
setting.json
{
"workbench.startupEditor": "none",
}
{
"latex-workshop.latex.tools": 
...
...
..
}

全体が一つの{}に収まっているjsonファイルの構造になっていないと読み込んでくれません。

最後に

別の種類のLaTeXを使っている人もrecipeが違うだけで基本的には変わらないと思います。あらゆる種類のLaTeXに対応させることもできるそうなので他の人の記事も参考にしてみてください。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?