LoginSignup
19
18

More than 5 years have passed since last update.

Homebrew から gnuplot を入れると色々メンドかった話

Posted at

Mac OS X Marvericks で MacTeX (TeX Live 2013) & Homebrew gnuplot を入れて使おうとしたところ,gnuplot-lua-tikz パッケージが使えなくてハマりました.関連して色々と落とし穴が見えたので,まとめようと思います.

Homebrew から gnuplot をインストールする

uda@mac:~$ brew install gnuplot

私の OS X Marvericks / Homebrew 環境で何も考えずに上記を実行したところ,問題なく gnuplot がインストールされたように見えました.しかし,この方法は色々と落とし穴を含んでいます.

clang のせいでインストールに失敗することがある(らしい)

詳しくはこちら:

Xcode で入る gcc …… は実際には F*CKING Apple LLVM clang なので,そのせいでうまくいかないことがあったようです.

私は gcc-4.9 を指定した場合も何も指定しなかった場合もうまく行きましたが,Mac OS のバージョンによってはうまくいかないのかもしれません.気になる人はホンモノの gcc を指定してみましょう.

uda@mac:~$ brew install --cc=gcc-4.9 gnuplot

LaTeX 関連のファイルが導入されない etc.

Homebrew の gnuplot フォーミュラでは,膨大な数の機能を持つ gnuplot の全機能を有効にしてビルドするわけではありません.そのため,brew install gnuplot にはいくつかオプションを渡すことができます.

uda@mac:~$ brew info gnuplot
(前略)
==> Options
--cairo
    Build the Cairo based terminals
--latex
    Build with LaTeX support
--nogd
    Build without gd support
--nolua
    Build without the lua/TikZ terminal
--pdf
    Build the PDF terminal using pdflib-lite
--qt
    Build the Qt4 terminal
--tests
    Verify the build with make check (1 min)
--with-x
    Build the X11 terminal
--without-aquaterm
    Do not build AquaTerm support
--without-emacs
    Do not build Emacs lisp files
--wx
    Build the wxWidgets terminal using pango
--HEAD
    install HEAD version
(後略)

明示的にオプションを指定しなければ,これらの機能は有効にならないようです.例えば,以下のようにすることで gnuplot-lua-tikz.sty などのスタイルファイルが生成されるようになります.

uda@mac:~$ brew install gnuplot --latex

他にも gnuplot のターミナルを種類を増やすオプションがありますから,必要に応じて有効にするとよいでしょう.

! LaTeX error: `gnuplot-lua-tikz.sty' not found.

さて,これで gnuplot-lua-tikz.sty が無事使えるようになったのでしょうか?いいえ,まだ落とし穴があります.実はこのファイルは tex のパスの通っていない場所に配置されてしまいます.

uda@mac:~$ ls -la /usr/local/texlive/texmf-local/tex/latex/ | grep gnuplot

uda@mac:~$ ls -la /usr/local/Cellar/gnuplot/4.6.5/share/texmf/tex/latex/gnuplot/
total 32
drwxr-xr-x 7 uda admin   238  4  8 23:41 .
drwxr-xr-x 3 uda admin   102  4  8 23:41 ..
-rw-r--r-- 1 uda admin 13768  4  8 23:41 gnuplot-lua-tikz-common.tex
-rw-r--r-- 1 uda admin   299  4  8 23:41 gnuplot-lua-tikz.sty
-rw-r--r-- 1 uda admin   250  4  8 23:41 gnuplot-lua-tikz.tex
-rw-r--r-- 1 uda admin   173  4  8 23:41 gnuplot.cfg
-rw-r--r-- 1 uda admin   407  4  8 23:41 t-gnuplot-lua-tikz.tex

いわゆる TEXMFLOCAL(全ユーザ共通の TeX 設定ディレクトリ)には配置されません.まぁ Homebrew のマナーを考えればある意味当然なのですが,だったらせめて TEXMFHOME(ユーザ個人の TeX 設定ディレクトリ)に置いてくれって感じですね.なんなんだ.

面倒すぎて何が何だか分からない,結局どうすればいいの?

案0: Mac を投げ捨てる.

案1: gnuplot をソースからビルドする

はい,安定ですね.http://sourceforge.net/projects/gnuplot/files/gnuplot/ からとってきてがんばってください.

uda@mac:~/gnuplot-4.6.5$ ./configure
uda@mac:~/gnuplot-4.6.5$ make
uda@mac:~/gnuplot-4.6.5$ sudo make install

いりそうな機能もだいたい入りますしコンパイラの問題もいくらでも自分で調整できます.

え?「俺はそんなことしたくないから Homebrew 使ってるんだ」って?

案2: TEXMFHOME にシンボリックリンクを作る

Homebrew から gnuplot をインストールしたあと TEXMFHOME -> Cellar のシンボリックリンクを張る方法です.また,こちらは sudoer でなくてもいけます.

uda@mac:~$ brew install gnuplot --latex
uda@mac:~$ mkdir -p ~/Library/texmf/tex/latex
uda@mac:~$ ln -s /usr/local/Cellar/gnuplot/4.6.5/share/texmf/tex/latex/gnuplot $HOME/Library/texmf/tex/latex/gnuplot

MacTeX では TEXMFHOME$HOME/Library 以下になることに要注意です.

案3: TeX Live に gnuplot-lua-tikz.sty が入るのをおとなしく待つ

これは個人的な意見ですが,そもそも gnuplot のインストールに依存してしまっているのがなんか釈然としないのですよね.gnuplot-lua-tikz.sty 自体は gnuplot がなくても使えるパッケージですから,CTAN にも上がっていて欲しいです.

……善処します.

19
18
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
19
18