7
5

More than 5 years have passed since last update.

MacでコマンドラインからLaTeXコンパイル

Last updated at Posted at 2018-06-03

目的

.texファイルを書いて、コマンド一発でPDFを作成すること。

環境

macOS High Sierra

インストール


事前にghostscriptインストール。

$ brew install ghostscript

全部入ってるのがMacTex、少しなのがBasicTex。BasicTexをHomebrewでインストール。
ついでにドキュメントサイズの設定(A4)と日本語向けのパッケージインストール。

$ brew cask install basictex
$ sudo tlmgr update --self --all
$ sudo tlmgr paper a4
$ sudo tlmgr install collection-langjapanese

パッケージ


listingなどパッケージが入ってないときは適宜こんな感じで

$ tlmgr search --global hoge
$ sudo tlmgr install hoge

日本語フォント


Macのヒラギノフォント設定すると綺麗になる?らしい

$ sudo cjk-gs-integrate --link-texmf --force
$ sudo mktexlsr
$ sudo kanji-config-updmap-sys hiragino-elcapitan-pron

コンパイル時のエラー


例としてこんなエラーが出た時

grep: pcrr7t.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input pcrr7t' failed to make pcrr7t.tfm.
kpathsea: Appending font creation commands to missfont.log.

! Font OT1/pcr/m/n/8=pcrr7t at 8.0pt not loadable: Metric (TFM) file not found.

pcrr7t.tfmが無いってことで、それが入ったパッケージを探すコマンド↓

$ tlmgr search --file pcrr7t.tfm --global

結果

tlmgr: package repository http://ftp.yz.yamagata-u.ac.jp/pub/CTAN/systems/texlive/tlnet (not verified: gpg unavailable)
courier:
    texmf-dist/fonts/tfm/adobe/courier/pcrr7t.tfm

ということでcourierをインストール

$ sudo tlmgr install courier

したらコンパイルできた。

Makefile


こんな感じで書いた。

all:
  platex main.tex
  platex main.tex
  dvipdfmx main

何回かplatexしないとrefが??になる。

参考


TeX Live/Mac - TEX Wiki

Error in TeX Live – Font … not loadable: Metric (TFM) file not found - StackExchange
7
5
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
7
5