15
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?

More than 1 year has passed since last update.

【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!!

15
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
15
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?