3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Mac Latex 導入メモ

3
Last updated at Posted at 2025-12-30

はじめに

いつもMac購入時に苦労するLatex導入、今回も苦労しました。
何度も同じようなことをしていますが、導入メモを残しておきます。
(2026-01-01 設定ファイルが各所間違えていたので再修正。エラーなく、完璧に動くようになりました)

前提

5年ぶりに個人PCを購入し、M5 Macを使うことになった。
執筆の入校で必要なため、Latex環境を構築することは必須。
今まで書きかけの原稿でビルドができる状態にする必要がある。

最新状況(2026-01-01時点)

下記の画面コピーのような感じです。VS Codeの画面からLatexの修正をかけて、保存し、画面右上のビルドアイコンをクリックするとビルドが走り出し、即座にPDFも更新されます。
むちゃくちゃ快適な環境になりました。

手順

home brew

各種ソフト導入の前提で必須です。

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Tex 導入

2行目のアップデートには相当時間がかかります(30分以上)

brew install mactex --cask 
sudo /usr/local/texlive/2025/bin/universal-darwin/tlmgr update --self --all

動作確認

latex --version
pdflatex --version
tlmgr --version
sudo tlmgr info latex

ビルドテスト

latex <<EOF
\documentclass{article}
\begin{document}
Hello, TeX Live 2025!
\end{document}
EOF

VS code連携

VS Code に LaTeX 機能を追加

VS Code で:

1️⃣ 左の Extensions(四角アイコン)
2️⃣ 検索:LaTeX Workshop
3️⃣ Install(アイコンが本+歯車、作者:James Yu)

tasks.json

latex用のフォルダ配下に .vscode/tasks.json ファイルを作る

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "latex build",
            "type": "shell",
            "command": "latexmk",
            "args": [
                "-pdf",
                "-f",
                "-latex=platex",  // ここでplatexを指定します
                "main.tex"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": ["$latexmk"],
            "detail": "LaTeX build using latexmk"
        }
    ]
}

latexmk用設定ファイル

main.texと同じフォルダーにlatexmkrcを作る

# ==== pLaTeX + dvipdfmx 用 latexmkrc(日本語向け)====

# LaTeX(dvi 出力)は pLaTeX を使う
$latex = 'platex -synctex=1 -interaction=nonstopmode -file-line-error %O %S';

# dvi → pdf 変換は dvipdfmx を使う
$dvipdf = 'dvipdfmx %O -o %D %S';

# 「tex → dvi → pdf」という流れで PDF まで作るモード
$pdf_mode = 3;

# 参考: bibtex に関する設定を入れたい場合はここに追記
# 例:
# $bibtex_use = 2;

settings.jsonファイル

latex用のフォルダ配下に .vscode/settings.json ファイルを作る
(2025/12/31追記 昨日のオリジナルは間違っていました。差し替え後のこちらが正しく動くものです。)

{
    "latex-workshop.latex.tools": [
        {
            "name": "latexmk (platex)",
            "command": "latexmk",
            "args": [
                "-f",            // エラーがあっても止まらないように
                "%DOC%"         // main.tex など
            ]
        }
    ],

    "latex-workshop.latex.recipes": [
        {
            "name": "latexmk (pLaTeX)",
            "tools": [
                "latexmk (platex)"
            ]
        }
    ],

    "terminal.integrated.env.osx": {
        "PATH": "/Library/TeX/texbin:${env:PATH}"
    }
}
3
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?