[[Microsoft Windows]] > Cygwin

*[[Cygwin:https://www.cygwin.com/]] での TeX の利用 [#y69b4c00]

Cygwin は Microsoft Windows 上で動作する Linux(UNIX® 互換システム)ライクな環境です.
x86_64 版のインストーラがあります.

ここでは,Cygwin 上に TeX 環境を構築して利用する方法を説明します.
Cygwin で [[TeX Live]] を使用する場合は

- TeX Live 公式パッケージ
- TeX Live/Cygwin

の選択肢があります.

----
#contents
----


**TeX Live 公式パッケージ [#cfed3869]

以下の操作で wget というコマンドを使用しますが,Cygwin
インストール時にパッケージ選択画面で Default のままインストールした場合,wget
がインストールされていないので,そのコマンドが使えません.
あらためて setup-x86_64.exe
を立ち上げ,パッケージ選択画面で wget を検索し,Default から Install
に変更し,wget をインストールしましょう.

また,TeX Live のインストールには [[Perl]] も必要です.
さらに,TeX で eps 形式の図を扱うときは [[Ghostscript]] も必要です.
少なくとも wget, Perl, Ghostscript は事前に
Cygwin にインストールしておきましょう.

***TeX Live のインストール [#peed6637]

-[[CygwinにTeXlive公式パッケージを導入する:http://vraisamis.hatenadiary.jp/entry/2013/11/19/213227]]
-http://www.tug.org/texlive/quickinstall.html
-http://www.tug.org/texlive/doc/texlive-en/texlive-en.html#installation

を参照.

[[ミラーサイト>TeX Live#tlnet]]から
install-tl-unx.tar.gz をダウンロードします.
 $ wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz

install-tl-unx.tar.gz を展開します.
 $ tar xvf install-tl-unx.tar.gz

展開したインストーラのディレクトリに移動します.
 $ cd install-tl-2*
インストーラを実行します.
オプションでダウンロードするリポジトリを指定できます.
 $ ./install-tl -no-gui -repository http://mirror.ctan.org/systems/texlive/tlnet/
 
 ...
 
 Actions:
  <I> start installation to hard disk
  <H> help
  <Q> quit
 
 Enter command: I

I を入力してインストールを開始します.

サーバーの接続エラーが発生したり,アーカイブ中に予期せぬ EOF があったりした場合はインストールが途中でストップします.
エラーが発生した場合は以下のコマンドで途中から再開できたりできなかったりします.

 $ ./install-tl -no-gui -profile installation.profile
 ABORTED INSTALLATION FOUND: installation.profile
 Do you want to continue with the exact same settings as before (y/N): y

再開できない場合は[[接続先を変更>TeX Live#tlnet]]するか,または
[[ISO ファイル>TeX Live#iso]]をミラーサイトからダウンロードしてインストールしてください.
インストールが終了したら /usr/local/bin
ディレクトリ配下にシンボリックリンクを追加します.
 $ /usr/local/texlive/????/bin/*/tlmgr path add

***アップデート [#k71f6600]

アップデートには [[tlmgr]] を使用します.
 $ tlmgr update --self --all
を実行すれば OK です.

ただし,アップデートによってパッケージや設定が変更されて,今まで動いていたものが動かなくなったりすることがあるかもしれません.

-/usr/local/texlive/????/tlpkg/backups

にパッケージのバックアップが保存されますので,アップデートによって動作しなくなった場合は以前のバージョンに戻してください.

***タイプセットのしかた [#dab5905e]

(u)pLaTeX + dvipdfmx を実行する場合は [[ptex2pdf]] が便利です.

-pLaTeX + dvipdfmx の場合
 $ ptex2pdf -l -ot '-synctex=1' foo.tex
-upLaTeX + dvipdfmx の場合
 $ ptex2pdf -u -l -ot '-synctex=1' foo.tex

**TeX Live/Cygwin &aname(texlive-cygwin); [#xad0a00d]

TeX Live 由来のパッケージが,texlive.tlpkg に沿ったパッケージングによって
Cygwin 本家から提供されています.
TeX Live のパッケージが一通りそろっていれば問題ないというユーザにとっては十分です.
いわゆる OS のパッケージングなので,Cygwin 本家のパッケージングシステムから独自に変更を加えることに対する対応は甘いという点に,ヘビーユーザは気を付ける必要があります.

***TeX Live/Cygwin 64-bit 版 (x86_64) [#u7b94ff6]
-https://cygwin.com/cgi-bin2/package-grep.cgi?grep=texlive&arch=x86_64
-https://cygwin.com/cygwin/packages/x86_64/texlive-collection-langjapanese/
-https://cygwin.com/cygwin/packages/x86_64/texlive/
-http://ftp.jaist.ac.jp/pub/cygwin/noarch/release/texlive-collection-langjapanese/
-http://ftp.jaist.ac.jp/pub/cygwin/x86_64/release/texlive/

***TeX Live/Cygwin のインストール [#fc129d62]

Cygwin オフィシャルインストーラの setup-x86_64.exe または setup-x86.exe を使って TeX Live/Cygwin をインストールできます.
Cygwin オフィシャルインストーラの setup-x86_64.exe を使って TeX Live/Cygwin をインストールできます.
パッケージ選択画面で Publishing を Default から Install に変更すると TeX Live/Cygwin がフルインストールされます.

***タイプセットのしかた [#ba49fc90]

(u)pLaTeX + dvipdfmx を実行する場合は [[ptex2pdf]] が便利です.
使用法は上の TeX Live 公式パッケージの該当項目を参照してください.


**注意点 [#o2b6fd0e]

***TeX Live/Cygwin の dvipdfmx が TeX Live 公式パッケージの dvipdfmx よりも優先的に実行されて Unable to find TFM file のエラーが発生することがある [#yc6e672e]

TeX Live/Cygwin の dvipdfmx が TeX Live 公式パッケージの dvipdfmx よりも優先的に実行されて Unable to find TFM file のエラーが発生することがあるようです.

TeX Live 公式パッケージの dvipdfmx が優先的に実行されるように PATH を変更するとうまくいくようです.

-[[Unable to find TFM file “″ で2時間無駄にした:http://masuku0w0.hatenablog.jp/entry/2016/04/27/013612]]
-https://twitter.com/I1zkE/status/723790138212376577 , https://twitter.com/I1zkE/status/723795415124996096
-[[【cygwin】w32texとの競合問題:http://bluepost69-tech.hatenablog.com/entry/2016/01/22/031818]]


**不具合 [#iffd4e02]

***TeX Live/Cygwin の dvipdfmx が rungs の呼び出しに失敗する → /usr/share/texmf-dist/dvipdfmx/dvipdfmx.cfg を修正する [#oe289452]

TeX Live/Cygwin の [[dvipdfmx]] がうまく動作しない場合は
/usr/share/texmf-dist/dvipdfmx/dvipdfmx.cfg を修正します.

デフォルトでは
 D  "rungs -q -dNOPAUSE -dBATCH -dEPSCrop -sDEVICE=pdfwrite -dCompatibilityLevel=%v -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -sOutputFile='%o' '%i' -c quit"
に設定されています.
Ghostscript のコマンド名が gs の場合は
 D  "gs -q -dNOPAUSE -dBATCH -dEPSCrop -sDEVICE=pdfwrite -dCompatibilityLevel=%v -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -sOutputFile='%o' '%i' -c quit"
に修正します.

-[[dvipdfmx fails to call rungs:https://cygwin.com/ml/cygwin/2013-01/msg00366.html]]
--[[Re: dvipdfmx fails to call rungs:https://cygwin.com/ml/cygwin/2013-01/msg00370.html]]
-[[Cygwin の TeXLive の dvipdfmx が失敗する:http://d.hatena.ne.jp/tsntsumi/20120514/DvipdfmxInTexLiveOnCygwinFailed]] → [[Cygwin の TeXLive の dvipdfmx が成功した:http://d.hatena.ne.jp/tsntsumi/20120515/DvipdfmxInTeXLiveOnCygwinSucceeded]]


**関連リンク [#bc8cfcc3]
-[[Cygwin:https://www.cygwin.com/]]
--[[The Cygwin Project mailing list archives:https://cygwin.com/ml/cygwin/]]
--[[The cygwin-announce mailing list archives:https://cygwin.com/ml/cygwin-announce/]]
--[[The cygwin-apps mailing list archives:https://cygwin.com/ml/cygwin-apps/]]
-[[Cygwin Ports project:http://sourceware.org/cygwinports/]]
-[[gnupack:http://gnupack.osdn.jp/docs/latest/UsersGuide.html]]

***動作環境 [#n6af06c2]
-http://www.cygwin.com/faq.html#faq.what.supported

***License [#fe355f24]
GPLv3
-https://www.cygwin.com/faq.html#faq.what.free
-https://cygwin.com/licensing.html

***ChangeLog [#t7089ab8]
-https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git
--https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=shortlog
--https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=log