*ptex2pdf [#u0ef9f2c]
* TeX ファイルから PDF ファイルを生成するプログラム ptex2pdf [#headline]
ptex2pdf は uplatex, euptex, uptex, platex, eptex, ptex の中から指定したコマンドと dvipdfmx とを連続して実行する Lua スクリプトです.
ptex2pdf は [[TeX Live]] に含まれています.
もともとは [[TeXworks]] での使用を簡便にするために開発されましたが,[[TeXShop]] などの統合環境においても使用できますし,コマンドライン(ターミナルからの直接の入力)でも使用できます.

&color(White,#5F2F2F){  ''◆CONTENTS◆''  };&br;

----
#contents
----

*ptex2pdf とは [#c565a6de]
ptex2pdf は uplatex, euptex, uptex, platex, eptex, ptex の中から指定したコマンドと dvipdfmx を実行する Lua スクリプトです.~
ptex2pdf は TeX Live, W32TeX に含まれています.~
もともとは TeXworks での使用を簡便にするために開発されましたが、TeXShop その他の統合環境においても使用できますし、コマンドライン(ターミナルからの直接の入力)でも使用できます。~
** 使い方 [#usage]
 ptex2pdf <オプション> <ファイル名.tex>
*** オプション一覧 [#options]
- -v  version
- -h  help
- --help (help の完全版で,TeXworks での設定の説明も含む)
- -e  use eptex class of programs(euptex, eptex を使用する場合に指定)
- -u  use uptex class of programs(uplatex, euptex, uptex を使用する場合に指定)
- -l  use latex based formats(uplatex, platex を使用する場合に指定)
- -s  stop at dvi(PDF を作成しない)
- -i  retain intermediate files(DVI を削除しない)
- -ot '<opts>' extra options for TeX(TeX コンパイラのオプション指定)
- -od '<opts>' extra options for dvipdfmx(dvipdfmx のオプション指定)
- -output-directory '<dir>' directory for created files(出力ファイルのディレクトリを指定)

-http://www.ctan.org/pkg/ptex2pdf
-http://www.preining.info/blog/software-projects/ptex2pdf/
*** 使用例 [#practices]
-upLaTeX でコンパイル
 ptex2pdf -u -l hoge.tex
-upLaTeX でコンパイル,synctex 有効(TeXShop の設定プロファイルから upTeX (ptex2pdf) を設定したときのデフォルト)
 ptex2pdf -u -l -ot "-synctex=1 -file-line-error" hoge.tex
-upLaTeX でコンパイル,synctex 有効,-shell-escape 有効,B5 サイズ指定,PDF 暗号化,印刷のみ許可
 ptex2pdf -u -l -ot "-synctex=1 -file-line-error -shell-escape" -od "-p b5 -S -P 0x0804" hoge.tex

**License [#b37c3e22]
** 注意点 [#notice]

[[GPLv2:https://gitorious.org/tlptexlive/ptex2pdf/source/COPYING]]
*** macOS の TeXstudio で ptex2pdf が動作しない [#osx_texstudio]

**ChangeLog [#e3bc9999]
macOS の [[TeXstudio]] で ptex2pdf が動作しないという報告「[http://tipsboardx.blogspot.jp/2014/06/mac-texstudioptex2pdf.html (mac) TexStudioでptex2pdfが動かない]」があります.

-https://gitorious.org/tlptexlive/ptex2pdf
--https://gitorious.org/tlptexlive/ptex2pdf/commits
-http://www.tug.org/svn/texlive/trunk/Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua?view=markup
--http://www.tug.org/svn/texlive/trunk/Master/texmf-dist/scripts/ptex2pdf/ptex2pdf.lua?view=log
原因の切分けが完全ではありませんが,以下の2ステップを行えば解決するようです.
- ptex2pdf のバージョンが 0.6 より前であれば,
ptex2pdf.lua の shebang line
 #!/usr/bin/env texlua  
の texlua の後ろの余分なスペース2つを削除する
- /Library/TeX/texbin へ PATH を通す(たとえば,~/.bash_profile に export PATH=$PATH:/Library/TeX/texbin を追加する)

*注意点 [#g4630026]
** 不具合 [#bugs]

**OS X の TeXstudio で ptex2pdf が動作しない → ptex2pdf.lua の shebang line #!/usr/bin/env texlua   の texlua の後ろの余分なスペース2つを削除して ~/.bash_profile に export PATH=$PATH:/usr/texbin を追加する [#v4d20b34]
https://github.com/texjporg/ptex2pdf/issues

-[http://tipsboardx.blogspot.jp/2014/06/mac-texstudioptex2pdf.html (mac) TexStudioでptex2pdfが動かない]
***%%Windows 環境で ptex2pdf v0.9 を使用して "予 定.tex" を処理しようとすると dvipdfmx でエラーが発生して "予 定.pdf" が作成できない%%(バーション 20170603.0 で修正済み) [#he5f997c]

*不具合 [#n3e20d7f]
-[[ptex2pdf で &quot;予 定.tex&quot; が処理できない · Issue #10 · texjporg/ptex2pdf · GitHub:https://github.com/texjporg/ptex2pdf/issues/10]]

**TeX Live/Cygwin で ptex2pdf を実行すると /usr/bin/env: texlua  : No such file or directory のエラーが発生する → ptex2pdf.lua の shebang line #!/usr/bin/env texlua   の texlua の後ろの余分なスペース2つを削除 [#g2950b8d]
Windows 環境で ptex2pdf v0.9 を使用して "予 定.tex" を処理しようとすると dvipdfmx でエラーが発生して "予 定.pdf" が作成できません。

TeX Live/Cygwin で ptex2pdf を実行すると /usr/bin/env: texlua  : No such file or directory のエラーが発生します.~
この場合は (u)platex で "予 定.tex" を処理した後で dvipdfmx "予 定.dvi" を実行すると "予 定.pdf" が作成できます。

[[ptex2pdf.lua の 385 行目:https://github.com/texjporg/ptex2pdf/blob/0.9/ptex2pdf.lua#L385]]に記述されている

 bname = string.gsub(bname, "^.*[/\\](.*)$", "%1")

を以下のようにコメントアウトすると処理できるようになるようです。

 --bname = string.gsub(bname, "^.*[/\\](.*)$", "%1")

バージョン 20170603.0 でこのバグは修正されました.

texlive2017-20170524.iso に収録されているのは ptex2pdf v0.9 なので tlmgr で最新版にアップデートしてください.

*** %%TeX Live/Cygwin で ptex2pdf を実行すると /usr/bin/env: texlua  : No such file or directory のエラーが発生する%%(バーション 0.6 で修正済み) [#extra_spaces]

バージョン 0.6 より前では,TeX Live/Cygwin で ptex2pdf を実行すると /usr/bin/env: texlua  : No such file or directory のエラーが発生します.

 $ ptex2pdf -u -l hoge.tex
 /usr/bin/env: texlua  : No such file or directory

ptex2pdf -u -l <FILENAME> を実行すると "/usr/bin/env: texlua  : No such file or directory" と表示される場合は ptex2pdf.lua の shebang line
この場合,ptex2pdf.lua の shebang line
 #!/usr/bin/env texlua  
の texlua の後ろの余分なスペース2つを削除してください.~
の texlua の後ろの余分なスペース2つを削除してください.

-[[Cygwin の setup から texlive パッケージを入れて ptex2pdf -l <FILENAME> としたら "/usr/bin/env: texlua  : No such file or directory" ってエラーになった.:https://twitter.com/tsubuyakisc/status/351962192901443585]]
-[[#!/usr/bin/env texlua   って texlua の後ろに空白文字が2文字ついてた.これを削除して無事 ptex2pdf が動くようになった.:https://twitter.com/tsubuyakisc/status/351962660453093376]]
- [[Cygwin の setup から texlive パッケージを入れて ptex2pdf -l <FILENAME> としたら "/usr/bin/env: texlua  : No such file or directory" ってエラーになった.:https://twitter.com/tsubuyakisc/status/351962192901443585]]
- [[#!/usr/bin/env texlua   って texlua の後ろに空白文字が2文字ついてた.これを削除して無事 ptex2pdf が動くようになった.:https://twitter.com/tsubuyakisc/status/351962660453093376]]

*使い方 [#dfd1522f]
 ptex2pdf <オプション> <ファイル名.tex>
**オプション一覧 [#q9a85657]
- -v  version
- -h  help
- --help (help の完全版で、TeXworks での設定の説明も含む)
- -e  use eptex class of programs(euptex, eptex を使用する場合に指定)
- -u  use uptex class of programs(uplatex, euptex, uptex を使用する場合に指定)
- -l  use latex based formats(uplatex, platex を使用する場合に指定)
- -s  stop at dvi(PDF を作成しない)
- -i  retain intermediate files(dvi を削除しない)
- -ot '<opts>' extra options for TeX(TeX コンパイラのオプション指定)
- -od '<opts>' extra options for dvipdfmx(dvipdfmx のオプション指定)
バージョン 0.6 でこのバグは修正されました.

**使用例 [#ldc0b8f0]
-upLaTeX でコンパイル
 ptex2pdf -u -l hoge.tex
-upLaTeX でコンパイル、synctex 有効(TeXShop の設定プロファイルから upTeX (ptex2pdf) を設定したときのデフォルト)
 ptex2pdf -u -l -ot "-synctex=1 -file-line-error" hoge.tex
-upLaTeX でコンパイル、synctex 有効、-shell-escape 有効、B5 サイズ指定、PDF 暗号化、印刷のみ許可
 ptex2pdf -u -l -ot "-synctex=1 -file-line-error -shell-escape" -od "-p b5 -S -P 0x0804" hoge.tex
-[[latexmk と ptex2pdf:http://konoyonohana.blog.fc2.com/blog-entry-25.html]]
** リンク [#links]

*** 作者による解説 [#project]
http://www.preining.info/blog/software-projects/ptex2pdf/

*** 開発版レポジトリ [#repository]
https://github.com/texjporg/ptex2pdf

*** ライセンス [#license]
[[GPLv3, GPLv2:https://github.com/texjporg/ptex2pdf#copyright-and-license]]

*** 変更履歴 [#changelog]
https://github.com/texjporg/ptex2pdf#changelog

*** CTAN 配布サイト [#ctanurl]
https://ctan.org/pkg/ptex2pdf

*** TeX Live 上の位置 [#texlive]
- ユーザがインストールする位置:[[texmf-dist/scripts/ptex2pdf/>http://www.tug.org/svn/texlive/trunk/Master/texmf-dist/scripts/ptex2pdf/]]
- 開発レポジトリ上の関連する置き場:
-- http://www.tug.org/svn/texlive/trunk/Build/source/texk/texlive/linked_scripts/ptex2pdf/
-- http://www.tug.org/svn/texlive/trunk/Master/texmf-dist/doc/latex/ptex2pdf/

** 関連記事 [#references]

- ptex2pdf は (e)(u)p(la)tex→dvipdfmx という動作に特化していますが,より高い自由度で TeX 関連プログラムを連続起動する仕組みに,[[latexmk>Latexmk]] があります.(Cf. [[latexmk と ptex2pdf:http://konoyonohana.blog.fc2.com/blog-entry-25.html]])