season's quarterly

数学/物理/プログラミング

【Windows】LaTeX環境構築

VSCodeのインストールとupLaTeXを前提とする。

TexLive

  1. https://www.tug.org/texlive/acquire-netinstall.htmlからインストーラをダウンロード。
  2. 実行。Installを選択してNext。2枚目のウィンドウが開く。
  3. 高度な設定
    • スキーム: basicスキーム(plain + latex)
    • カスタマイズ: LaTeX 推奨パッケージを追加。スキームの表示がカスタムスキームに変わる。
    • インストール。かなり長い。
  4. コマンドプロンプトlatexと打つと以下のように出る(Ctrl + cで抜ける)。
C:\Users\seaso>latex
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=latex)
 restricted \write18 enabled.
**

確認

upLaTeX

uplatex, uplatex.windowsインストール済み

  1. test.texを作成。\documentclassuplatexを指定。
  2. uplatex test.tex: test.aux, test.dvi, test.logが作成される。
  3. dvipdfmx test.dvi: test.pdfが作成される。
\documentclass[uplatex]{jsarticle}
\begin{document}

\title{タイトル}
\author{著者}
\maketitle

\section{見出し}
本文

\end{document}

latexmk

  1. TLShell TeX Live ManagerからTeX Live Shellを起動。
  2. 状態未インストールを選択し、latexmkで検索。latexmk, latexmk.windowsの二つが出てくる。
  3. 両方チェックを入れ、選択項目をインストールインストール済みに二つが追加される。
  4. C:\ユーザー\{ユーザー名}\.latexmkrcファイルを作成。upLaTeXの場合以下のようにする。
$latex = 'uplatex %O -kanji=utf8 -no-guess-input-enc -synctex=1 -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';
$pdf_mode = 3;
$pdf_previewer = "start %S"
> latexmk test.tex

で必要に応じて中間ファイルが生成され.dvi, .pdfが出力される。

> latexmk -pv test.tex

でpdfを出力した後、指定のビュワーで開く。

LaTeX Workshop

  1. VSCodeLaTeX Workshopをインストール
  2. settings.jsonを編集し、latexmkを利用できるようにする。
  3. .texファイルを開くと、ウィンドウの右上にBuild LaTeX projectボタンが表示される。押すとpdfが生成される。
  4. ウィンドウの右上にView LaTeX PDF fileボタンが表示される。押すと分割タブでpdfが表示される。
    "latex-workshop.latex.tools": [
        {
          "name": "latexmk(uplatex)",
          "command": "latexmk",
          "args": [
            "-f", "-gg", "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOC%"
          ]
        },
    ],
    "latex-workshop.latex.recipes": [
        {
          "name": "upLaTeX",
          "tools": [
            "latexmk(uplatex)"
          ]
        },
    ],
    "latex-workshop.intellisense.package.enabled": true,
    "latex-workshop.latex.autoBuild.run": "never",
    "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",
        // for Beamer files
        "_minted*", "*.nav", "*.snm", "*.vrb",
    ],
    "latex-workshop.latex.autoClean.run": "onBuilt",
    "latex-workshop.view.pdf.viewer": "tab",

参考