16
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【LaTeX 環境構築】brew + VSCode で Mac に TeX を導入する

Last updated at Posted at 2022-05-29

はじめに

もちろん、みんな卒論とか学術論文書く時は TeX 使うよね。。。
意外と TeX の環境構築に手こずる人も居るみたいなので、それmactex-no-guiで簡単にできるよ?
ってことで、今回は Mac の VSCode で TeX 環境を構築する方法を紹介する。

brew のインストール

### インストール
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

### .zshrcに追加
- Intel chip (x64/x86/x86-64) の場合
基本的にはそのままで良い

- M1 chip (ARM) の場合
$ echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> ~/.zshrc
$ eval $(/opt/homebrew/bin/brew shellenv)

### rezshする
$ source ~/.zshrc
$ exec $SHELL -l

### 確認
$ brew --version
Homebrew 3.4.11

VSCode のインストール

### インストール
$ brew install --cask visual-studio-code

### 確認
$ brew list | grep visual-studio-code
visual-studio-code

MacTeX のイントール

### インストール
$ brew install --cask mactex-no-gui

### rezsh(ここでrezshしておかないとlatexmkを認識してくれない場合があるっぽい)
$ exec $SHELL -l

### 確認
$ latexmk --version
Latexmk, John Collins, 17 Mar. 2022. Version 4.77

VSCode Extension Framework のインストール

VSCode の以下拡張機能をインストールする

vscodesetting.jsonに追記

  • VSCode を立ち上げて⌘ + ,setting.jsonを開く
  • もしくは直接~/Library/Application\ Support/Code/User/settings.jsonを編集
{
  "latex-workshop.latex.tools": [
    {
      "command": "latexmk",
      "args": [
        "-e",
        "$latex=q/platex %O -synctex=1 -interaction=nonstopmode -file-line-error %S/",
        "-e",
        "$bibtex=q/pbibtex %O %B/",
        "-e",
        "$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/",
        "-e",
        "$makeindex=q/mendex %O -o %D %S/",
        "-e",
        "$dvipdf=q/dvipdfmx %O -o %D %S/",
        "-norc",
        "-pdfdvi",
        "%DOC%"
      ],
      "name": "latexmk"
    }
  ],
  "latex-workshop.latex.recipes": [
    {
      "name": "latexmk (tex to PDF)",
      "tools": ["latexmk"]
    }
  ],
  "latex-workshop.view.pdf.viewer": "tab",
  "latex-workshop.latex.clean.subfolder.enabled": true,
  "latex-workshop.latex.autoClean.run": "onBuilt",
  "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",
    "*.dvi",
    "*.synctex.gz"
  ]
}

TeX で Hello world!

\documentclass{jsarticle}

\begin{document}

Hello,\LaTeX!\\

\end{document}

sample.png

こんな感じで編集できれば設定完了 !!
Let's TeX Life!!

16
12
1

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
16
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?