3
2

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でLaTeX環境を構築する際にハマったこと

Posted at

環境概要

主にup*系のツールを使用

ハマった点

ツールチェインの設定

当初の設定

settings.json(一部)
  "latex-workshop.latex.recipes": [
      {
          "name": "ptex2pdf (uplatex) -> pbibtex -> ptex2pdf (uplatex) *2",
          "tools": [
              "ptex2pdf (uplatex)",
              "upbibtex",
              "ptex2pdf (uplatex)",
              "ptex2pdf (uplatex)"
          ]
      },
      {
          "name": "ptex2pdf (uplatex) *2",
          "tools": [
              "ptex2pdf (uplatex)",
              "ptex2pdf (uplatex)"
          ]
      }
  ],
  "latex-workshop.latex.tools": [
      {
          "name":"ptex2pdf (uplatex)",
          "command": "ptex2pdf",
          "args": [
              "-l",
              "-u",
              "-ot",
              "-kanji=utf8 -synctex=1",
              "%DOC%"
          ]
      },
      {
        "name": "upbibtex",
        "command": "upbibtex",
        "args": [
            "%DOCFILE%"
        ]
    }
  ]

このようにして、コマンドを順次実行する設定としていた

問題点

  • 文献リストを持たない小さい文章の処理が失敗する
    • 保存して自動コンパイルが走るたびにエラー

解決策

  • latexmkを使う
settings.json(一部)
  "latex-workshop.latex.recipes": [
      {
          "name": "latexmk",
          "tools": [
              "latexmk"
          ]
      }
  ],
  "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%"
        ]
      }
  ]

本当は.latexmkrcを使ったほうがlatex-workshop.latex.toolsの設定内容が短くなるらしい

プレビュー機能に関して(未解決)

問題点

VSCodeのタブやブラウザを用いたプレビューが正常に表示できない

原因分析

  • GitHubでも同様のIssueが上がっているが拡張機能の作者の環境では発生していない
    • 環境依存の問題
    • VSCodeや拡張機能の不具合ではなさそう
      • ネットワーク関係(ファイアウォール周り?)の問題か?

回避策

SumatraPDFを使ってSyncTeX活用してなんとか頑張る

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?